data_models/ directory hosts
the configuration files for spaces, containers, views, data models, and nodes. While the classic/ directory hosts the
configuration files for labels, assets, and sequences.
When you deploy, the Cognite Toolkit uses the Cognite API to implement the YAML configurations in the CDF project.
In general, the format of the YAML files matches the API specification for the resource types. We recommend
that you use the externalId of the resources as (part of) the name of the YAML file. This is to enable using the same resource
configuration across multiple CDF projects, for example, a development, staging and production project. Use number prefixes
(1.<filename.suffix>) to control the order of deployment within each resource type.
3D Models
Resource directory: 3dmodels/ Requires Cognite Toolkit v0.3.0 or later API documentation: 3D models 3D model configurations are stored in the module’s 3dmodels/ directory. You can have one or more 3D models in a single YAML file. The filename must end with3DModel, for example, my_3d_model.3DModel.yaml.
Example 3D model configuration:
my_3d_model.3DModel.yaml
The 3D model API uses an internal ID for the
dataSetId, while the YAML configuration files reference the external ID; dataSetExternalId.
The Cognite Toolkit resolves the external ID to the internal ID before sending the request to the Cognite API.Agents
Resource directory: agents/ Requires Cognite Toolkit v0.5.85 or later and alpha flagagents enabled
API documentation: Agents
Agent configurations are stored in the module’s agents/ directory. You can have one or more agents in a single YAML file.
It’s recommended to have one agent per file. The filename must end with Agent, for example, my_agent.Agent.yaml.
Example agent configuration:
my_agent.Agent.yaml
Available tools
This section lists the available tools that you can use in the agent configuration. Note that this is a service in rapid development, and there may be more tools available than what is listed here. When you use a tool that the Cognite Toolkit doesn’t recognize, you will get a warning when running thecdf build command. However, you
can still deploy the tool to CDF as long as the CDF API supports the tool.
Ask document
Assets
Resource directory: classic/ Requires Cognite Toolkit v0.3.0 or later API documentation: Assets Asset configurations are stored in the module’s classic/ directory. You can have one or more asset in a single YAML file. The filename must end withAsset, for example, my_asset.Asset.yaml.
Example Asset configuration:
my_root.Asset.yaml
The asset API uses an internal ID for the data set, while the YAML configuration files reference the external ID;
dataSetExternalId. The Cognite Toolkit resolves the external ID to the internal ID before sending the request to the Cognite API.my_asset.Asset.yaml
The CogniteToolkit doesn’t support the field
parentId in the asset configuration. Instead, use parentExternalId.
The parentId field is an internal ID that is not consistent across environments.Table formats
In addition toyaml, the Cognite Toolkit supports csv and parquet formats for asset configurations. As with the yaml format, the filename must end with Asset, for example, my_asset.Asset.csv.
my_root.Asset.csv
yaml configuration. The exception is the metadata field,
which is a dictionary in the yaml configuration, but a string in the csv configuration. This is solved by using the
notation metadata.origin column in the csv configuration.
Groups
Resource directory: auth/ API documentation: Groups The group configuration files are stored in the module’s auth/ directory. You can have one or more groups in a single YAML file. The filename must end withGroup, for example, my_group.Group.yaml.
The name field is used as a unique identifier for the group. If you change the name of the group manually in CDF,
it will be treated as a different group and will be ignored by the Cognite Toolkit.
Example group configuration:
my_group.Group.yaml
metadata:origin property to indicate that the group is created by the Cognite Toolkit
You can specify each ACL capability in CDF as in the projectsAcl example above. Scoping to dataset, space, RAW table,
current user, or pipeline is also supported (see ACL scoping).
Groups and group deletion
If you delete groups with thecdf clean or cdf deploy --drop command, the Cognite Toolkit skips the groups that the running
user or service account is a member of. This prevents the cleaning operation from removing access rights from
the running user and potentially locking the user out from further operation.
ACL scoping
Dataset scope
Use to restrict access to data in a specific data set.<fragment>
The groups API uses an internal ID for the data set, while the YAML configuration files reference the external ID. The Cognite Toolkit resolves the external ID to the internal ID before sending the request to the Cognite API.
Space scope
Use to restrict access to data in a data model space.<fragment>
Table scope
Use to restrict access to a database.<fragment>
<fragment>
Current user-scope
Use to restrict actions to the groups the user is a member of.<fragment>
Security categories
Requires Cognite Toolkit v0.2.0 or later Resource directory: auth/ API documentation: Security categories The security categories are stored in the module’s auth/ directory. You can have one or more security categories in a single YAML file. We recommend that you start security category names withsc_ and use _ to separate words. The file name is not significant,
but we recommend that you name it after the security categories it creates.
project_categories.SecurityCategory.yaml
Data models
Resource directory: data_models/ API documentation: Data modeling The data model configurations are stored in the module’s data_models directory. A data model consists of a set of data modeling entities: one or more spaces, containers, views, and data models. Each entity has its own file with a suffix to indicate the entity type: my.space.yaml, my.container.yaml, my.view.yaml, my.datamodel.yaml. You can also use the Cognite Toolkit to create nodes to keep configuration for applications (for instance, InField) and to create node types that are part of the data model. Define nodes in files with the .node.yaml suffix. The Cognite Toolkit applies configurations in the order of dependencies between the entity types: first spaces, next containers, then views, and finally data models. If there are dependencies between the entities of the same type, you can use prefix numbers in the filename to have the Cognite Toolkit apply the files in the correct order. The Cognite Toolkit supports using subdirectories to organize the files, for example:Spaces
API documentation: Spaces Spaces are the top-level entities and is the home of containers, views, and data models. You can create a space with a .space.yaml file in the data_models/ directory.sp_cognite_app_data.space.yaml
Containers
API documentation: Containers Containers are the home of properties and data. You can create a container with a .container.yaml file in the data_models/ directory. You can also create indexes and constraints according to the API specification.MyActivity.container.yaml
id, title, description, and asset.
Note that sp_activity_data requires its own activity_data.space.yaml file in the data_models/ directory.
Views
API documentation: Views Use views to ingest, query, and structure the data into meaningful entities in your data model. You can create a view with a .view.yaml file in the data_models/ directory.MyActivity.view.yaml
id, title, description, and asset.
The asset property references the MyAsset view in the sp_activity_model space.
The view references the properties from the container MyActivity in the sp_activity_data space. The view
exists in a space called sp_activity_model, while the container exists in the sp_activity_data space.
Data models
API documentation: Data models Use data models to structure the data into knowledge graphs with relationships between views using edges. From an implementation perspective, a data model is a collection of views. You can create a data model with a .datamodel.yaml file in the data_models/ directory.ActivityDataModel.datamodel.yaml
MyActivity and MyTasks.
The data model exists in a space called sp_activity_model together with the views.
Nodes
API documentation: Instances Use nodes to populate a data model. You can create nodes with a .node.yaml file in the data_models/ directory.myapp_config.node.yaml
MY_APP_Config with version ‘1’ in the sp_config space. The instance has data that is read by MY_APP and used to configure the application.
The node instance is created in the sp_config space with myapp_config as the externalId. The example also
configures a root location for the application and specifies how to find the application’s data: in the sp_activity_data
space with version 1 of the MyActivityview.
Another example is node types. They are part of a data model schema (the description of how data is structured),
and creates a type of node that can be created in the data model. This is an example of a YAML file
with multiple node types defined.
myapp_config.node.yaml
Edges
Requires Cognite Toolkit v0.4.0 or later API documentation: Instances Use edges to define connections between nodes in a data model. You can create edges with a .edge.yaml file in the data_models/ directory. You can have one or more edges in a single YAML file. The filename must end withEdge, for example, my_edge.Edge.yaml.
my_edge.Edge.yaml
Data sets
Resource directory: data_sets/ API documentation: Data sets You can not delete data sets in CDF, but you can use the Cognite Toolkit to create new data sets or update existing ones. You can create multiple data sets in the same YAML file. The filename must end withDataSet, for example, my_data_set.DataSet.yaml.
The data sets API uses an internal ID for the data set, while the YAML configuration files reference the
external ID;
dataSetExternalId. The Cognite Toolkit resolves the external ID to the internal ID before
sending the request to the Cognite API. For an example, see files.data_sets.DataSet.yaml
Events
Requires Cognite Toolkit v0.4.0 or later Resource directory: classic/ API documentation: Events Events can be found in the module’sclassic/ directory. You can define one or more events in a single YAML file.
The filename must end with Event, for example, my_event.Event.yaml.
The Cognite Toolkit ensures that dependent resources are created before the events. For example, if you reference an
asset or a data set in an event, the Cognite Toolkit creates the asset or data set before creating the event.
Example event definition:
my_event.Event.yaml
The data set is referenced by the
dataSetExternalId and assetExternalIds. The Cognite Toolkit automatically
resolves the external ID to the internal ID of the data set and assets before sending the request to CDF.InfieldV1
Requires Cognite Toolkit v0.5.10 or later and alpha flaginfield enabled
Resource directory: cdf_applications/
InfieldV1 can be found in the modules cdf_applications/ directory. You can define one or more InfieldV1 configurations in a single YAML file.
The filename must end with InfieldV1, for example, my_infield_app.InfieldV1.yaml.
The Cognite Toolkit ensures that dependent resources are created before the InfieldV1 applications. For example, if you
reference a space, data sets, assets, or groups in the InfieldV1 configuration, the Cognite Toolkit creates it before creating the InfieldV1 configuration.
Example InfieldV1 configuration:
my_infield_app.InfieldV1.yaml
The data set is referenced by the
dataSetExternalId. The Cognite Toolkit automatically
resolves the external ID to the internal ID of the data set.Labels
Requires Cognite Toolkit v0.3.0 or later Resource directory: classic/ (labels/ inv0.2.0)
API documentation: Labels
Labels can be found in the module’s classic/ directory. You can define one or more labels in a single YAML file.
The filename must end with Label, for example, my_equipment.Label.yaml.
The Cognite Toolkit creates labels before files and other resources that reference them.
Example label definition:
my_equipment.Label.yaml
The Cognite API doesn’t support updating labels. When you update a label with the Cognite Toolkit, it deletes the previous label and creates a new one.
Extraction pipelines
Resource directory: extraction_pipelines/ API documentation: Extraction pipelines API documentation Configuration: Extraction pipeline config Documentation: Extraction pipeline documentation Extractor pipelines and configurations are stored in the module’s extraction_pipelines/ directory. You can define one or more extraction pipelines in a single YAML file. It is, however, most common to have one pipeline per file. In addition, one or more the extraction pipeline configurations must be stored in a separate file. Extraction pipeline configurations are detected by the.config suffix, while extraction pipeline filenames end with ExtractionPipeline.
ep_src_asset_hamburg_sap.ExtractionPipeline.yaml
ep_src_asset_hamburg_sap and the name src:asset:hamburg:sap.
The configuration allows an extractor installed inside a closed network to connect to CDF and download the extractor’s configuration file.
The Cognite Toolkit expects the configuration file be in the same directory and have the same name as the extraction
pipeline configuration file, but with the suffix .config.yaml. The configuration file is not strictly required,
but the Cognite Toolkit warns if the file is missing during the deployment process.
The extraction pipeline can be connected to a data set and to the RAW tables that the extractor will write to.
This is an example configuration file for the extraction pipeline above:
ep_src_asset_hamburg_sap.config.yaml
The Cognite Toolkit expects the
config property to be valid YAML and will not validate the content of the config property
beyond the syntax validation. The extractor that is configured to download the configuration file validates the content of the config property.Files
Resource directory files/ API documentation: FilesCogniteFile Requires Cognite Toolkit v0.3.0 or later
Files can be found in the module’s files/ directory. You can define the metadata for one or more files using either a single YAML file or multiple YAML files. Mark the files as CogniteFile or FileMetadata by using the suffix .CogniteFile.yaml or .FileMetadata.yaml.
Files with a suffix other than .yaml, such as .txt, or YAML files that do not end with FileMetadata or CogniteFile, are expected to be content of a configuration file.
To upload a file with the metadata, the name in the YAML file must match the filename of the file that should be uploaded.
You can also use the template for uploading multiple files
to upload multiple files without specifying the metadata for each file.
my_file.pdf and my_other_file.pdf:
my_files.FileMetadata.yaml
my_file.pdf:
my_file.FileMetadata.yaml
The data set is referenced by the
dataSetExternalId. The Cognite Toolkit automatically
resolves the external ID to the internal ID of the data set.CogniteFile metadata configuration for a single file, my_file.pdf:
my_file.CogniteFile.yaml
CogniteFile metadata configuration for multiple files, my_file.pdf and my_other_file.pdf:
my_files.CogniteFile.yaml
Uploading multiple files
To upload multiple files without specifying the metadata configuration for each file individually, use this template format for theFileMetadata configuration file:
files.FileMetadata.yaml
CogniteFile configuration file:
files.CogniteFile.yaml
- It is a YAML file given in
list/arrayformat. - There is a single entry in the list.
- The
externalIdcontains the$FILENAMEvariable.
externalId and name properties.
The $FILENAME variable will be replaced with the filename of the file being uploaded.
Functions
Resource directory functions/ API documentation: Functions The function configuration files are stored in the module’s functions/ directory. You can define one or more functions in a single or multiple YAML file(s). The Cognite Toolkit creates the functions in the order they are defined in the file. Functions files must end withFunction, for example, my_function.Function.yaml.
The functions YAML files must be located in the functions/ directory and not in subdirectories. This allows you to
store YAML files that are not configuration files in subdirectories as part of the function’s code.
externalId of the function.
Example function configuration:
Folder structure, including a function schedule:
my_functions.Function.yaml
functionPath is the path to the handler.py in the function code directory. In this case, handler.py
is expected to be in the fn_example_repeater/src/ directory.
Note that dataSetExternalId is not part of the function API. The Cognite Toolkit uploads the function code
to a FileMetadata and references the uploaded file when creating a Cognite Function. If the dataSetExternalId
is set, the Cognite Toolkit uses it on the FileMetadata upload. If not set, the code file will be uploaded
without a data set.
Alternatively, you can define space to store the function code as a CogniteFile instead of a FileMetadata:
my_dm_function_code.Function.yaml
v0.7.0 of the Cognite Toolkit this requires the alpha flag function-cognite-file to be enabled.
Function schedules
Resource directory: functions/ API documentation: Schedules Schedules for functions are also stored in the module’s functions/ directory. The Cognite Toolkit expects the YAML filename to end withSchedule, for example, run_calculation_x.Schedule.yaml. You can specify more than
one schedule in a single file.
To ensure that the function exists before the schedule is created, schedules are deployed after functions
Schedules don’t have externalIds, and the Cognite Toolkit identifies the schedule by a combination of the
functionExternalId and the name. Consequently, you can’t deploy two schedules for a function with the
exact same name, and with two different sets of data.
daily.Schedule.yaml
functionExternalId must match an existing function or a function deployed by the tool.
For schedules, the authentication property is optional but recommended. You can use it to specify
credentials for the schedule that are different from the default credentials used by the Cognite Toolkit.
We recommend using credentials with the minimum required access rights to run the function . If
you don’t specify the authentication property, the Cognite Toolkit uses its own credentials to run the function.
This only works if the config.[env].yaml has set validation-type: dev. If it is set to prod or anything else,
the Cognite Toolkit will raise an error when trying to deploy the schedule without the authentication property.
Hosted extractors
Requires Cognite Toolkit v0.3.0 or later Resource directory: hosted_extractors/ Hosted extractor documentation: Hosted extractors The hosted extractors are stored in the module’shosted_extractors/ directory. A hosted extractor has four types of
resources: Source, Destination, Job, and Mapping. Each resource type has its suffix in the filename, for example,
my_kafka.Source.yaml.
When creating, updating, and deleting hosted extractors, the Cognite Toolkit applies changes in the correct order
based on the dependencies between the source, destination, job, and mapping versions.
Source
API documentation: Hosted extractor source Below is an example of a source configuration file.my_mqtt.Source.yaml
Destination
API documentation: Hosted extractor destination Below is an example of a destination configuration file.my_cdf.Destination.yaml
The Cognite Toolkit automatically resolves the external ID to the internal ID of the data set.
Job
API documentation: Hosted extractor job Below is an example of a job configuration file.my_mqtt_to_cdf.Job.yaml
Mapping
API documentation: Hosted extractor mapping Below is an example of a mapping configuration file.my_mqtt_to_cdf.Mapping.yaml
Locations
Requires Cognite Toolkit v0.3.0 or later Resource directory: locations/ The location filters are stored in the module’s locations/ directory. You can have one or multiple locations in a single YAML file. The location YAML file name must end withLocationFilter, for example, my.LocationFilter.yaml.
Location filters work with data modeling or with asset-centric resource types. The below example shows a
location filter for data modeling.
example.LocationFilter.yaml
shared_filter.LocationFilter.yaml
dataSetExternalId, assetSubtreeId, or externalIdPrefix in the filter. The example
below illustrates all the options.
You can also set filters for specific resource types, such as assets, events, files,
timeseries, and sequences:
shared_filter.LocationFilter.yaml
The location filter API uses an internal ID for the
parentId and dataSetId, while the YAML configuration files reference the external ID; parentExternalid and dataSetExternalId.
The Cognite Toolkit resolves the external ID to the internal ID before sending the request to the Cognite API.RAW
Resource directory: raw/ API documentation: RAW The RAW configuration files are stored in the module’s raw/ directory. You can have one or more RAW configurations in a single YAML file. For example, multiple tables can be defined in a single file. RAW table configuration filenames must end withTable, for example, my_table.Table.yaml. Database configuration filenames must end with Database, for example, my_database.Database.yaml.
raw_tables.Table.yaml
sap_workorder_mdi2_sap.Table.yaml
Uploading data to RAW tables
You can upload data to RAW tables. You need to create one YAML file per table you want to upload. The data file can either be a .csv or .parquet file and must be named the same name as the YAML file. This example configuration creates a RAW database calledasset_hamburg_sap with a table called assets and
populates it with data from the asset_hamburg_sap.csv file.
asset_hamburg_sap.Table.yaml
asset_hamburg_sap.Table.csv
Use case: Uploading data to RAW tables
The Cognite Toolkit governs resource configurations, typically metadata rather than data. For example, a sensor’s name, location, type, and the asset it’s attached to are metadata, while the actual sensor readings are data. Metadata is typically available from a source system. You can, for example, use an extraction pipeline to extract and ingest the metadata to CDF. If the metadata isn’t available for extraction from a source system, a potential option is to store the metadata as .csv files and have them version-controlled, for example, in a Git repository. Next, you can use the Cognite Toolkit to deploy the metadata to RAW tables in CDF. Then, you can use Transformations to write the metadata to the correct destination resources. This way, you can track changes to the metadata and use the Git repository as the single source of truth for the metadata.Relationships
Requires Cognite Toolkit v0.4.0 or later Resource directory: classic/ API documentation: Relationships Relationships can be found in the module’sclassic/ directory. You can define one or more relationships in a single YAML file. The filename must end with Relationship, for example, my_relationship.Relationship.yaml.
The Cognite Toolkit ensures that dependent resources are created before the relationships. For example, if you reference an asset or a data set in a relationship, the Cognite Toolkit creates the asset or data set before creating the relationship.
Example relationship definition:
my_relationship.Relationship.yaml
The data set is referenced by the
dataSetExternalId. The Cognite Toolkit automatically
resolves the external ID to the internal ID of the data set.Resource view mapping
Requires Cognite Toolkit v0.6.73 or later and the alpha flagmigration enabled
Resource directory: migration/
ResourceViewMapping can be found in the modules migration/ directory. You can define one or more ResourceViewMapping in a single YAML file.
The filename must end with ResourceViewMapping, for example, my_asset_mapping.ResourceViewMapping.yaml.
Example ResourceViewMapping:
my_asset_mapping.ResourceViewMapping.yaml
Robotics
Requires Cognite Toolkit v0.3.0 or later Resource directory: robotics/ API documentation: The Robotics API is not yet publicly available. The Robotics configuration files are stored in the module’s robotics/ directory. There are multiple types of Robotics resources:RobotCapability, Map, Location, Frame, DataPostProcessing. You can have one or more resources
in a single YAML file, but all resources in the file must be of the same type. Each resource type has its suffix in the
filename, for example, my_robot_capability.RobotCapability.yaml.
Robot capabilities
Below is an example of a RobotCapability configuration file.my_robot_capability.RobotCapability.yaml
- Required properties:
name,externalIdandmethod. - Optional properties:
description,inputSchema,dataHandlingSchema. inputSchemaanddataHandlingSchemaare objects and are not verified by the Cognite Toolkit, they are passed as is to the Robotics API.
Map
Below is an example of a Map configuration file.my_map.Map.yaml
- Required properties:
name,externalId, andmapType. - Optional properties:
description,data,locationExternalId,scale. MapTypehas allowed valuesWAYPOINTMAP,THREEDMODEL,TWODMAP, andPOINTCLOUDdatais an object that is not verified by the Cognite Toolkit, it is passed as is to the Robotics API.
Location
Below is an example of a Location configuration file.my_location.Location.yaml
- Required properties:
nameandexternalId. - Optional properties:
description.
Frame
Below is an example of a Frame configuration file.my_frame.Frame.yaml
- Required properties:
nameandexternalId. - Optional properties:
transform. - In
transform,- Required properties:
parentFrameExternalId,translation,orientation. - Optional properties: None.
- For
translationandorientation, all properties are required.
- Required properties:
Data post-processing
Below is an example of a DataPostProcessing configuration file.my_data_post_processing.DataPostProcessing.yaml
- Required properties:
name,externalId, andmethod. - Optional properties:
description,inputSchema. inputSchemais an object and is not verified by the Cognite Toolkit, it is passed as is to the Robotics API.
Search configuration
Requires Cognite Toolkit v0.6.26 or later and alpha flagsearch-config enabled
Resource directory: cdf_applications/
SearchConfig can be found in the modules cdf_applications/ directory. You can define search configurations for a view in a single YAML file.
The filename must end with SearchConfig, for example, MyActivity_view.SearchConfig.yaml.
The Cognite Toolkit accepts a single SearchConfig YAML for a view where you can define the configurations that you want to see in your search applications.
Example SearchConfig configuration:
MyActivity_view.SearchConfig.yaml
Only one YAML resource can be created for a view. If multiple resources are created, the toolkit will skip other resources with warning.It is prefered to list down all the properties under
columnsLayout, filterLayout and propertiesLayout.
Mention the properties, filters, and columns in the order you want them to appear in the search application.Sequences
Requires Cognite Toolkit v0.3.0 or later Sequence rows requires Cognite Toolkit v0.4.0 or later Resource directory: classic/ API documentation: Sequences API documentation Rows: Sequence Rows Sequences can be found in the module’sclassic/ directory. You can define one or more sequences in a single YAML file.
The filename must end with Sequence, for example, my_sequence.Sequence.yaml.
Below is an example of a sequence configuration file.
my_sequence.Sequence.yaml
The data set is referenced by the
dataSetExternalId. The Cognite Toolkit automatically resolves the external ID to the internal ID of the data set.Sequence rows
Sequence rows are a separate resource type from sequences. The sequence row configuration files are expected in the classic/ directory and must have the suffixSequenceRow, for example, my_sequence.SequenceRow.yaml.
Below is an example of a sequence row configuration file.
powercurve.SequenceRow.yaml
externalId is the same as the sequence’s externalId. The columns property lists the columns in the sequence.
The rows property contains the data for the sequence. Each row has a rowNumber and a values property. The values
property is an array of values for each column in the sequence.
Streamlit applications
Requires Cognite Toolkit v0.4.0 or later Resource directory: streamlit/ API documentation: This uses the files API: Files Streamlit applications are stored in the module’s streamlit/ directory. You can define one or more Streamlit applications in a single YAML file. The filename must end withStreamlit, for example, myapp.Streamlit.yaml.
Below is an example of a Streamlit application configuration file.
myapp.Streamlit.yaml
The data set is referenced by the
dataSetExternalId. The Cognite Toolkit automatically resolves the external ID to the internal ID of the data set.externalId of the application must be unique within the project and must match the name of a directory
where the .py files are located, including the entrypoint file. In addition, there must be a requirements.txt
file in the same directory. For the above example, the directory structure would look like this:
Streams
Requires Cognite Toolkit v0.6.105 or later and alpha flagstreams enabled
Resource directory: streams/
API documentation: Streams
Streams are stored in the modules’ streams/ directory. The filename must end with Streams, for example, my_stream.Streams.yaml.
The number of active streams has limits that depend on the template name. For more information about these limits, see the API documentation.
Example stream configuration:
my_stream.Streams.yaml
Currently, three template types are available for the
name field: ImmutableTestStream, BasicArchive, and BasicLiveData.Transformations
Resource directory: transformations/ Transformation Notifications requires Cognite Toolkit v0.3.0 or later API documentation Transformations: Transformations API documentation Schedules: Schedule API documentation Notifications: Notifications The transformation configuration files are stored in the module’s transformations/ directory. You can have one or more transformations in a single YAML file, but typically you have one transformation per file. The filename must end withTransformation, for example, my_transformation.Transformation.yaml.
Each transformation can have a corresponding .sql file with the accompanying SQL code. The .sql file should
have the same filename as the YAML file that defines the transformation (without the number prefix) or
use the externalId of the transformation as the filename.
The transformation schedule is a separate resource type, tied to the transformation by external_id.
The Cognite Toolkit detects the transformation schedule YAML file by the schedule suffix in the filename,
for example, my_transformation.schedule.yaml. The transformation notification YAML file is detected by the
Notification suffix in the filename, for example, my_transformation.Notification.yaml. All other YAML files are
considered transformation configurations.
Transformation configuration
Example transformation configuration:tr_asset_oid_workmate_asset_hierarchy.Transformation.yaml
tr_asset_oid_workmate_asset_hierarchy.Transformation.sql
authentication section
to specify the credentials. See below for more information on how to configure the credentials.
You can specify the SQL inline in the transformation YAML file, using the query property (str), but we recommend
that you use a separate .sql file for readability.
In the above transformation, the transformation re-uses the globally defined credentials for the Cognite Toolkit.
For production projects, we recommend that you use a service account with the minimum required access
rights instead.
Transformation credentials
You can specify the credentials in theauthentication section of the transformation YAML file. The most
common way is as follows:
<fragment>
clientId and clientSecret are used to authenticate against a service principal that is connected to a
Cognite group with the capabilities (authorization) needed to run the transformation. The service principal must be
authorized to read from the source table and write to the transformation destination, for example, a data model.
You can also specify two sets of credentials, one for reading from the source and one for writing to the destination.
<fragment>
read credentials are used to read from the source table, and the write credentials are used to
write to the destination.
If you need to authenticate against a different CDF project, you can specify full credentials:
<fragment>
<fragment>
Transformation schedule
The transformationschedule is optional. If you do not specify a schedule, the transformation will be created,
but not scheduled. You can then schedule it manually in the CDF UI or using the Cognite API.
Schedule is a separate API endpoint in CDF.
Example transformation schedule configuration:
tr_asset_oid_workmate_asset_hierarchy.schedule.yaml
Transformation notifications
The transformationnotification is optional. Below is an example of a transformation notification configuration file.
tr_notifications.Notification.yaml
Time series
Resource directory: timeseries/ API documentation: Time-series TimeSeries can be found in the module’stimeseries/ directory. You can define the metadata of one or more time series
in a single or multiple YAML file(s). The filename must end with TimeSeries, for example, my_timeseries.TimeSeries.yaml.
Typically, you create time series when ingesting data into CDF by configuring the
data pipelines with the corresponding data sets, databases, groups, and so on.
timeseries.TimeSeries.yaml
ds_timeseries_hamburg data set with the external IDs pi_160696 and pi_160702.
Uploading datapoints to time series
You can upload datapoints to times series using the Cognite Toolkit. The datapoints are stored in the module’s timeseries/ directory. Datapoints are stored incsv or parquet files. There is no requirements for the
filename of the datapoints file.
Typically, you create time series when ingesting data into CDF by configuring the
data pipelines with the corresponding data sets, databases, groups, and so on.
datapoints.csv
Timeseries subscriptions
Requires Cognite Toolkit v0.2.0 or later Resource directory: timeseries/ API documentation: Timeseries subscriptions Timeseries subscriptions are stored in the module’s timeseries/ directory. We recommend to have a separate YAML file for each subscription. Use theDatapointSubscription suffix in the filename,
for example my_subscription.DatapointSubscription.yaml.
The Cognite Toolkit create the timeseries subscription after the timeseries.
Example timeseries subscription configuration:
my_subscription.DatapointSubscription.yaml
Workflows
Requires Cognite Toolkit v0.2.0 or later WorkflowTrigger requires Cognite Toolkit v0.3.0 or later Resource directory: workflows/ API documentation: Workflows The workflows are stored in the module’sworkflows/ directory. A workflow has three types of resources: Workflow, WorkflowVersion,
and WorkflowTrigger. They are identified by the Workflow.yaml, WorkflowVersion.yaml, and WorkflowTrigger suffixes.
We recommend having one file per workflow and workflow version.
When creating, updating, and deleting workflows, the Cognite Toolkit applies changes in the correct order based on the
dependencies between the workflows and workflow versions. The Cognite Toolkit creates transformations and functions before
the workflow versions to ensure that the workflow versions can reference them.
Example workflow:
my_workflow.Workflow.yaml
my_version.WorkflowVersion.yaml
my_trigger.WorkflowTrigger.yaml
<fragment>