CogniteMigration data model.
Prerequisites
Before migrating annotations, complete the following:- Creating a data model and mappings
- Deploying the CogniteMigration data model
- Migrating data sets
- Migrating assets
- Migrating files and time series
If you have not completed some prerequisites, see Manually populate the CogniteMigration data model.
Required capabilities
The following capabilities are required to runcdf migrate annotations:
Migrating annotations
Only annotations of resource typefile and annotation type diagrams.AssetLink or diagrams.FileLink can be migrated. See Migrating 360 images for 360° image annotation migration.
Select annotations by data set or CSV file, then run cdf migrate annotations.
1
Choose how to select annotations
Use data set selection to migrate all annotations linked to files in a data set. Use CSV file selection to migrate a specific list of annotations.
2
Run `cdf migrate annotations`
Run the command in interactive mode, or pass the options as arguments. See
cdf migrate annotations --help.3
Verify the migration
Confirm that annotation nodes exist in the target instance space for the selected files. See Verify the migration.
Data set selection
To migrate all annotations linked to files in a data set, run the command in interactive mode:cdf migrate annotations --help for details.
CSV file selection
To migrate annotations using a CSV file, run:<path to csv file> with a path relative to your Cognite Toolkit project root.
This CSV file migrates an annotation from the Kelmarsh example:
migration.annotations.csv
space: The target instance space where the annotation will be created.externalId: The external ID of the resulting annotation.id: The integer internal ID of the source annotation to migrate. This ID is returned in the response of the Filter annotations endpoint.
ingestionView: The resource view mapping to use. This is the annotation-specific equivalent of theingestionMappingcolumn used in other migration CSV formats. If omitted, the default mapping for annotations is used (typically the CogniteDiagramAnnotation view in the CogniteCore model). Deploy custom mappings withcdf buildandcdf deployusing the Resource view mapping resource type.
Verify the migration
After a successful run, confirm that annotation nodes exist in the target instance space. Query the instance space in CDF or use the DMS instances API to check that nodes with the expectedexternalId values are present.
For data set selections, compare the annotation node count in the target instance space against the number of source annotations returned by the Filter annotations endpoint for the same data set.
What cdf migrate annotations does
When you run cdf migrate annotations, the migration plugin performs the following steps on batches of annotations:
1
Download annotations
The Cognite Toolkit reads annotations from the asset-centric annotations endpoint, filtering for resource type
file and annotation types diagrams.AssetLink and diagrams.FileLink.2
Convert annotations to instance nodes
The Cognite Toolkit applies the mapping and converts each annotation to an instance node. The mapping is read from the
ingestionView column in the CSV file, or the default mapping is used if no mapping is specified.3
Write instance nodes to CDF
The Cognite Toolkit writes the created instance nodes to CDF using the
/models/instances endpoint.4
Create lineage nodes
While writing instances, the Cognite Toolkit creates lineage nodes in the
InstanceSource view in the CogniteMigration data model to record the lineage from source annotations to the created instance nodes.