Skip to main content

Challenges with Data Model creation using CDF Toolkit Examples

  • January 15, 2025
  • 8 replies
  • 97 views

Forum|alt.badge.img+1

I tried to create data models using these examples in the repo using CDF Toolkit
https://github.com/cognitedata/toolkit/tree/main/tests/data/describe_data/data_models

However, I am not getting the expected result.

I got following result as data model
 

type Asset {

  areaId: Int

  categoryId: Int

  createdDate: Timestamp

  description: String

  documents: [File]

  isActive: Boolean

  isCriticalLine: Boolean

  metrics: [TimeSeries]

  parent: JSONObject

  sourceDb: String

  tag: String

  updatedDate: Timestamp

  children: [Asset]

}

 

type WorkOrder {

  actualHours: Int

  createdDate: Timestamp

  description: String

  dueDate: Timestamp

  durationHours: Int

  endTime: Timestamp

  isActive: Boolean

  isCancelled: Boolean

  isCompleted: Boolean

  isSafetyCritical: Boolean

  percentageProgress: Int

  plannedStart: Timestamp

  priorityDescription: String

  programNumber: String

  startTime: Timestamp

  status: String

  title: String

  workOrderNumber: String

  workPackageNumber: String

  workItems: [WorkItem]

  linkedAssets: [Asset]

}

 

type WorkItem {

  criticality: String

  description: String

  isCompleted: Boolean

  itemInfo: String

  itemName: String

  method: String

  title: String

  toBeDone: Boolean

  workOrder: JSONObject

  linkedAssets: [Asset]

}


Here, WorkItem​’s workOrder is JSONObject while I expected it to be WorkOrder.

Please check this screenshot as well

​​​​​​

8 replies

Jan Inge Bergseth
MVP

For workItem you probably want to pint back to your work order - but your type is: workOrder: JSONObject

Look at linked Assets, exepct that your item should not pint to a list just one WorkOrder


Forum|alt.badge.img+1
  • Author
  • Committed
  • 17 replies
  • January 16, 2025
Jan Inge Bergseth wrote:

For workItem you probably want to pint back to your work order - but your type is: workOrder: JSONObject

Look at linked Assets, exepct that your item should not pint to a list just one WorkOrder

yes it points to JSONObject instead of WorkOrder. This is the issue I am facing. I have created this data model using mentioned url’s example



 


Jan Inge Bergseth
MVP

If you look at the examples in toolkit as Activity pointing to Asset:

  assets:

    container:

      space: cdf_cdm

      externalId: CogniteActivity

      type: container

    containerPropertyIdentifier: assets

    name: Assets

    description: A list of assets the activity is related to.

    source:

      space: {{ schemaSpace }}

      externalId: {{ organization }}Asset

      version: v1

      type: view

 

==> we describe the source not type pointing to the Asset view and location for the view

you should try this in your code too….

 


Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 111 replies
  • January 20, 2025

@Khilesh Sahu A few additional notes.

Very creative to look into the test data for Toolkit to find examples. However, note that this is risky as the test data is typically for a specific purpose, which is not to serve as an example. In this case you have selected a data model in the response format. Data models consists of views which comes both in request (write) and response (read) format. Instead, recommend you to use `cdf modules init/add` and select the models package to find examples. 

As Jan Inge is saying, when a connection shows up as a JSONObject in the UI it is typically because the connection is implemented as a direct relation and the `source` property is not specified. This is used to specify what the direct relation is pointing to. For more information see the API specification for the creation of views. (The YAML files in Toolkit is matching the API spec for views)

 


Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 111 replies
  • January 20, 2025

@Khilesh Sahu One more question. What is it you are trying to achieve? Doing data modeling directly on configuration files is a very challenging task that is very error prone, I have been burned a lot when doing this. We are working at improving data modeling experience at Cognite. I am happy to take a call if you are interested. Let me know.


Forum|alt.badge.img+1
  • Author
  • Committed
  • 17 replies
  • January 20, 2025
Anders Albert wrote:

@Khilesh Sahu One more question. What is it you are trying to achieve? Doing data modeling directly on configuration files is a very challenging task that is very error prone, I have been burned a lot when doing this. We are working at improving data modeling experience at Cognite. I am happy to take a call if you are interested. Let me know.

that would be great if we can discuss over call. Can you please setup a call


Thanks ​@Khilesh Sahu for opening the thread here. Please update the thread once we try out the suggestions.

Hello ​@Anders Albert ,
We have created a Data Model. And now this data model needs to be versioned controlled and distributed to multiple tenants. Model is kind of universal and hence it is same for all multiple tenants.

So what we are trying to do is converting this model to yamls, committing it to repos and then using cdf toolkit to deploy this to multiple tenant environments. We want to automate it via pipelines.

Thanks
Neeraj B


Forum|alt.badge.img+1
  • Author
  • Committed
  • 17 replies
  • January 21, 2025

@Anders Albert and ​@Jan Inge Bergseth - I have tried similar approach as you suggested with our data model. Later, I tried with the mentioned example. 

From CDF Example in WorkItem.view.yaml
 

 

From our sample entiry.view.yaml

 


We got same issue in both case.


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings