Example #1
0
def get_ltw_data_graph(graph_id=None):
    if not graph_id:
        ltwapp = App.query.filter_by(id=session['app']).first()
        graph_id = ltwapp.graph_id
    if graph_id:
        Virtuoso = plugin("Virtuoso", Store)
        store = Virtuoso(app.config['VIRTUOSO_ODBC'])
        ltw_data_graph = ConjunctiveGraph(store=store)
        g = ltw_data_graph.get_context(graph_id)

        # Initialization step needed to make Virtuoso library work
        g.add((URIRef('initializationstuff'), URIRef('initializationstuff'), URIRef('initializationstuff')))
        g.remove((URIRef('initializationstuff'), URIRef('initializationstuff'), URIRef('initializationstuff')))

        return g
    else:
        return None
Example #2
0
def get_ltw_data_graph(graph_id=None):
    if not graph_id:
        ltwapp = App.query.filter_by(id=session['app']).first()
        graph_id = ltwapp.graph_id
    if graph_id:
        Virtuoso = plugin("Virtuoso", Store)
        store = Virtuoso(app.config['VIRTUOSO_ODBC'])
        ltw_data_graph = ConjunctiveGraph(store=store)
        g = ltw_data_graph.get_context(graph_id)

        # Initialization step needed to make Virtuoso library work
        g.add((URIRef('initializationstuff'), URIRef('initializationstuff'),
               URIRef('initializationstuff')))
        g.remove((URIRef('initializationstuff'), URIRef('initializationstuff'),
                  URIRef('initializationstuff')))

        return g
    else:
        return None
Example #3
0
 def test_get_plugin(self):
     V = plugin("Virtuoso", Store)
     assert V is Virtuoso
Example #4
0
                        <http://helheim.deusto.es/ltw/0.1#ontologyClass> ?class_ont ;
                        <http://helheim.deusto.es/ltw/0.1#identifier> ?id .
               }
        """)

    current_task.update_state(state='PROGRESS',
                              meta={
                                  'progress_percent': 20,
                                  'progress_msg': 'Fetching your data...'
                              })

    ont_id_list = [str(a[0]).lower() + 's' for a in config_q_res]
    ont_class_list = [str(a[1]) for a in config_q_res]

    try:
        Virtuoso = plugin("Virtuoso", Store)
        store = Virtuoso(celery.conf.VIRTUOSO_ODBC)
        ltw_conj_data_graph = ConjunctiveGraph(store=store)
        graph_id = str(uuid.uuid4())
        ltw_data_graph = ltw_conj_data_graph.get_context(graph_id)
    except Exception, e:
        raise Exception("Unable to connect to LTW data source: %s" % str(e))

    progress_per_part = 70 / len(ont_class_list)

    counter = Value('f', float(20))
    max_processes = len(ont_class_list) if len(
        ont_class_list
    ) <= celery.conf.MAX_MULTIPROCESSING else celery.conf.MAX_MULTIPROCESSING
    pool = Pool(max_processes, p_q_initializer, [counter])
Example #5
0
            SELECT DISTINCT ?id ?class_ont
                WHERE {
                    ?s a <http://helheim.deusto.es/ltw/0.1#ClassItem> ;
                        <http://helheim.deusto.es/ltw/0.1#ontologyClass> ?class_ont ;
                        <http://helheim.deusto.es/ltw/0.1#identifier> ?id .
               }
        """
    )

    current_task.update_state(state='PROGRESS', meta={'progress_percent': 20, 'progress_msg': 'Fetching your data...'})

    ont_id_list = [ str(a[0]).lower() + 's' for a in config_q_res ]
    ont_class_list = [ str(a[1]) for a in config_q_res ]

    try:
        Virtuoso = plugin("Virtuoso", Store)
        store = Virtuoso(celery.conf.VIRTUOSO_ODBC)
        ltw_conj_data_graph = ConjunctiveGraph(store=store)
        graph_id = str(uuid.uuid4())
        ltw_data_graph = ltw_conj_data_graph.get_context(graph_id)
    except Exception, e:
        raise Exception("Unable to connect to LTW data source: %s" % str(e))

    progress_per_part = 70 / len(ont_class_list)

    counter = Value('f', float(20))
    max_processes = len(ont_class_list) if len(ont_class_list) <= celery.conf.MAX_MULTIPROCESSING else celery.conf.MAX_MULTIPROCESSING
    pool = Pool(max_processes, p_q_initializer, [counter])

    if len(ont_id_list) > 1:
        fetch_msg = 'Fetching %s' % ', '.join(ont_id_list[:-1])
Example #6
0
 def test_get_plugin(self):
     V = plugin("Virtuoso", Store)
     assert V is Virtuoso