Skip to content

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¤

Bases: DeleteConfig

Graph Insight Snapshot Delete Configuration.

Attributes:

  • model_config

GraphInsightUpdateConfig¤

Bases: UpdateConfig

Graph Insight Snapshot Update Configuration.

Attributes:

  • model_config

GraphInsightsRepository¤

GraphInsightsRepository(client)

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(iri)

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()

Delete all snapshots via the bulk DELETE endpoint.

delete_item¤

delete_item(key, skip_if_missing=False, configuration=None)

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:

fetch_data¤

fetch_data()

Fetch all snapshots from the semspect status endpoint.

get_status¤

get_status(snapshot_id)

Fetch current status of a single snapshot.

Parameters:

  • snapshot_id (str) – The snapshot database ID.

Returns:

is_available¤

is_available()

Return True if the semspect extension is active and the user is allowed.

items¤

items()

Get the items of the repository

keys¤

keys()

Get the keys of the repository

logger¤

logger: logging.Logger

Gets the client logger

update_item¤

update_item(item, configuration=None)

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:

values¤

values()

Get the values of the repository

wait_for_completion¤

wait_for_completion(snapshot_id, timeout=120.0, poll_interval=2.0)

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:

Raises:

  • TimeoutError – if the snapshot is still ONGOING after timeout seconds.

Comments