def ENTSOE_FullGrid(refresh=False): if not refresh: try: return load( os.path.join(get_path("DATASETROOT"), "FullGrid", "out.db")) except FileNotFoundError: return parse(os.path.join(get_path("DATASETROOT"), "FullGrid")) else: return parse(os.path.join(get_path("DATASETROOT"), "FullGrid"))
def ENTSOE_MiniNB(refresh=False): if not refresh: try: return load( os.path.join(get_path("DATASETROOT"), "MiniGrid_NodeBreaker", "out.db")) except FileNotFoundError: return parse( os.path.join(get_path("DATASETROOT"), "MiniGrid_NodeBreaker")) else: return parse( os.path.join(get_path("DATASETROOT"), "MiniGrid_NodeBreaker"))
def test_too_generic_object_declaration(): # In this testcase the merge order of the id- and about-object references is changed. This # should not be a problem with pytest.raises(ValueError): dataset = os.path.join(p_test_datasets, "terminal_declaration_too_generic") s, m = parse(dataset, backend=backends.InMemory)
def lint(dataset, silence_tqdm): _, ext = os.path.splitext(dataset) if os.path.isdir(dataset) or ext == ".zip" or ext == ".rdf": session, model = cimpyorm.parse(dataset, InMemory(), silence_tqdm=silence_tqdm) elif ext == ".db": session, model = cimpyorm.load(dataset) else: raise ValueError("Invalid dataset path.") print(cimpyorm.lint(session, model)) embed()
def parse(dataset, silence_tqdm): """ Parse a dataset into a database backend. :param dataset: Path to the cim snapshot. :param backend: Database backend to be used (defaults to a SQLite on-disk database in the dataset location). :param silence_tqdm: Silence tqdm progress bars """ s, m = session, model = cimpyorm.parse(dataset, SQLite(), silence_tqdm) embed()
def test_merge_w_inconsistent_classnames(): dataset = os.path.join( p_test_datasets, "mergeable_dataset_w_inconsistent_class_definitions") s, m = parse(dataset, backend=backends.InMemory) assert_complete_basic_terminal_element(s, m)
def test_merge_across_profiles(): dataset = os.path.join(p_test_datasets, "basic_mergeable_dataset") s, m = parse(dataset, backend=backends.InMemory) assert_complete_basic_terminal_element(s, m)
def test_reverse_order_uuid_usage(): # In this testcase the merge order of the id- and about-object references is changed. This # should not be a problem dataset = os.path.join(p_test_datasets, "basic_reverse_order_merge") s, m = parse(dataset, backend=backends.InMemory) assert_complete_basic_terminal_element(s, m)
def test_merge_across_profiles(): with path(test_datasets, "basic_mergeable_dataset") as dataset: s, m = parse(dataset, backend=backends.InMemory) assert_complete_basic_terminal_element(s, m)
def test_parse_with_schema_directory(full_grid): s, m = parse(full_grid, schema=os.path.join(get_path("SCHEMAROOT"), "CIM16"), backend=InMemory) assert m.ACLineSegment assert s.query(m.Terminal).count() > 0