cmem_client.repositories.graph_insights¤
Repository for the Graph Insights snapshots of Corporate Memory.
Provides GraphInsightsRepository for creating statistics snapshots of a graph, polling their computation and deleting them. Graph Insights is an optional extension, so check that it is enabled before using it.
Examples:
Check whether the extension is available, then create a snapshot:
>>> from cmem_client.client import Client
>>> client = Client.from_env()
>>> client.graph_insights.is_available()
>>> snapshot_id = client.graph_insights.create("https://ns.eccenca.com/data/config/")
>>> client.graph_insights.wait_for_completion(snapshot_id)
Read the snapshots and drop them again:
>>> client.graph_insights.fetch_data()
>>> list(client.graph_insights)
>>> client.graph_insights.delete_item(snapshot_id)
Classes:
- GraphInsightDeleteConfig – Graph Insight Snapshot Delete Configuration.
- GraphInsightUpdateConfig – Graph Insight Snapshot Update Configuration.
- GraphInsightsRepository – Repository for the semspect Graph Insights extension.
GraphInsightDeleteConfig¤
Bases: DeleteConfig
Graph Insight Snapshot Delete Configuration.
Attributes:
- model_config –
GraphInsightUpdateConfig¤
Bases: UpdateConfig
Graph Insight Snapshot Update Configuration.
Attributes:
- model_config –
GraphInsightsRepository¤
Bases: Repository[GraphInsightSnapshot], DeleteItemProtocol, UpdateItemProtocol
Repository for the semspect Graph Insights extension.
Does not auto-fetch on init because semspect is optional and may not be installed. Call fetch_data() explicitly before iterating snapshots.
Functions:
- create – Create or update a snapshot for the given graph IRI.
- delete_all – Delete all snapshots via the bulk DELETE endpoint.
- delete_item – Delete an item from the repository
- fetch_data – Fetch all snapshots from the semspect status endpoint.
- get_status – Fetch current status of a single snapshot.
- is_available – Return True if the semspect extension is active and the user is allowed.
- items – Get the items of the repository
- keys – Get the keys of the repository
- update_item – Update an existing item in the repository.
- values – Get the values of the repository
- wait_for_completion – Poll until snapshot status is no longer ONGOING.
Attributes:
- logger (
Logger) – Gets the client logger
create¤
Create or update a snapshot for the given graph IRI.
Parameters:
- iri (
str) – The graph IRI to create a snapshot for.
Returns:
str– The snapshot ID returned by the server.
delete_all¤
Delete all snapshots via the bulk DELETE endpoint.
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 all snapshots from the semspect status endpoint.
get_status¤
Fetch current status of a single snapshot.
Parameters:
- snapshot_id (
str) – The snapshot database ID.
Returns:
GraphInsightSnapshot– A GraphInsightSnapshot with current status fields.
is_available¤
Return True if the semspect extension is active and the user is allowed.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
update_item¤
Update an existing item in the repository.
Parameters:
- item (
ItemType) – The item to update in the repository. - configuration (
UpdateItemConfig_contra | None) – Optional configuration for the update operation.
Raises:
RepositoryModificationError– If the item does not exist or an error occurs.HTTPError– For any other HTTP error.
values¤
Get the values of the repository
wait_for_completion¤
Poll until snapshot status is no longer ONGOING.
Parameters:
- snapshot_id (
str) – The snapshot database ID to wait for. - timeout (
float) – Maximum seconds to wait before raising TimeoutError. - poll_interval (
float) – Seconds between status checks.
Returns:
GraphInsightSnapshot– The snapshot once it reaches a terminal state.
Raises:
TimeoutError– if the snapshot is still ONGOING after timeout seconds.