def insert_graph( manager: Manager, graph: BELGraph, user: User, public: bool = True, use_tqdm: bool = False, ) -> Network: """Insert a graph and also make a report. :param manager: A PyBEL manager :param graph: A BEL graph :param user: The identifier of the user to report. Defaults to 1. Can also give a user object. :param public: Should the network be public? Defaults to False. :param use_tqdm: Show a progress bar? Defaults to False. :raises: TypeError """ if manager.has_name_version(graph.name, graph.version): logger.info('database already has %s', graph) return manager.get_network_by_name_version(graph.name, graph.version) network = manager.insert_graph(graph, use_tqdm=use_tqdm) report = Report(public=public, user=user) fill_out_report(graph=graph, network=network, report=report) manager.session.add(report) manager.session.commit() return network
def get_numbers(graph: pybel.BELGraph, manager: pybel.Manager)->float: """Insert and drop a graph to count how long it takes. :param graph: :param manager: :return: The time it took to drop """ print('inserting') parse_start_time = time.time() network = manager.insert_graph(graph) print(f'inserted in {time.time() - parse_start_time:.2f} seconds') print('dropping') drop_start_time = time.time() manager.drop_network(network) drop_time = time.time() - drop_start_time print(f'dropped in {drop_time:.2f} seconds') return drop_time