src/pybel/manager/cache_manager.py
def insert_graph(
        self,
        graph: BELGraph,
        use_tqdm: bool = True,
    ) -> Network:
        """Insert a graph in the database and returns the corresponding Network model.

        :raises: pybel.resources.exc.ResourceError
        """
        if not graph.name:
            raise ValueError('Can not upload a graph without a name')

        if not graph.version:
            raise ValueError('Can not upload a graph without a version')

        logger.debug('inserting %s v%s', graph.name, graph.version)

        t = time.time()

        namespace_urls = graph.namespace_url.values()
        self._ensure_namespace_urls(namespace_urls, use_tqdm=use_tqdm)
        for keyword, pattern in graph.namespace_pattern.items():
            self.ensure_regex_namespace(keyword, pattern)

        annotation_urls = graph.annotation_url.values()
        self._ensure_namespace_urls(annotation_urls, use_tqdm=use_tqdm, is_annotation=True)

        network = Network(**{
            key: value
            for key, value in graph.document.items()
            if key in METADATA_INSERT_KEYS
        })

        network.store_bel(graph)

        network.nodes, network.edges = self._store_graph_parts(graph, use_tqdm=use_tqdm)

        self.session.add(network)
        self.session.commit()

        logger.info('inserted %s v%s in %.2f seconds', graph.name, graph.version, time.time() - t)

        return network
Insert a graph in the database and returns the corresponding Network model.

        :raises: pybel.resources.exc.ResourceError
        
Insert a graph in the database and returns the corresponding Network model.
Insert a graph in the database and returns the corresponding Network model .
def insert_graph(
        self,
        graph: BELGraph,
        use_tqdm: bool = True,
    ) -> Network:
        if not graph.name:
            raise ValueError('Can not upload a graph without a name')
        if not graph.version:
            raise ValueError('Can not upload a graph without a version')
        logger.debug('inserting %s v%s', graph.name, graph.version)
        t = time.time()
        namespace_urls = graph.namespace_url.values()
        self._ensure_namespace_urls(namespace_urls, use_tqdm=use_tqdm)
        for keyword, pattern in graph.namespace_pattern.items():
            self.ensure_regex_namespace(keyword, pattern)
        annotation_urls = graph.annotation_url.values()
        self._ensure_namespace_urls(annotation_urls, use_tqdm=use_tqdm, is_annotation=True)
        network = Network(**{
            key: value
            for key, value in graph.document.items()
            if key in METADATA_INSERT_KEYS
        })
        network.store_bel(graph)
        network.nodes, network.edges = self._store_graph_parts(graph, use_tqdm=use_tqdm)
        self.session.add(network)
        self.session.commit()
        logger.info('inserted %s v%s in %.2f seconds', graph.name, graph.version, time.time() - t)
        return network
def insert_graph ( self , graph : BELGraph , use_tqdm : bool = True , ) -> Network : if not graph . name : raise ValueError ( 'Can not upload a graph without a name' ) if not graph . version : raise ValueError ( 'Can not upload a graph without a version' ) logger . debug ( 'inserting %s v%s' , graph . name , graph . version ) t = time . time ( ) namespace_urls = graph . namespace_url . values ( ) self . _ensure_namespace_urls ( namespace_urls , use_tqdm = use_tqdm ) for keyword , pattern in graph . namespace_pattern . items ( ) : self . ensure_regex_namespace ( keyword , pattern ) annotation_urls = graph . annotation_url . values ( ) self . _ensure_namespace_urls ( annotation_urls , use_tqdm = use_tqdm , is_annotation = True ) network = Network ( ** { key : value for key , value in graph . document . items ( ) if key in METADATA_INSERT_KEYS } ) network . store_bel ( graph ) network . nodes , network . edges = self . _store_graph_parts ( graph , use_tqdm = use_tqdm ) self . session . add ( network ) self . session . commit ( ) logger . info ( 'inserted %s v%s in %.2f seconds' , graph . name , graph . version , time . time ( ) - t ) return network
Insert a graph in the database and returns the corresponding Network model.
Insert a graph in the database and returns the corresponding Network model .
"""Insert a graph in the database and returns the corresponding Network model.

        :raises: pybel.resources.exc.ResourceError
        """
None
self
graph
BELGraph
use_tqdm
bool