Higher-level wrapper for deploying projects and bulk import/export of data.
| Method | __init__ |
Initialise the Gateway. |
| Method | clear |
Clear all data from all datasets in the project. |
| Method | dump |
Export entity data from the project to JSON files on disk. |
| Method | dump |
Export the project schema and dataset configurations to JSON files. |
| Method | load |
Load data from JSON files into the DataGraphs project. |
| Method | load |
Deploy the project schema and datasets to the API. |
| Constant | UNKNOWN |
Undocumented |
| Property | client |
The underlying Client instance. |
| Method | _dump |
Dump the project datasets to JSON files. |
| Method | _dump |
Dump the project schema to a JSON file. |
| Method | _ensure |
Validate that no duplicate class names are found across the provided datasets. |
| Method | _get |
Undocumented |
| Method | _get |
Undocumented |
| Method | _load |
Load data for a specific class from a JSON file. |
| Method | _load |
Load data for all non-base classes in a dataset. |
| Method | _load |
Read a JSON file and PUT its contents into the project. |
| Method | _map |
Re-map URN project segments to match the current client project. |
| Method | _persist |
Fetch entities of class_name from the API and write them to a JSON file. |
| Method | _validate |
Validate that the local and API datasets match in terms of class names. |
| Method | _verify |
Undocumented |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _schema |
Undocumented |
| Instance Variable | _wait |
Undocumented |
DatagraphsClient, wait_time_ms: int = DatagraphsClient.DEFAULT_WAIT_TIME_MS):
¶
Initialise the Gateway.
| Parameters | |
client:DatagraphsClient | A DataGraphs API client. |
waitint | Delay in milliseconds between successive API calls. |
str | Path, class_name: str = Schema.ALL_CLASSES, include_date_fields: bool = False) -> dict:
¶
Export entity data from the project to JSON files on disk.
Each class is written to a separate <ClassName>.json file. Base classes are automatically skipped.
| Parameters | |
tostr | Path | Target directory. Created automatically if it does not exist. |
classstr | The class name to dump, or Schema.ALL_CLASSES for all. |
includebool | Whether to include system date metadata. |
| Returns | |
dict | A dict with an exported count. |
Export the project schema and dataset configurations to JSON files.
Files are named {project_name}-v{version}-schema.json and {project_name}-v{version}-datasets.json.
| Parameters | |
schemastr | Path | Directory to write the schema JSON file. |
datasetsstr | Path | Directory to write the datasets JSON file. |
str = Schema.ALL_CLASSES, from_dir_path: str | Path = '', file_path: str | Path = '') -> dict:
¶
Load data from JSON files into the DataGraphs project.
Base classes (those with subclasses) are automatically skipped when loading all classes.
| Parameters | |
classstr | The class name to load, or Schema.ALL_CLASSES to load every non-base class found across all datasets. |
fromstr | Path | Directory containing <ClassName>.json files. |
filestr | Path | Explicit path to a single JSON file (used when loading a specific class_name). |
| Returns | |
dict | A dict with loaded and skipped counts. |
Schema, datasets: list[ Dataset], validation_mode: VALIDATION_MODE = VALIDATION_MODE.PROMPT):
¶
Deploy the project schema and datasets to the API.
Tears down existing datasets before applying the new schema and datasets.
| Parameters | |
schema:Schema | The schema to deploy. |
datasets:list[ | The datasets to deploy. |
validationVALIDATION_MODE | How to handle mismatches between deployment and
existing datasets. See VALIDATION_MODE. |
| Raises | |
ValueError | If duplicate class names are found across datasets. |
dict, class_name: str, dataset_slug: str, from_dir_path: str | Path = '', file_path: str | Path = '') -> dict:
¶
Load data for a specific class from a JSON file.
dict, dataset: Dataset, from_dir_path: str | Path) -> dict:
¶
Load data for all non-base classes in a dataset.
str, dataset_slug: str, from_dir_path: str | Path = '', file_path: str | Path = '') -> dict:
¶
Read a JSON file and PUT its contents into the project.
- Returns:
- A dict with loaded and skipped counts.
- Raises:
- FileNotFoundError: If file_path was explicitly provided but does not exist.
Re-map URN project segments to match the current client project.
- Args:
- data: A list of entity dicts, each containing an id URN.
- Returns:
- The list with URNs re-mapped where necessary.
- Raises:
- ValueError: If an entity is missing a valid string id.
str, to_dir_path: str | Path, include_date_fields: bool) -> int:
¶
Fetch entities of class_name from the API and write them to a JSON file.
- Args:
- class_name: The class name to fetch. to_dir_path: Target directory (must already exist).
list[ Dataset], existing_datasets: list[ Dataset], validation_mode: VALIDATION_MODE):
¶
Validate that the local and API datasets match in terms of class names.