Data Modeling Introduction¶
Prerequisite:
- Installed Neat, see Installation
- Launched a notebook environment.
- Familiar with the
NeatSession
object, see introduction
In this tutorial, we will publish an example data model to CDF.
Creating NeatSession¶
We will start by instansiating a NeatSession
. The below steps assumes you are in a CDF Notebook
%pip install cognite-neat
from cognite.client import CogniteClient
from cognite.neat import NeatSession
client = CogniteClient()
neat = NeatSession(client)
Reading Data Model¶
We will read an example model that comes with neat.
neat
neat.read.excel.examples.pump_example
Success: Read UnverifiedDMSModel
neat
Unverified Data Model
type | Physical Data Model |
---|---|
intended for | DMS Architect |
name | Neat Hello World |
space | neat_playground |
external_id | NeatHelloWorld |
version | v1 |
views | 33 |
containers | 3 |
properties | 14 |
When we read a model in neat, it will always be unverified. This is to enable use to do modifications to the model before we verify it.
In this case, we know that the example is ready to be verified
neat.verify()
Success: UnverifiedDMSModel → VerifiedDMSModel
neat
Verified Data Model
aspect | physical |
---|---|
intended for | DMS Architect |
name | Neat Hello World |
space | neat_playground |
external_id | NeatHelloWorld |
version | v1 |
views | 33 |
containers | 3 |
properties | 14 |
Inspect Model¶
We can visualize the data model with the show command
neat.show.data_model()
http_purl.org_cognite_neat_data-model_verified_physical_neat_playground_NeatHelloWorld_v1.html
Deploy to CDF¶
We want to deploy this model to CDF.
First, instead of using the default data model ID, we set our own.
neat.set.data_model_id(("my_space", "HelloWorldModel", "v1"))
Success: VerifiedDMSModel → VerifiedDMSModel
Then we deploy the data model to CDF.
neat.to.cdf.data_model()
You can inspect the details with the .inspect.outcome.data_model(...) method.
name | unchanged | |
---|---|---|
0 | spaces | 1 |
1 | containers | 3 |
2 | views | 3 |
3 | data_models | 1 |
4 | nodes | 0 |
Note that model is an extension of CogniteCore
and thus includes CogniteCore
types as well as the Pump
, Facility
and Documentation
Model to Excel¶
Finally, we can inspect the data model in Excel by using the to.excel
command.
neat.to.excel("my_first_model.xlsx")