Skip to main content
Question

Resource Creation YAML Configurations


Forum|alt.badge.img+1

Is there a recommended approach for using YAML configurations to automate the creation of spaces, containers, views, and data models in Cognite Data Fusion? How can we incorporate customizable parameters (e.g., space names, descriptions, and container properties) in the YAML files to make the process more flexible?

Example YAML configuration for containers:

containers:
  - name: "example_container_1"
    description: "First sample container"
    external_id: "example_container_1_id"
    properties:
      name:
        type: "Text"
        nullable: false
      parent:
        type: "DirectRelation"
        nullable: true
      isValid:
        type: "Boolean"
        nullable: true
    indexes:
      - index_name: "entity_name"
        type: "BTree"
        properties: ["name"]

  - name: "example_container_2"
    description: "Second sample container"
    external_id: "example_container_2_id"
    properties:
      identifier:
        type: "Text"
        nullable: false
    indexes:
      - index_name: "identifier_index"
        type: "BTree"
        properties: ["identifier"]

Each container is defined with the following:

  • Properties: Each property has a defined type (e.g., "Text") and a nullable flag, ensuring flexibility in field definitions.
  • Indexes: Each container includes index definitions with a specific index type (e.g., "BTree") and the properties to be indexed.

Though this example only focuses on containers, a similar structure is required for other resources like spaces, views, and data models. How can these configurations be used with the Python SDK?

4 replies

Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 108 replies
  • January 2, 2025

Have you looked into Cognite Toolkit? Documentation

That is a CLI built on top of the Python-SDK using the YAML format to automate deployment of all CDF resources. 

 

If you want to use the python SDK directly, all data classes, for example, `ContainerApply` has a `.load` method that takes a string which can be a `YAML-string`.


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

Have you looked into Cognite Toolkit? Documentation

That is a CLI built on top of the Python-SDK using the YAML format to automate deployment of all CDF resources. 

 

If you want to use the python SDK directly, all data classes, for example, `ContainerApply` has a `.load` method that takes a string which can be a `YAML-string`.


I was trying to do using python SDK. Though my topic is using python SDK now I would like to change my approach and create using Cognite Toolkit. However, I am not able to find enough information to create space, view, container and data model using cognite tool kit.

Please let me know if you have any references
 


Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 108 replies
  • January 13, 2025

The simplest is likely to run the command `cdf modules init` and select the `QuickStart` package. That will give you an example setup which include data sources as well as a data model containing space, container, and data model. 

For further information, I strongly recommend reading the documentation, in particular the YAML reference.


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

The simplest is likely to run the command `cdf modules init` and select the `QuickStart` package. That will give you an example setup which include data sources as well as a data model containing space, container, and data model. 

For further information, I strongly recommend reading the documentation, in particular the YAML reference.

Thank you. I used your suggested approach. However, this question was to find ways to use yaml while using python sdk.

I have tried CDF toolkit and facing some other issue. Here is the link if you can help 

 


Reply


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