Skip to main content
Answer

Trying to setup an asset hierarchy with Core Data Model, but am getting some errors

  • October 30, 2024
  • 5 replies
  • 145 views

Markus Pettersen
MVP

I am trying to setup an asset hierarchy using the Core Data Model as shown in the example:
https://docs.cognite.com/cdf/dm/dm_guides/dm_cdm_build_asset_hierarchy/

But I am getting some strange errors when I try to implement it. A normal container and view without a refernce to core data model works fines, but when trying to add cdm it fails. I am using the toolkit to deploy the data model.

In the “Data management” tab I get this error:


{
  "title": "",
  "message": "Cannot read properties of undefined (reading 'listPump')",
  "errors": []
}

In the “Query explorer” I get these errors:

{
"errors": [
{
"message": "The field type 'Cognite3DObject' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteSourceSystem' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAssetClass' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAssetType' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteFile' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteEquipment' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteActivity' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteTimeSeries' is not present when resolving type 'Pump' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type '_CogniteAssetDirectRelation' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteAsset' is not present when resolving type '_CogniteAssetDirectRelationConnection' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteFile' is not present when resolving type '_CogniteFileDirectRelation' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteFile' is not present when resolving type '_CogniteFileDirectRelationConnection' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteEquipment' is not present when resolving type '_CogniteEquipmentDirectRelation' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteEquipment' is not present when resolving type '_CogniteEquipmentDirectRelationConnection' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteActivity' is not present when resolving type '_CogniteActivityDirectRelation' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteActivity' is not present when resolving type '_CogniteActivityDirectRelationConnection' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteTimeSeries' is not present when resolving type '_CogniteTimeSeriesDirectRelation' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
},
{
"message": "The field type 'CogniteTimeSeries' is not present when resolving type '_CogniteTimeSeriesDirectRelationConnection' [@-1:-1]",
"locations": [],
"extensions": {
"classification": "ValidationError"
}
}
]
}

 

Best answer by Arild Eide

Hi @Markus Pettersen 

 

Thanks for posting!

The problem you have hit here is a known limitation. When the UI opens a Data Model there is validation stage that now fails, because your data model does not explicitly mention the types from the Core Data Model that CogniteAsset refers to.

There is a fix implemented, but it is not yet released. We will make sure to update this thread once it is.

 

Apologize for the inconvenience.

 

Arild Eide

 

 

5 replies

Arild  Eide
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • Answer
  • October 31, 2024

Hi @Markus Pettersen 

 

Thanks for posting!

The problem you have hit here is a known limitation. When the UI opens a Data Model there is validation stage that now fails, because your data model does not explicitly mention the types from the Core Data Model that CogniteAsset refers to.

There is a fix implemented, but it is not yet released. We will make sure to update this thread once it is.

 

Apologize for the inconvenience.

 

Arild Eide

 

 


Markus Pettersen
MVP

Thank you for the update, I’ll wait for the release of the fix.

 

Markus


Markus Pettersen
MVP

Any updates on when this fix will be deployed, we still get the same errors.


Arild  Eide
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • February 4, 2025

Hi ​@Markus Pettersen 

 

I was a bit too quick in my initial reply to your post. The fix referred to was to make the validation in the editor more lenient, so it would actually validate without explicitly referring the views that CogniteAsset depends on.

You would need to add the views to the Data Model, instead of adding only AssetTest and Pump you would need to also add the views mentioned in the error message,  (cdf_cdm, CogniteTimeSeries, v1)

So the yaml defining the data model would need to be extended, with each of the views, like this:

externalId: liftStationsPumps
name: Lift stations and pumps
space: asset-demo
version: v1
views:
- externalId: LiftStation
space: asset-demo
type: view
version: v1
- externalId: Pump
space: asset-demo
type: view
version: v1
- externalId: CogniteAsset
space: cdf_cdm
type: view
version: v1
- externalId: CogniteTimeSeries
space: cdf_cdm
type: view
version: v1

Markus Pettersen
MVP

I made a quick adjustment and added those views to the data model and it removed the validation errors related to CogniteAsset and CogniteTimeSeries, but I still get these errors for the views referenced by CogniteAsset and CogniteAsset:
"The field type 'CogniteSourceSystem' is not present when resolving type 'PiTimeSeries' [@-1:-1]"

I guess a temporary fix would be to add all views to the data model, but that is quite cumbersome in the long run and will make code harder to maintain over time. Adding the asset and time series view makes sense as I am using those, but adding all the views that those rely on is overkill from my perspective. 

Is there a timeline for when the fix you refer to will be deployed?

version: '{{PIAF_DM_VERSION}}'
space: '{{sp_id_prefix}}_{{PIAF_SPACE_ID}}'
externalId: '{{dm_id_prefix}}_{{PIAF_DM_EXTERNAL_ID}}'
name: {{PIAF_DM_NAME}}
views:
- version: '{{PIAF_DM_VERSION}}'
space: '{{sp_id_prefix}}_{{PIAF_SPACE_ID}}'
externalId: AssetTest
type: view
- version: '{{PIAF_DM_VERSION}}'
space: '{{sp_id_prefix}}_{{PIAF_SPACE_ID}}'
externalId: PiTimeSeries
type: view
- externalId: CogniteAsset
space: cdf_cdm
type: view
version: v1
- externalId: CogniteTimeSeries
space: cdf_cdm
type: view
version: v1

Also, as an additional note/request. The documentation on Cognite’s website should be updated to reflect this behaviour.
https://docs.cognite.com/cdf/dm/dm_guides/dm_cdm_build_asset_hierarchy