Invoke
The cognite_data_quality.invoke module provides helpers for calling already-deployed Cognite Functions from Python. These helpers send a payload to the function running in CDF — they do not run validation locally.
call_validation()— unified entry point, dispatches byvalidation_typecall_validate_instances_shacl()— instance validation (type:instance)call_validate_instances_shacl_partitioned()— partitioned worker (type:partitioned)call_validate_timeseries_shacl()— time series validation (type:timeseries)call_validate_aggregate_uniqueness()— aggregate uniqueness (type:aggregate_uniqueness)call_validate_shacl()— SHACL-centric entrypoint with extension support (type:shacl)enqueue_historic_validation()— enqueue historic jobs onHistoricJobQueue(type: queue enqueue; sequential processing)deploy_validation_pipeline()— deploy and run the full validation pipeline (historic_mode: orchestrator or enqueue)
See Invoking validation functions for usage examples and payload key descriptions. For local sample vs estate historic (force=True), see Confirm that rules work.
cognite_data_quality.invoke
Invoke deployed Cognite Functions from Python.
Use these helpers to call the data quality validation functions from a notebook, script, or any Python runtime. Each function is a thin wrapper around client.functions.call().
call_rule_engine_result_sync(client, data, *, wait=True, external_id='data-quality-validation')
Call the incremental RuleEngineResult sync handler.
Source code in cognite_data_quality/invoke.py
call_validate_aggregate_uniqueness(client, data, *, wait=True, external_id='data-quality-validation')
Call the aggregate uniqueness validation handler.
Convenience wrapper for call_validation(validation_type="aggregate_uniqueness", ...).
Source code in cognite_data_quality/invoke.py
call_validate_instances_shacl(client, data, *, wait=True, external_id='data-quality-validation')
Call the instance SHACL validation function.
Convenience wrapper for call_validation(validation_type="instance", ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
data
|
dict
|
Payload dict. Typical keys: instances (dict with items), shacl_rules or ruleset_references, datamodel_space, datamodel_external_id, datamodel_version, auto_load_depth, records_config (stream_id, rule_set_id, etc.). |
required |
wait
|
bool
|
If True, block until the function returns. |
True
|
external_id
|
str
|
Function external ID (default: data-quality-validation). |
'data-quality-validation'
|
Returns:
| Type | Description |
|---|---|
dict
|
Response dict with conforms, violations, instances_validated, etc. |
Source code in cognite_data_quality/invoke.py
call_validate_instances_shacl_partitioned(client, data, *, wait=True, external_id='data-quality-validation')
Call the partitioned instance SHACL validation function (worker).
Convenience wrapper for call_validation(validation_type="partitioned", ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
data
|
dict
|
Payload dict. Same shape as validate-instances-shacl; instances are typically provided by the orchestrator. |
required |
wait
|
bool
|
If True, block until the function returns. |
True
|
external_id
|
str
|
Function external ID (default: data-quality-validation). |
'data-quality-validation'
|
Returns:
| Type | Description |
|---|---|
dict
|
Response dict with status, conforms, violations, instances_validated, etc. |
Source code in cognite_data_quality/invoke.py
call_validate_pre_persist(client, data, *, wait=True, external_id='data-quality-validation')
Validate a proposed DMS patch before persisting it.
Source code in cognite_data_quality/invoke.py
call_validate_shacl(client, data, *, wait=True, external_id='data-quality-validation')
Call the SHACL-centric validation entrypoint with optional global-rule extensions.
Convenience wrapper for call_validation(validation_type="shacl", ...).
Source code in cognite_data_quality/invoke.py
call_validate_timeseries_shacl(client, data, *, wait=True, external_id='data-quality-validation')
Call the time series SHACL validation function.
Convenience wrapper for call_validation(validation_type="timeseries", ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
data
|
dict
|
Payload dict. Typical keys: ruleset_references or shacl_rules, datamodel_space, datamodel_external_id, datamodel_version, filter or instance_ids, records_config. |
required |
wait
|
bool
|
If True, block until the function returns. |
True
|
external_id
|
str
|
Function external ID (default: data-quality-validation). |
'data-quality-validation'
|
Returns:
| Type | Description |
|---|---|
dict
|
Response dict with validation results. |
Source code in cognite_data_quality/invoke.py
call_validation(client, validation_type, data, *, wait=True, external_id='data-quality-validation')
Call the unified SHACL validation function.
The unified function consolidates all validation types into a single deployment. Use this function for new code. Legacy individual functions are still supported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
validation_type
|
Literal['instance', 'partitioned', 'timeseries', 'orchestrator', 'test', 'aggregate_uniqueness', 'rule_engine_result_sync', 'shacl', 'pre_persist']
|
Type of validation to perform: - "instance": Basic instance validation (real-time) - "partitioned": Partitioned historic instance validation - "timeseries": Time series validation (normal/backfill) - "orchestrator": Historic validation orchestrator - "test": Test SHACL rules without writing to Records API - "aggregate_uniqueness": Aggregate-based uniqueness validation - "rule_engine_result_sync": Incremental RuleEngineResult listener - "shacl": SHACL-centric entrypoint with optional global-rule extensions - "pre_persist": Validate a proposed DMS patch before apply |
required |
data
|
dict
|
Payload dict. Contents depend on validation_type. |
required |
wait
|
bool
|
If True, block until the function returns. |
True
|
external_id
|
str
|
Function external ID (default: data-quality-validation). |
'data-quality-validation'
|
Returns:
| Type | Description |
|---|---|
dict
|
Response dict from the appropriate handler. |
Example
Instance validation
result = call_validation( client=client, validation_type="instance", data={ "instances": {"items": [...]}, "ruleset_references": [{"externalId": "my_rules", "version": "1.0.0"}], "datamodel_space": "my_space", "datamodel_external_id": "MyModel", "datamodel_version": "v1", "records_config": {...} } )
Orchestrator
result = call_validation( client=client, validation_type="orchestrator", data={ "datamodel_space": "my_space", "view_external_id": "MyView", "instance_space": "my_instances", ... } )
Source code in cognite_data_quality/invoke.py
deploy_validation_pipeline(client, data=None, *, settings_path=None, views_dir=None, view_external_id=None, view_space=None, view_config_external_id=None, settings_external_id='data-quality-validation_settings', data_product_external_id=None, data_product_version=None, data_quality_space='dataQuality', wait=True, external_id='data-quality-validation', historic_mode='orchestrator', trigger_queue_manager=False, queue_manager_workflow_external_id='dq-historic-queue-manager', queue_manager_workflow_version='1', force=False)
Deploy and run a full validation pipeline with batch and incremental validation.
This function: 1. Triggers partitioned batch load of all instances (splits data into partitions) 2. Sets up sync trigger for ongoing incremental validation 3. Creates scheduled workflow for monitoring progress 4. Continuously manages orchestration (retries, cleanup)
Convenience wrapper for call_validation(validation_type="orchestrator", ...).
Three usage modes:
Mode 1: Pass data dict directly (legacy): deploy_validation_pipeline(client, data={...}, wait=True)
Mode 2: Load from local YAML configs: deploy_validation_pipeline( client, settings_path="config/environments/example/settings.yaml", view_external_id="SmallBoat", wait=True )
Mode 3: Load everything from CDF Files (no local files required): deploy_validation_pipeline( client, view_config_external_id="pump_view_config", )
Mode 4: DataProduct mode — triggers historic orchestrator per view: deploy_validation_pipeline( client, data_product_external_id="dp_rmdm_dm", view_external_id="Pump", # omit to run all views data_quality_space="sp_data_quality_demo", )
# View-only resolve (DataProduct inferred from managed_data_product_external_ids in DMS):
deploy_validation_pipeline(
client,
view_space="my_space",
view_external_id="Pump",
)
Loads view configs from the DataProduct API and calls the orchestrator for
each matching view. The orchestrator runs the historic batch validation and
sets up the per-view sync trigger on completion.
Infrastructure (``data_product_sync`` schedule, workflow definitions) must be
deployed first via ``deploy_validation_infrastructure()``.
Mode 4 enqueue — queue historic jobs instead of parallel orchestrators::
deploy_validation_pipeline(
client,
data_product_external_id="dp_rmdm_dm",
data_quality_space="sp_data_quality_demo",
historic_mode="enqueue",
trigger_queue_manager=True,
)
Uses ``enqueue_historic_validation()``; ``historic_queue_manager`` processes
the queue sequentially. Completed jobs for the same DP version are skipped
unless ``force=True``.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
data
|
dict | None
|
(Legacy) Payload dict. Typical keys: datamodel_space, datamodel_external_id, datamodel_version, view_space, view_external_id, view_version, instance_space, ruleset_references, partition_count, partition_field, records_space, records_container, stream_id, rule_set_id, rule_set_version. If None, must provide settings_path or view_config_external_id. |
None
|
settings_path
|
str | None
|
Path to a local settings.yaml file. Optional when using view_config_external_id — settings are then fetched from CDF Files instead. |
None
|
views_dir
|
str | None
|
Directory containing view YAML configs. Defaults to settings_path parent / "views". Only used in mode 2. |
None
|
view_external_id
|
str | list[str] | None
|
Specific view external ID (modes 2 and 4). Use with
|
None
|
view_space
|
str | None
|
DMS schema space for the view (modes 2 and 4). Required when the external ID is ambiguous across spaces. |
None
|
view_config_external_id
|
str | None
|
External ID of a view config stored in CDF Files (mode 3).
Uploaded during deployment via deploy_instance_workflows().
External ID scheme: |
None
|
settings_external_id
|
str
|
External ID of the settings file stored in CDF Files.
Defaults to |
'data-quality-validation_settings'
|
data_quality_space
|
str
|
DMS space where the |
'dataQuality'
|
wait
|
bool
|
If True, block until the function returns. |
True
|
external_id
|
str
|
Function external ID (default: data-quality-validation).
Only used in legacy mode (when |
'data-quality-validation'
|
historic_mode
|
Literal['orchestrator', 'enqueue']
|
In DataProduct mode (mode 4), |
'orchestrator'
|
trigger_queue_manager
|
bool
|
When |
False
|
queue_manager_workflow_external_id
|
str
|
Workflow external ID for the queue manager. |
'dq-historic-queue-manager'
|
queue_manager_workflow_version
|
str
|
Workflow version for the queue manager. |
'1'
|
force
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Response dict from the function. |
Example
Mode 4: DataProduct mode — trigger historic validation for one view
result = deploy_validation_pipeline( client, data_product_external_id="dp_rmdm_dm", view_external_id="Pump", # omit for all views data_quality_space="sp_data_quality_demo", )
Mode 3: fully from CDF — no local files needed
result = deploy_validation_pipeline( client, view_config_external_id="pump_view_config", )
Mode 2: local YAML files
result = deploy_validation_pipeline( client, settings_path="config/environments/example/settings.yaml", view_external_id="SmallBoat", )
Mode 1: legacy data dict
result = deploy_validation_pipeline( client, data={"datamodel_space": "sailboat", ...} )
Source code in cognite_data_quality/invoke.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |
enqueue_historic_validation(client, *, data_product_external_id=None, data_product_version=None, view_external_id=None, view_space=None, data_quality_space='dataQuality', trigger_queue_manager=False, queue_manager_workflow_external_id='dq-historic-queue-manager', queue_manager_workflow_version='1', force=False)
Enqueue historic validation jobs on HistoricJobQueue for sequential processing.
Idempotent per view and DataProduct version: jobs already queued, running,
or completed for the same version are skipped. Failed jobs are re-enqueued.
Pass force=True to re-queue a completed historic run for the current
DataProduct/RuleSet version, including views with
historic_reprocess_on_update=false. Already queued or running jobs
are still skipped. view_external_id only narrows which views are in scope.
All managed DataProducts (from DMS managed_data_product_external_ids):
enqueue_historic_validation(client, data_quality_space="sp_data_quality")
Single DataProduct (all ruled views, or filter with view_external_id):
enqueue_historic_validation(
client,
data_product_external_id="dp_ent_sif",
data_quality_space="sp_data_quality",
)
Re-run historic for all ruled views without a version bump:
enqueue_historic_validation(
client,
data_product_external_id="dp_ent_sif",
data_quality_space="sp_data_quality",
force=True,
trigger_queue_manager=True,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
CogniteClient
|
Cognite client instance. |
required |
data_product_external_id
|
str | None
|
DataProduct external ID. When omitted, enqueues for every managed DataProduct in DMS settings. |
None
|
data_product_version
|
str | None
|
Optional explicit DP version; defaults to latest published. |
None
|
view_external_id
|
str | list[str] | None
|
Optional view filter (single ID or list). |
None
|
view_space
|
str | None
|
Disambiguate when the same view external ID exists in multiple spaces. |
None
|
data_quality_space
|
str
|
DMS space for |
'dataQuality'
|
trigger_queue_manager
|
bool
|
If True, start |
False
|
queue_manager_workflow_external_id
|
str
|
Workflow external ID for the queue manager. |
'dq-historic-queue-manager'
|
queue_manager_workflow_version
|
str
|
Workflow version for the queue manager. |
'1'
|
force
|
bool
|
If True, re-queue completed jobs for the same DataProduct/RuleSet version
and include views with |
False
|
Returns:
| Type | Description |
|---|---|
EnqueueHistoricValidationResult
|
|
Source code in cognite_data_quality/invoke.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |