Skip to content

Read

cognite.neat._session._read.CDFReadAPI #

Bases: BaseReadAPI

Reads from CDF Data Models. Use the .data_model() method to load a CDF Data Model to the knowledge graph.

data_model(data_model_id) #

Reads a Data Model from CDF to the knowledge graph.

Parameters:

Name Type Description Default
data_model_id DataModelIdentifier

Tuple of strings with the id of a CDF Data Model.

required
Example
neat.read.cdf.data_model(("example_data_model_space", "EXAMPLE_DATA_MODEL", "v1"))

graph(data_model_id, instance_space=None, skip_cognite_views=True) #

Reads a knowledge graph from Cognite Data Fusion (CDF).

Parameters:

Name Type Description Default
data_model_id DataModelIdentifier

Tuple of strings with the id of a CDF Data Model.

required
instance_space str | SequenceNotStr[str] | None

The instance spaces to extract. If None, all instance spaces are extracted.

None
skip_cognite_views bool

If True, all Cognite Views are skipped. For example, if you have the CogniteAsset view in you data model, it will ont be used to extract instances.

True

Returns:

Name Type Description
IssueList IssueList

A list of issues that occurred during the extraction.

cognite.neat._session._read.CDFClassicAPI #

Bases: BaseReadAPI

Reads from the Classic Data Model from CDF. Use the .graph() method to load CDF core resources to the knowledge graph.

graph(root_asset_external_id, limit_per_type=None, identifier='id') #

Reads the classic knowledge graph from CDF.

The Classic Graph consists of the following core resource type.

Classic Node CDF Resources

  • Assets
  • TimeSeries
  • Sequences
  • Events
  • Files

All the classic node CDF resources can have one or more connections to one or more assets. This will match a direct relationship in the data modeling of CDF.

In addition, you have relationships between the classic node CDF resources. This matches an edge in the data modeling of CDF.

Finally, you have labels and data sets that to organize the graph. In which data sets have a similar, but different, role as a space in data modeling. While labels can be compared to node types in data modeling, used to quickly filter and find nodes/edges.

This extractor will extract the classic CDF graph into Neat starting from either a data set or a root asset.

It works as follows
  1. Extract all core nodes (assets, time series, sequences, events, files) filtered by the given data set or root asset.
  2. Extract all relationships starting from any of the extracted core nodes.
  3. Extract all core nodes that are targets of the relationships that are not already extracted.
  4. Extract all labels that are connected to the extracted core nodes/relationships.
  5. Extract all data sets that are connected to the extracted core nodes/relationships.

Parameters:

Name Type Description Default
root_asset_external_id str

The external id of the root asset

required
limit_per_type int | None

The maximum number of nodes to extract per core node type. If None, all nodes are extracted.

None
identifier Literal['id', 'externalId']

The identifier to use for the core nodes. Note selecting "id" can cause issues if the external ID of the core nodes is missing. Default is "id".

'id'

Returns:

Name Type Description
IssueList IssueList

A list of issues that occurred during the extraction.

Example
neat.read.cdf.graph("root_asset_external_id")

cognite.neat._session._read.ExcelReadAPI #

Bases: BaseReadAPI

Reads a Neat Excel Rules sheet to the graph store. The rules sheet may stem from an Information architect, or a DMS Architect.

Parameters:

Name Type Description Default
io

file path to the Excel sheet

required
Example
neat.read.excel("information_or_dms_rules_sheet.xlsx")

__call__(io, enable_manual_edit=False) #

Reads a Neat Excel Rules sheet to the graph store. The rules sheet may stem from an Information architect, or a DMS Architect.

Parameters:

Name Type Description Default
io Any

file path to the Excel sheet

required
enable_manual_edit bool

If True, the user will be able to re-import rules which where edit outside NeatSession

False

Manual Edit Warning

This is an alpha feature and is subject to change without notice. It is expected to have some limitations and may not work as expected in all cases.

cognite.neat._session._read.YamlReadAPI #

Bases: BaseReadAPI

__call__(io, format='neat') #

Reads a yaml with either neat rules, or several toolkit yaml files to import Data Model(s) into NeatSession.

Parameters:

Name Type Description Default
io Any

File path to the Yaml file in the case of "neat" yaml, or path to a zip folder or directory with several Yaml files in the case of "toolkit".

required
format Literal['neat', 'toolkit']

The format of the yaml file(s). Can be either "neat" or "toolkit".

'neat'
Example
neat.read.yaml("path_to_toolkit_yamls")

cognite.neat._session._read.CSVReadAPI #

Bases: BaseReadAPI

Reads a csv that contains a column to use as primary key which will be the unique identifier for the type of data you want to read in. Ex. a csv can hold information about assets, and their identifiers are specified in a "ASSET_TAG" column.

Parameters:

Name Type Description Default
io

file path or url to the csv

required
type

string that specifies what type of data the csv contains. For instance "Asset" or "Equipment"

required
primary_key

string name of the column that should be used as the unique identifier for each row of data

required
Example
type_described_in_table = "Turbine"
column_with_identifier = "UNIQUE_TAG_NAME"
neat.read.csv("url_or_path_to_csv_file", type=type_described_in_table, primary_key=column_with_identifier)

cognite.neat._session._read.XMLReadAPI #

Bases: BaseReadAPI

Reads an XML file that is either of DEXPI or AML format.

Parameters:

Name Type Description Default
io

file path or url to the XML

required
format

can be either "dexpi" or "aml" are the currenly supported XML source types.

required

dexpi(io) #

Reads a DEXPI file into the NeatSession and executes set of predefined transformations.

Parameters:

Name Type Description Default
io Any

file path or url to the DEXPI file

required
Example
neat.read.xml.dexpi("url_or_path_to_dexpi_file")

This method bundles several graph transformers which

  • attach values of generic attributes to nodes
  • create associations between nodes
  • remove unused generic attributes
  • remove associations between nodes that do not exist in the extracted graph
  • remove edges to nodes that do not exist in the extracted graph

aml(io) #

Reads an AML file into NeatSession and executes a set of predefined transformations.

Parameters:

Name Type Description Default
io Any

file path or url to the AML file

required
Example
neat.read.xml.aml("url_or_path_to_aml_file")

This method bundles several graph transformers which

  • attach values of attributes to nodes
  • remove unused attributes
  • remove edges to nodes that do not exist in the extracted graph

cognite.neat._session._read.RDFReadAPI #

Bases: BaseReadAPI

Reads an RDF source into NeatSession. Supported sources are "ontology" or "imf".

Parameters:

Name Type Description Default
io

file path or url to the RDF source

required

ontology(io) #

Reads an OWL ontology source into NeatSession.

Parameters:

Name Type Description Default
io Any

file path or url to the OWL file

required
Example
neat.read.rdf.ontology("url_or_path_to_owl_source")

imf(io) #

Reads IMF Types provided as SHACL shapes into NeatSession.

Parameters:

Name Type Description Default
io Any

file path or url to the IMF file

required
Example
neat.read.rdf.imf("url_or_path_to_imf_source")