Skip to main content
The P&ID Annotation deployment pack (dp:contextualization:cdf_p_and_id_annotation) automates the annotation of Piping and Instrumentation Diagrams (P&IDs) in Cognite Data Fusion. It deploys as a Cognite Toolkit module and uses a CDF Workflow to run two tagging transformations followed by a CDF Function that detects tags in each diagram and links them to assets and files as CogniteDiagramAnnotation instances in the data model. The pack ships production-tested code drawn from real customer implementations, with incremental processing via the Data Modeling Sync API, threshold-based approval and suggestion, and batch-level resilience for large P&ID volumes.
P&ID Annotation is a cherry-pickable module (dp:contextualization:cdf_p_and_id_annotation) inside the Contextualization deployment pack (dp:contextualization). You can add it on its own or alongside the other contextualization modules.

Who it’s for

Target personas:
  • Data engineers — deploy, configure, and tune the annotation pipeline.
  • Subject matter experts — engineers who validate P&ID-to-asset annotations.
Use this pack when:
  • You need to contextualize P&ID documents by linking them to assets and other files in your CDF data model.
  • You want a production-ready annotation pipeline without building one from scratch.
  • Your project ingests P&ID files from sources such as SharePoint and needs to match them to asset hierarchies from systems such as SAP.
  • You need incremental processing — only new or updated files should be annotated on each run.
When not to use this pack:
  • If your P&ID documents require a fundamentally different annotation engine — this pack covers standard diagram detection and CDF annotation.
  • If P&ID files have not yet been ingested into the CDF file store — the pack requires files to be present before it can annotate them.
  • If you need to match time series to assets rather than annotate documents, use the CDF Entity Matching deployment pack instead.

What’s included

Prerequisites

Verify all of the following before you start:
  • Cognite Toolkit version 0.8 or later is installed. See Setting up.
  • A cdf.toml file exists in your project root. If it is missing, run cdf modules init and select Create toml file (required).
  • Authentication is configured and verified — run cdf auth init and cdf auth verify using a local .env file. See Authentication and authorization.
  • P&ID files are already ingested into the CDF file store, and an asset hierarchy exists in the data model for matching.
  • You have an IdP application for the function and scheduled workflow (IDP_CLIENT_ID / IDP_CLIENT_SECRET) and the IdP group source ID for the files.processing.groups access group.

Install and deploy

You can add the P&ID Annotation module to an existing Toolkit project or start a new project from scratch.
Add the module from your project directory:
The Toolkit creates the module under modules/contextualization/cdf_p_and_id_annotation/ and updates your config.<env>.yaml files. Before building, open config.dev.yaml and set at minimum project, organization, location_name, source_name, the schema and instance spaces, and the credentials (functionClientId / functionClientSecret and files_location_processing_group_source_id) — see Configuration reference. Then build and deploy:
1

Build deployment artifacts

The Toolkit substitutes template variables and writes artifacts to the build/ directory. If you need to change the project name or any variables marked <change_me>, edit config.<env>.yaml first — see Configure, build, and deploy modules.
2

Dry-run the deployment

Inspect the output and confirm that configurations look correct before deploying.
3

Deploy to CDF

The Toolkit deploys only configurations that have changed since the last run.
4

Set up CI/CD (optional)

For governed production deployments, automate build, dry-run, and deploy in a pipeline. See Set up CI/CD pipelines.
After deployment, your project should include:

Verify the deployment

After deploying, confirm success with these checks:
  1. The cdf deploy command finishes without errors and reports successful deployment of Functions, Workflows, Transformations, Extraction Pipelines, RAW, the data set, and the access group.
  2. In CDF, navigate to Integrate > Data Workflows and verify that the annotation workflow is listed (external ID p_and_id_annotation by default).
  3. Trigger the workflow with Run (or wait for the daily trigger). Confirm that both tagging transformations complete before the annotation function, and that all tasks finish without errors.
  4. Navigate to Build Solutions > Functions, open fn_dm_context_files_annotation, select View logs, and verify that files were processed without errors.
  5. Navigate to Integrate > Staging (RAW) and verify that documents_tags, documents_docs, and files_state_store have been created and populated.
  6. Use CDF Search in Industrial Tools to confirm annotations on P&ID documents — purple boxes link to assets, orange boxes link to files.
The deployment is successful when the workflow completes without errors, the RAW match tables are populated, and annotations appear on the P&ID documents.

Configuration reference

Module variables are set per environment in config.<env>.yaml. Update these before running cdf build. Each variable takes its default unless you override it. Where the default is , a placeholder (for example YourOrg, LOC, SOURCE, <not set>), or a ${...} value read from .env, you must provide your own value before deploying.

Runtime parameters (extraction pipeline)

Annotation behavior is controlled by extraction_pipelines/ctx_files-pandid_annotation.config.yaml (ep_ctx_files_pandid_annotation), not config.<env>.yaml. The data section configures the views to annotate — the file view (type: diagrams.FileLink) and one or more entity views such as the asset view (type: diagrams.AssetLink) — each with a searchProperty (default name) and an optional filterProperty / filterValues (for example, tags: ["PID"]) to scope matching.
If you change autoApprovalThreshold or autoSuggestThreshold, set cleanOldAnnotations: true for one run to remove the annotations created by previous runs before re-annotating. Only annotations created by this process are removed; manually created annotations are preserved.

Architecture

The pack deploys a CDF Function, two tagging transformations, a workflow with a daily trigger, an extraction pipeline holding the runtime parameters, RAW tables, an access group, and a dataset.

Data flow

The workflow tags qualifying assets and files, then runs the annotation function. The function detects tags in each P&ID, matches them to assets and files, and creates annotations classified by the two confidence thresholds.

Annotation pipeline

The workflow runs in three stages:
  1. Taggingasset_tagging_tr and file_tagging_tr add a PID tag to qualifying assets and files. These are customizable examples that control which records the filterProperty / filterValues settings admit into matching.
  2. Detection and matching — the annotation function reads new or updated files via the Sync API, detects tags in each diagram, and matches them against the configured file and asset views using each view’s searchProperty.
  3. Annotation creation — matches at or above autoApprovalThreshold are approved and those at or above autoSuggestThreshold are suggested; both are written as CogniteDiagramAnnotation instances (diagrams.AssetLink for assets, diagrams.FileLink for files). Document-to-tag and document-to-document matches are also written to the documents_tags and documents_docs RAW tables.

Run modes

Resilience

The annotation function processes files in batches with up to three retries per batch, then falls back to processing files individually. Failed individual files are logged and skipped without blocking the run. Annotation external IDs prevent duplicate annotations across runs when cleanup is disabled, and each successful batch persists its cursor so a failed run resumes without reprocessing.

Troubleshooting

For issues not covered here, contact Cognite support.

Support

Last modified on July 6, 2026