cmem_client.repositories.graph_imports¤
Repository for the owl:imports relations between named graphs.
Provides GraphImportsRepository for adding and removing an import statement between two
graphs, and for resolving the resulting import tree of a graph. Items are keyed by
from_graph::::to_graph.
Examples:
Declare that one graph imports another and remove the relation again:
>>> from cmem_client.client import Client
>>> from cmem_client.models.graph_import import GraphImport
>>> client = Client.from_env()
>>> client.graph_imports.create_item(
... GraphImport(
... from_graph="https://example.org/data/",
... to_graph="https://example.org/vocab/",
... )
... )
>>> client.graph_imports.delete_item(
... "https://example.org/data/::::https://example.org/vocab/"
... )
Resolve what a graph pulls in, directly and transitively:
>>> client.graph_imports.get_transitive_imports("https://example.org/data/")
>>> client.graph_imports.get_import_tree("https://example.org/data/")
Classes:
- GraphImportsCreateConfig – Graph Imports creation configuration
- GraphImportsDeleteConfig – Graph Imports deletion configuration.
- GraphImportsRepository – Repository for managing Graph Imports
Attributes:
GRAPH_IMPORTS_CREATE_SPARQL¤
GRAPH_IMPORTS_CREATE_SPARQL = '\nPREFIX owl: <http://www.w3.org/2002/07/owl#>\n\nINSERT DATA {{\n GRAPH <{from_graph}> {{\n <{from_graph}> owl:imports <{to_graph}> .\n }}\n}}\n'
GRAPH_IMPORTS_DELETE_SPARQL¤
GRAPH_IMPORTS_DELETE_SPARQL = '\nPREFIX owl: <http://www.w3.org/2002/07/owl#>\n\nDELETE DATA {{\n GRAPH <{from_graph}> {{\n <{from_graph}> owl:imports <{to_graph}> .\n }}\n}}\n'
GRAPH_IMPORTS_LIST_SPARQL¤
GRAPH_IMPORTS_LIST_SPARQL = '\nPREFIX owl: <http://www.w3.org/2002/07/owl#>\n\nSELECT ?from_graph ?to_graph\nWHERE\n{\n GRAPH ?from_graph {\n ?from_graph owl:imports ?to_graph\n }\n}\n'
GraphImportsCreateConfig¤
Bases: CreateConfig
Graph Imports creation configuration
Attributes:
- model_config –
GraphImportsDeleteConfig¤
Bases: DeleteConfig
Graph Imports deletion configuration.
Attributes:
- model_config –
GraphImportsRepository¤
Bases: Repository, CreateItemProtocol, DeleteItemProtocol
Repository for managing Graph Imports
Functions:
- create_item – Create (add) a new item to the repository
- delete_all – Delete all items from the repository
- delete_item – Delete an item from the repository
- fetch_data – Fetch new data and update the repository
- get_import_tree – Get the hierarchical import tree structure for a graph.
- get_transitive_imports – Get the list of graphs imported by a graph, resolved transitively.
- items – Get the items of the repository
- keys – Get the keys of the repository
- raise_modification_error – Raise an exception if needed
- values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
create_item¤
Create (add) a new item to the repository
Parameters:
- item (
ItemType) – The item to add to the repository - skip_if_existing (
bool) – If true, creating already existing items will be ignored - configuration (
CreateItemConfig_contra | None) – Optional configuration
Raises:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
delete_all¤
Delete all items from the repository
delete_item¤
Delete an item from the repository
Parameters:
- key (
str) – The key of the item to delete - skip_if_missing (
bool) – If True, it is ignored if the deleted item even exists - configuration (
DeleteItemConfig) – Optional configuration for deletion
Raises:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
fetch_data¤
Fetch new data and update the repository
get_import_tree¤
Get the hierarchical import tree structure for a graph.
Parameters:
- graph_iri (
str) – The IRI of the graph to retrieve the import tree for.
Returns:
GraphImportTree– A GraphImportTree with tree and ignored dicts mapping graph IRIs to lists of IRIs.
get_transitive_imports¤
Get the list of graphs imported by a graph, resolved transitively.
Parameters:
- graph_iri (
str) – The IRI of the graph to retrieve transitive imports for.
Returns:
list[str]– A flat list of graph IRIs that are transitively imported by graph_iri.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
raise_modification_error¤
Raise an exception if needed
values¤
Get the values of the repository