To
cognite.neat._session._to.ToAPI
#
API used to write the contents of a NeatSession to a specified destination. For instance writing information rules or DMS rules to a NEAT rules Excel spreadsheet, or writing a verified data model to CDF.
excel(io, include_reference=True, include_properties='all', add_empty_rows=False)
#
Export the verified data model to Excel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
io |
Any
|
The file path or file-like object to write the Excel file to. |
required |
include_reference |
bool | DataModelIdentifier
|
If True, the reference data model will be included. Defaults to True. Note that this only applies if you have created the data model using the create.enterprise_model(...), create.solution_model(), or create.data_product_model() methods. You can also provide a DataModelIdentifier directly, which will be read from CDF |
True
|
include_properties |
Literal['same-space', 'all']
|
The properties to include in the Excel file. Defaults to "all". - "same-space": Only properties that are in the same space as the data model will be included. |
'all'
|
add_empty_rows |
bool
|
If True, empty rows will be added between each component. Defaults to False. |
False
|
Example
Export information model to excel rules sheet
Example
Read CogniteCore model, convert it to an enterprise model, and export it to an excel file
client = CogniteClient()
neat = NeatSession(client)
neat.read.cdf(("cdf_cdm", "CogniteCore", "v1"))
neat.create.enterprise_model(
data_model_id=("sp_doctrino_space", "ExtensionCore", "v1"),
org_name="MyOrg",
)
dms_rules_file_name = "dms_rules.xlsx"
neat.to.excel(dms_rules_file_name, include_reference=True)
Example
Read the data model ("my_space", "ISA95Model", "v5") and export it to an excel file with the CogniteCore model in the reference sheets. ```python client = CogniteClient() neat = NeatSession(client)
neat.read.cdf(("my_space", "ISA95Model", "v5")) dms_rules_file_name = "dms_rules.xlsx" neat.to.excel(dms_rules_file_name, include_reference=("cdf_cdm", "CogniteCore", "v1"))
session(io)
#
yaml(io=None, format='neat', skip_system_spaces=True)
#
Export the verified data model to YAML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
io |
Any | None
|
The file path or file-like object to write the YAML file to. Defaults to None. |
None
|
format |
Literal['neat', 'toolkit']
|
The format of the YAML file. Defaults to "neat". |
'neat'
|
skip_system_spaces |
bool
|
If True, system spaces will be skipped. Defaults to True. |
True
|
YAML formats
- "neat": This is the format Neat uses to store the data model.
- "toolkit": This is the format used by Cognite Toolkit, that matches the CDF API.
Returns:
Type | Description |
---|---|
str | None
|
str | None: If io is None, the YAML string will be returned. Otherwise, None will be returned. |
Example
Export to yaml file in the case of "neat" format
Example
Export yaml files as a zip folder in the case of "toolkit" format
cognite.neat._session._to.CDFToAPI
#
Write a verified Data Model and Instances to CDF.
instances(space=None, space_property=None)
#
Export the verified DMS instances to CDF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space |
str | None
|
Name of instance space to use. Default is to suffix the schema space with '_instances'. Note this space is required to be different from the space with the data model. |
None
|
space_property |
str | None
|
This is an alternative to the 'space' argument. If provided, the space will set to the value of the property with the given name for each instance. If the property is not found, the 'space' argument will be used. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
UploadResultList |
UploadResultList
|
The result of the upload. |
data_model(existing='update', dry_run=False, drop_data=False, components=None)
#
Export the verified DMS data model to CDF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
existing |
Literal['fail', 'skip', 'update', 'force', 'recreate']
|
What to do if the component already exists. Defaults to "update". See the note below for more information about the options. |
'update'
|
dry_run |
bool
|
If True, no changes will be made to CDF. Defaults to False. |
False
|
drop_data |
bool
|
If existing is 'force' or 'recreate' and the operation will lead to data loss, the component will be skipped unless drop_data is True. Defaults to False. Note this only applies to spaces and containers if they contain data. |
False
|
components |
Component | Collection[Component] | None
|
The components to export. If None, all components will be exported. Defaults to None. |
None
|
Data Model creation modes
- "fail": If any component already exists, the export will fail.
- "skip": If any component already exists, it will be skipped.
- "update": If any component already exists, it will be updated.
- "force": If any component already exists, and the update fails, it will be deleted and recreated.
- "recreate": All components will be deleted and recreated. The exception is spaces, which will be updated.