We have a DM with many direct relations. A processing is directly liked to an asset with the name of the property being ‘equipment’.

We use the Cognite data modeling API to generate models and use pygen to run programs on it. I have noticed something strange while using pygen.
Properties which are direct relations to other types sometimes are shown as text and other times are shown as NodeId objects.

In the former case, while observing them in the Data Model view, the properties appear empty. Actually, they contain the external_id of the instance as a string which can be seen while querying with pygen.

Sometimes, instances spontaneously transition from one type to the ohter (NodeId → string or vice versa). In my pygen programs thus, I have to use the following function to keep the program running.
from cognite.client.data_classes.data_modeling import NodeId
#Sometimes a text value is returned. Some other times, a NodeId is returned.
get_external_id = lambda x: x.external_id if isinstance(x, NodeId) else xI don’t really understand what is going on. Does anyone have a solution?
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support
