Skip to main content

cognee.datasets

Static class for managing datasets and their data.

Methods

datasets.list_datasets()

Returns all datasets accessible to the resolved user.

datasets.discover_datasets()

Discover dataset names from a local directory layout.

datasets.list_data()

Returns all Data records in a dataset. This is the API to use when you want to read back DataItem fields stored during cognee.add(), such as label and external_metadata.

datasets.has_data()

Check whether a dataset contains any data.

datasets.get_status()

Get pipeline status for one or more datasets. When pipeline_names is omitted, this method keeps the legacy flat shape and returns the status of cognify_pipeline only. With no pipeline_names or a single pipeline name, the method returns {str(dataset_id): PipelineRunStatus}. With multiple pipeline names, it returns {str(dataset_id): {pipeline_name: PipelineRunStatus}}. Possible values: Datasets with no recorded run for the requested pipeline are absent from the result.
get_status() expects dataset_ids to be a list of dataset UUIDs, not dataset names or string ids. Internally the values are bound against the pipeline_runs.dataset_id UUID column, so passing a plain string raises a SQLAlchemy StatementError wrapping one of:
  • AttributeError: 'str' object has no attribute 'hex'
  • ValueError: badly formed hexadecimal UUID string
If you already hold a string id (for example one read back from the HTTP API), wrap it in UUID before calling:

datasets.empty_dataset()

Delete all data in a dataset and remove the dataset itself.
Despite the name, empty_dataset() does not leave an empty dataset record behind. It deletes graph content, data records, and the dataset entity itself.

datasets.delete_data()

Delete a specific data item from a dataset.
mode="hard" is preserved for backward compatibility, but the implementation explicitly warns not to use it.

datasets.delete_all()

Delete all datasets the user has permission to delete.

Examples

Use get_status() in a wait loop to confirm all datasets in a parallel batch have finished indexing before querying.
The same pattern works when indexing is triggered via the HTTP API — poll get_status() from a separate process until all datasets reach DATASET_PROCESSING_COMPLETED or DATASET_PROCESSING_ERRORED.
external_metadata is stored on the relational Data record only. It is not placed into the vector store or knowledge graph and is not returned by cognee.search(). If you need metadata to be vector-searchable, define a custom DataPoint subclass and list the fields to embed in metadata.index_fields. See DataPoints.