Skip to content

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

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

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 .to_enterprise(), .to_solution(), or .to_data_product() methods.

True
Example

Export information model to excel rules sheet

information_rules_file_name = "information_rules.xlsx"
neat.to.excel(information_rules_file_name)

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.verify()
neat.prepare.data_model.to_enterprise(
    data_model_id=("sp_doctrino_space", "ExtensionCore", "v1"),
    org_name="MyOrg",
    move_connections=True
)
dms_rules_file_name = "dms_rules.xlsx"
neat.to.excel(dms_rules_file_name, include_reference=True)

session(io) #

Export the current session to a file.

Parameters:

Name Type Description Default
io Any

The file path to file-like object to write the session to.

required
Example

Export the session to a file

session_file_name = "neat_session.zip"
neat.to.session(session_file_name)

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

your_yaml_file_name = "neat_rules.yaml"
neat.to.yaml(your_yaml_file_name, format="neat")

Example

Export yaml files as a zip folder in the case of "toolkit" format

your_zip_folder_name = "toolkit_data_model_files.zip"
neat.to.yaml(your_zip_folder_name, format="toolkit")

Example

Export yaml files to a folder in the case of "toolkit" format

your_folder_name = "my_project/data_model_files"
neat.to.yaml(your_folder_name, format="toolkit")

cognite.neat._session._to.CDFToAPI #

Write a verified Data Model and Instances to CDF.

instances(space=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'.

None

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.