src/pybel/manager/cache_manager.py
def _store_graph_parts(self, graph: BELGraph, use_tqdm: bool = False) -> Tuple[List[Node], List[Edge]]:
        """Store the given graph into the edge store.

        :raises: pybel.resources.exc.ResourceError
        :raises: EdgeAddError
        """
        logger.debug('inserting %s into edge store', graph)
        logger.debug('building node models')
        node_model_build_start = time.time()

        nodes = list(graph)
        if use_tqdm:
            nodes = tqdm(nodes, total=graph.number_of_nodes(), desc='nodes')

        node_model = {}
        for node in nodes:
            node_object = self.get_or_create_node(graph, node)

            if node_object is None:
                logger.warning('can not add node %s', node)
                continue

            node_model[node] = node_object

        node_models = list(node_model.values())
        logger.debug('built %d node models in %.2f seconds', len(node_models), time.time() - node_model_build_start)

        node_model_commit_start = time.time()
        self.session.add_all(node_models)
        self.session.commit()
        logger.debug('stored %d node models in %.2f seconds', len(node_models), time.time() - node_model_commit_start)

        logger.debug('building edge models')
        edge_model_build_start = time.time()

        edges = graph.edges(keys=True, data=True)
        if use_tqdm:
            edges = tqdm(edges, total=graph.number_of_edges(), desc='edges')

        edge_models = list(self._get_edge_models(graph, node_model, edges))

        logger.debug('built %d edge models in %.2f seconds', len(edge_models), time.time() - edge_model_build_start)

        edge_model_commit_start = time.time()
        self.session.add_all(edge_models)
        self.session.commit()
        logger.debug('stored %d edge models in %.2f seconds', len(edge_models), time.time() - edge_model_commit_start)

        return node_models, edge_models
Store the given graph into the edge store.

        :raises: pybel.resources.exc.ResourceError
        :raises: EdgeAddError
        
Store the given graph into the edge store.
Store the given graph into the edge store .
def _store_graph_parts(self, graph: BELGraph, use_tqdm: bool = False) -> Tuple[List[Node], List[Edge]]:
        logger.debug('inserting %s into edge store', graph)
        logger.debug('building node models')
        node_model_build_start = time.time()
        nodes = list(graph)
        if use_tqdm:
            nodes = tqdm(nodes, total=graph.number_of_nodes(), desc='nodes')
        node_model = {}
        for node in nodes:
            node_object = self.get_or_create_node(graph, node)
            if node_object is None:
                logger.warning('can not add node %s', node)
                continue
            node_model[node] = node_object
        node_models = list(node_model.values())
        logger.debug('built %d node models in %.2f seconds', len(node_models), time.time() - node_model_build_start)
        node_model_commit_start = time.time()
        self.session.add_all(node_models)
        self.session.commit()
        logger.debug('stored %d node models in %.2f seconds', len(node_models), time.time() - node_model_commit_start)
        logger.debug('building edge models')
        edge_model_build_start = time.time()
        edges = graph.edges(keys=True, data=True)
        if use_tqdm:
            edges = tqdm(edges, total=graph.number_of_edges(), desc='edges')
        edge_models = list(self._get_edge_models(graph, node_model, edges))
        logger.debug('built %d edge models in %.2f seconds', len(edge_models), time.time() - edge_model_build_start)
        edge_model_commit_start = time.time()
        self.session.add_all(edge_models)
        self.session.commit()
        logger.debug('stored %d edge models in %.2f seconds', len(edge_models), time.time() - edge_model_commit_start)
        return node_models, edge_models
def _store_graph_parts ( self , graph : BELGraph , use_tqdm : bool = False ) -> Tuple [ List [ Node ] , List [ Edge ] ] : logger . debug ( 'inserting %s into edge store' , graph ) logger . debug ( 'building node models' ) node_model_build_start = time . time ( ) nodes = list ( graph ) if use_tqdm : nodes = tqdm ( nodes , total = graph . number_of_nodes ( ) , desc = 'nodes' ) node_model = { } for node in nodes : node_object = self . get_or_create_node ( graph , node ) if node_object is None : logger . warning ( 'can not add node %s' , node ) continue node_model [ node ] = node_object node_models = list ( node_model . values ( ) ) logger . debug ( 'built %d node models in %.2f seconds' , len ( node_models ) , time . time ( ) - node_model_build_start ) node_model_commit_start = time . time ( ) self . session . add_all ( node_models ) self . session . commit ( ) logger . debug ( 'stored %d node models in %.2f seconds' , len ( node_models ) , time . time ( ) - node_model_commit_start ) logger . debug ( 'building edge models' ) edge_model_build_start = time . time ( ) edges = graph . edges ( keys = True , data = True ) if use_tqdm : edges = tqdm ( edges , total = graph . number_of_edges ( ) , desc = 'edges' ) edge_models = list ( self . _get_edge_models ( graph , node_model , edges ) ) logger . debug ( 'built %d edge models in %.2f seconds' , len ( edge_models ) , time . time ( ) - edge_model_build_start ) edge_model_commit_start = time . time ( ) self . session . add_all ( edge_models ) self . session . commit ( ) logger . debug ( 'stored %d edge models in %.2f seconds' , len ( edge_models ) , time . time ( ) - edge_model_commit_start ) return node_models , edge_models
Store the given graph into the edge store.
Store the given graph into the edge store .
"""Store the given graph into the edge store.

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