invoke
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_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 shacl_rules_file_external_id, 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_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: shacl_rules_file_external_id, 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']
|
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 |
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": [...]}, "shacl_rules_file_external_id": "my_rules", "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_config_external_id=None, settings_external_id='data-quality-validation_settings', wait=True, external_id='data-quality-validation')
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/cog-sail/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", )
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, shacl_file_external_id, 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 | None
|
Specific view to deploy from local files (mode 2). |
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'
|
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 function. |
Example
Mode 3: fully from CDF — no local files needed
result = deploy_validation_pipeline( client, view_config_external_id="pump_view_config", )
Mode 3: override settings external ID
result = deploy_validation_pipeline( client, view_config_external_id="pump_view_config", settings_external_id="my-function_settings", )
Mode 2: local YAML files
result = deploy_validation_pipeline( client, settings_path="config/environments/cog-sail/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
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |