Skip to content

Session

cognite.neat._session.NeatSession #

Creates a new NeatSession.

This is the main entry point for using Neat. It provides access to the different APIs that can be used to read, write, and manipulate data and data models.

Parameters:

Name Type Description Default
client CogniteClient | None

The CogniteClient to use for reading and writing data.

None
storage Literal['memory', 'oxigraph']

The storage type to use for storing data and data models. Can be either "memory" or "oxigraph". In "memory" mode works well for small data sets and when only working with data models. It is works well for all notebook environments. In "oxigraph" mode, the data is stored in an Oxigraph database. This is more performant for larger data sets and when working with data. Note that this option requires additional dependencies to be installed and is not available in CDF Notebooks.

'memory'
verbose bool

Whether to print information about the operations being performed.

True
load_engine Literal['newest', 'cache', 'skip']

Whether to load the Neat Engine. Can be "newest", "cache", or "skip". "newest" will always check for the newest version of the engine. "cache" will load the engine if it has been downloaded before. "skip" will not load the engine.

'cache'
Example

Instantiate a NeatSession outside CDF jupyter notebook (needs instantiation of a CogniteClient)

from cognite.neat import get_cognite_client
from cognite.neat import NeatSession

client = get_cognite_client(env_file_name=".env")
neat = NeatSession(client)

Example

Instantiate a NeatSession inside a CDF jupyter notebook (use your user's CogniteClient directly)

from cognite.client import CogniteClient
from cognite.neat import NeatSession

client = CogniteClient()
neat = NeatSession(client)

version: str property #

Get the current version of neat.

Returns:

Type Description
str

The current version of neat used in the session.

Example
neat.version

verify() #

Verify the Data Model schema before the model can be written to CDF. If verification was unsuccessful, use .inspect.issues() to see what went wrong.

Example

Verify a data model after reading a source file and inferring the data model

# From an active NeatSession
...
neat.read.xml.dexpi("url_or_path_to_dexpi_file")
neat.infer()
neat.verify()

convert(target) #

Converts the last verified data model to the target type.

Parameters:

Name Type Description Default
target Literal['dms', 'information']

The target type to convert the data model to.

required
Example

Convert to DMS rules

neat.convert(target="dms")

Example

Convert to Information rules

neat.convert(target="information")

infer(model_id=('neat_space', 'NeatInferredDataModel', 'v1'), max_number_of_instance=100) #

Data model inference from instances.

Parameters:

Name Type Description Default
model_id DataModelId | tuple[str, str, str]

The ID of the inferred data model.

('neat_space', 'NeatInferredDataModel', 'v1')
max_number_of_instance int

The maximum number of instances to use for inference.

100
Example

Infer a data model after reading a source file

# From an active NeatSession
...
neat.read.xml.dexpi("url_or_path_to_dexpi_file")
neat.infer()