Contextualization

Entity Matching

These APIs will return as soon as possible, deferring a blocking wait until the last moment. Nevertheless, they can block for a long time awaiting results.

Fit Entity Matching Model

async EntityMatchingAPI.fit(
sources: Sequence[dict | CogniteResource],
targets: Sequence[dict | CogniteResource],
true_matches: Sequence[dict | tuple[int | str, int | str]] | None = None,
match_fields: dict | Sequence[tuple[str, str]] | None = None,
feature_type: str | None = None,
classifier: str | None = None,
ignore_missing_fields: bool = False,
name: str | None = None,
description: str | None = None,
external_id: str | None = None,
) EntityMatchingModel

Fit entity matching model.

Note

All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.

Parameters:
  • sources (Sequence[dict | CogniteResource]) – entities to match from, should have an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). Metadata fields are automatically flattened to “metadata.key” entries, such that they can be used in match_fields.

  • targets (Sequence[dict | CogniteResource]) – entities to match to, should have an ‘id’ field. Tolerant to passing more than is needed or used.

  • true_matches (Sequence[dict | tuple[int | str, int | str]] | None) – Known valid matches given as a list of dicts with keys ‘sourceId’, ‘sourceExternalId’, ‘targetId’, ‘targetExternalId’). If omitted, uses an unsupervised model. A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.

  • match_fields (dict | Sequence[tuple[str, str]] | None) – List of (from,to) keys to use in matching. Default in the API is [(‘name’,’name’)]. Also accepts {“source”: .., “target”: ..}.

  • feature_type (str | None) – feature type that defines the combination of features used, see API docs for details.

  • classifier (str | None) – classifier used in training.

  • ignore_missing_fields (bool) – whether missing data in match_fields should return error or be filled in with an empty string.

  • name (str | None) – Optional user-defined name of model.

  • description (str | None) – Optional user-defined description of model.

  • external_id (str | None) – Optional external id. Must be unique within the project.

Returns:

Resulting queued model.

Return type:

EntityMatchingModel

Example

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> sources = [{'id': 101, 'name': 'ChildAsset1', 'description': 'Child of ParentAsset1'}]
>>> targets = [{'id': 1, 'name': 'ParentAsset1', 'description': 'Parent to ChildAsset1'}]
>>> true_matches = [(1, 101)]
>>> model = client.entity_matching.fit(
...     sources=sources,
...     targets=targets,
...     true_matches=true_matches,
...     description="AssetMatchingJob1"
... )

Re-fit Entity Matching Model

async EntityMatchingAPI.refit(
true_matches: Sequence[dict | tuple[int | str, int | str]],
id: int | None = None,
external_id: str | None = None,
) EntityMatchingModel

Re-fits an entity matching model, using the combination of the old and new true matches.

Note

All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.

Parameters:
  • true_matches (Sequence[dict | tuple[int | str, int | str]]) – Updated known valid matches given as a list of dicts with keys ‘fromId’, ‘fromExternalId’, ‘toId’, ‘toExternalId’). A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.

  • id (int | None) – id of the model to use.

  • external_id (str | None) – external id of the model to use.

Returns:

new model refitted to true_matches.

Return type:

EntityMatchingModel

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> sources = [{'id': 101, 'name': 'ChildAsset1', 'description': 'Child of ParentAsset1'}]
>>> targets = [{'id': 1, 'name': 'ParentAsset1', 'description': 'Parent to ChildAsset1'}]
>>> true_matches = [(1, 101)]
>>> model = client.entity_matching.refit(true_matches=true_matches, id=1)

Retrieve Entity Matching Models

async EntityMatchingAPI.retrieve(
id: int | None = None,
external_id: str | None = None,
) EntityMatchingModel | None

Retrieve model

Parameters:
  • id (int | None) – id of the model to retrieve.

  • external_id (str | None) – external id of the model to retrieve.

Returns:

Model requested.

Return type:

EntityMatchingModel | None

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> retrieved_model = client.entity_matching.retrieve(id=1)
async EntityMatchingAPI.retrieve_multiple(
ids: Sequence[int] | None = None,
external_ids: SequenceNotStr[str] | None = None,
) EntityMatchingModelList

Retrieve models

Parameters:
  • ids (Sequence[int] | None) – ids of the model to retrieve.

  • external_ids (SequenceNotStr[str] | None) – external ids of the model to retrieve.

Returns:

Models requested.

Return type:

EntityMatchingModelList

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> retrieved_models = client.entity_matching.retrieve_multiple([1,2,3])
async EntityMatchingAPI.list(
name: str | None = None,
description: str | None = None,
original_id: int | None = None,
feature_type: str | None = None,
classifier: str | None = None,
limit: int | None = 25,
) EntityMatchingModelList

List models

Parameters:
  • name (str | None) – Optional user-defined name of model.

  • description (str | None) – Optional user-defined description of model.

  • original_id (int | None) – id of the original model for models that were created with refit.

  • feature_type (str | None) – feature type that defines the combination of features used.

  • classifier (str | None) – classifier used in training.

  • limit (int | None) – Maximum number of items to return. Defaults to 25. Set to -1, float(“inf”) or None to return all items.

Returns:

List of models.

Return type:

EntityMatchingModelList

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> client.entity_matching.list(limit=1, name="test")

Delete Entity Matching Models

async EntityMatchingAPI.delete(
id: int | Sequence[int] | None = None,
external_id: str | SequenceNotStr[str] | None = None,
) None

Delete models

https://api-docs.cognite.com/20230101/tag/Entity-matching/operation/entityMatchingDelete

Parameters:
  • id (int | Sequence[int] | None) – Id or list of ids

  • external_id (str | SequenceNotStr[str] | None) – External ID or list of external ids

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> client.entity_matching.delete(id=1)

Update Entity Matching Models

async EntityMatchingAPI.update(
item: EntityMatchingModel | EntityMatchingModelUpdate | Sequence[EntityMatchingModel | EntityMatchingModelUpdate],
mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null',
) EntityMatchingModelList | EntityMatchingModel

Update model

Parameters:
  • item (EntityMatchingModel | EntityMatchingModelUpdate | Sequence[EntityMatchingModel | EntityMatchingModelUpdate]) – Model(s) to update

  • mode (Literal['replace_ignore_null', 'patch', 'replace']) – How to update data when a non-update object is given (EntityMatchingModel). If you use ‘replace_ignore_null’, only the fields you have set will be used to replace existing (default). Using ‘replace’ will additionally clear all the fields that are not specified by you. Last option, ‘patch’, will update only the fields you have set and for container-like fields such as metadata or labels, add the values to the existing. For more details, see Update and Upsert Mode Parameter.

Returns:

No description.

Return type:

EntityMatchingModelList | EntityMatchingModel

Examples

>>> from cognite.client.data_classes.contextualization import EntityMatchingModelUpdate
>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> client.entity_matching.update(EntityMatchingModelUpdate(id=1).name.set("New name"))

Predict Using an Entity Matching Model

async EntityMatchingAPI.predict(
sources: Sequence[dict] | None = None,
targets: Sequence[dict] | None = None,
num_matches: int = 1,
score_threshold: float | None = None,
id: int | None = None,
external_id: str | None = None,
) EntityMatchingPredictionResult

Predict entity matching.

Warning

Blocks and waits for the model to be ready if it has been recently created.

Note

All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.

Parameters:
  • sources (Sequence[dict] | None) – entities to match from, does not need an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). If omitted, will use data from fit.

  • targets (Sequence[dict] | None) – entities to match to, does not need an ‘id’ field. Tolerant to passing more than is needed or used. If omitted, will use data from fit.

  • num_matches (int) – number of matches to return for each item.

  • score_threshold (float | None) – only return matches with a score above this threshold

  • id (int | None) – id of the model to use.

  • external_id (str | None) – external id of the model to use.

Returns:

object which can be used to wait for and retrieve results.

Return type:

EntityMatchingPredictionResult

Examples

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> sources = {'id': 101, 'name': 'ChildAsset1', 'description': 'Child of ParentAsset1'}
>>> targets = {'id': 1, 'name': 'ParentAsset1', 'description': 'Parent to ChildAsset1'}
>>> true_matches = [(1, 101)]
>>> model = client.entity_matching.predict(
...     sources = sources,
...     targets = targets,
...     num_matches = 1,
...     score_threshold = 0.6,
...     id=1
... )

Engineering Diagrams

Detect entities in Engineering Diagrams

async DiagramsAPI.detect(
entities: Sequence[dict | CogniteResource],
search_field: str = 'name',
partial_match: bool = False,
min_tokens: int = 2,
file_ids: int | Sequence[int] | None = None,
file_external_ids: str | SequenceNotStr[str] | None = None,
file_instance_ids: NodeId | Sequence[NodeId] | None = None,
file_references: list[FileReference] | FileReference | None = None,
pattern_mode: bool | None = None,
configuration: DiagramDetectConfig | None = None,
*,
multiple_jobs: bool = False,
) DiagramDetectResults | tuple[DetectJobBundle, list[dict[str, Any]]]

Detect annotations in engineering diagrams

Note

All users on this CDF subscription with assets read-all and files read-all capabilities in the project, are able to access the data sent to this endpoint.

Parameters:
  • entities (Sequence[dict | CogniteResource]) – List of entities to detect

  • search_field (str) – If entities is a list of dictionaries, this is the key to the values to detect in the PnId

  • partial_match (bool) – Allow for a partial match (e.g. missing prefix).

  • min_tokens (int) – Minimal number of tokens a match must be based on

  • file_ids (int | Sequence[int] | None) – ID of the files, should already be uploaded in the same tenant.

  • file_external_ids (str | SequenceNotStr[str] | None) – File external ids, alternative to file_ids and file_references.

  • file_instance_ids (NodeId | Sequence[NodeId] | None) – Files to detect in, specified by instance id.

  • file_references (list[FileReference] | FileReference | None) – File references (id, external_id or instance_id), and first_page and last_page to specify page ranges per file. Each reference can specify up to 50 pages. Providing a page range will also make the page count of the document a part of the response.

  • pattern_mode (bool | None) – If True, entities must be provided with a sample field. This enables detecting tags that are similar to the sample, but not necessarily identical. Defaults to None.

  • configuration (DiagramDetectConfig | None) – Additional configuration for the detect algorithm. See DiagramDetectConfig class documentation and beta API docs.

  • multiple_jobs (bool) – Enables you to publish multiple jobs. If True the method returns a tuple of DetectJobBundle and list of potentially unposted files. If False it will return a single DiagramDetectResults. Defaults to False.

Returns:

Resulting queued job or a bundle of jobs and a list of unposted files. Note that the .result property of the job or job bundle will block waiting for results.

Return type:

DiagramDetectResults | tuple[DetectJobBundle, list[dict[str, Any]]]

Note

The results are not written to CDF, to create annotations based on detected entities use AnnotationsAPI.

Examples

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.contextualization import FileReference
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> detect_job = client.diagrams.detect(
...     entities=[
...         {"userDefinedField": "21PT1017","ignoredField": "AA11"},
...         {"userDefinedField": "21PT1018"}],
...     search_field="userDefinedField",
...     partial_match=True,
...     min_tokens=2,
...     file_ids=[101],
...     file_external_ids=["Test1"],
...     file_references=[
...         FileReference(id=20, first_page=1, last_page=10),
...         FileReference(external_id="ext_20", first_page=11, last_page=20)
...     ])
>>> result = detect_job.get_result()
>>> print(result)
<code>
{
    'items': [
        {'fileId': 101, 'annotations': []},
        {'fileExternalId': 'Test1', 'fileId: 1, 'annotations': []},
        {'fileId': 20, 'fileExternalId': 'ext_20', 'annotations': [], 'pageCount': 17},
        {
            'fileId': 20,
            'fileExternalId': 'ext_20',
            'annotations': [
                {
                    'text': '21PT1017',
                    'entities': [{"userDefinedField": "21PT1017","ignoredField": "AA11"}],
                    'region': {
                        'page': 12,
                        'shape': 'rectangle',
                        'vertices': [
                            {'x': 0.01, 'y': 0.01},
                            {'x': 0.01, 'y': 0.02},
                            {'x': 0.02, 'y': 0.02},
                            {'x': 0.02, 'y': 0.01}
                        ]
                    }
                }
            ],
            'pageCount': 17
        }
    ]
}
</code>

To use beta configuration options you can use a dictionary or DiagramDetectConfig object for convenience:

>>> from cognite.client.data_classes.contextualization import ConnectionFlags, DiagramDetectConfig
>>> config = DiagramDetectConfig(
...     remove_leading_zeros=True,
...     connection_flags=ConnectionFlags(
...         no_text_inbetween=True,
...         natural_reading_order=True,
...     )
... )
>>> job = client.diagrams.detect(entities=[{"name": "A1"}], file_id=123, config=config)

Check the documentation for DiagramDetectConfig for more information on the available options.

Convert to an interactive SVG where the provided annotations are highlighted

async DiagramsAPI.convert(
detect_job: DiagramDetectResults,
) DiagramConvertResults

Convert a P&ID to interactive SVGs where the provided annotations are highlighted.

Note

Will automatically wait for the detect job to complete before starting the conversion.

Parameters:

detect_job (DiagramDetectResults) – detect job

Returns:

Resulting queued job.

Return type:

DiagramConvertResults

Examples

Run a detection job, then convert the results:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> detect_job = client.diagrams.detect(...)
>>> client.diagrams.convert(detect_job=detect_job)

Vision

The Vision API enable extraction of information from imagery data based on their visual content. For example, you can can extract features such as text, asset tags or industrial objects from images using this service.

Quickstart

Start an asynchronous job to extract information from image files stored in CDF:

from cognite.client import CogniteClient
from cognite.client.data_classes.contextualization import VisionFeature

client = CogniteClient()
extract_job = client.vision.extract(
    features=[VisionFeature.ASSET_TAG_DETECTION, VisionFeature.PEOPLE_DETECTION],
    file_ids=[1, 2],
)

The returned job object, extract_job, can be used to retrieve the status of the job and the prediction results once the job is completed. Wait for job completion and get the parsed results:

extract_job.wait_for_completion()
for item in extract_job.items:
    predictions = item.predictions
    # do something with the predictions

Save the prediction results in CDF as Annotations:

extract_job.save_predictions()

Note

Prediction results are stored in CDF as Annotations using the images.* annotation types. In particular, text detections are stored as images.TextRegion, asset tag detections are stored as images.AssetLink, while other detections are stored as images.ObjectDetection.

Tweaking the parameters of a feature extractor:

from cognite.client.data_classes.contextualization import FeatureParameters, TextDetectionParameters

extract_job = client.vision.extract(
    features=VisionFeature.TEXT_DETECTION,
    file_ids=[1, 2],
    parameters=FeatureParameters(text_detection_parameters=TextDetectionParameters(threshold=0.9))
    # or
    # parameters = {"textDetectionParameters": {"threshold": 0.9}}
)

Extract

async VisionAPI.extract(
features: VisionFeature | list[VisionFeature],
file_ids: list[int] | None = None,
file_external_ids: list[str] | None = None,
parameters: FeatureParameters | None = None,
) VisionExtractJob

Start an asynchronous job to extract features from image files.

Parameters:
  • features (VisionFeature | list[VisionFeature]) – The feature(s) to extract from the provided image files.

  • file_ids (list[int] | None) – IDs of the image files to analyze. The images must already be uploaded in the same CDF project.

  • file_external_ids (list[str] | None) – The external file ids of the image files to analyze.

  • parameters (FeatureParameters | None) – No description.

Returns:

Resulting queued job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.

Return type:

VisionExtractJob

Examples

Start a job, wait for completion and then get the parsed results:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.contextualization import VisionFeature
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> extract_job = client.vision.extract(features=VisionFeature.ASSET_TAG_DETECTION, file_ids=[1])
>>> extract_job.wait_for_completion()
>>> for item in extract_job.items:
...     predictions = item.predictions
...     # do something with the predictions
>>> # Save predictions in CDF using Annotations API:
>>> extract_job.save_predictions()

Get vision extract job

async VisionAPI.get_extract_job(
job_id: int,
) VisionExtractJob

Retrieve an existing extract job by ID.

Parameters:

job_id (int) – ID of an existing feature extraction job.

Returns:

Vision extract job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.

Return type:

VisionExtractJob

Examples

Retrieve a vision extract job by ID:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> extract_job = client.vision.get_extract_job(job_id=1)
>>> extract_job.wait_for_completion()
>>> for item in extract_job.items:
...     predictions = item.predictions
...     # do something with the predictions

Contextualization Data Classes

class cognite.client.data_classes.contextualization.AssetTagDetectionParameters(
threshold: 'float | None' = None,
partial_match: 'bool | None' = None,
asset_subtree_ids: 'list[int] | None' = None,
)

Bases: VisionResource, ThresholdParameter

asset_subtree_ids: list[int] | None = None
dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(
resource: dict | str,
) Self

Load a resource from a YAML/JSON string or dict.

partial_match: bool | None = None
threshold: float | None = None
to_pandas(
camel_case: bool = False,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.ConnectionFlags(
natural_reading_order: bool = False,
no_text_inbetween: bool = False,
**flags: bool,
)

Bases: object

Connection flags for token graph. These are passed as an array of strings to the API. Only flags set to True are included in the array. There is no need to set any flags to False.

Parameters:
  • natural_reading_order (bool) – Only connect text regions that are in natural reading order (i.e. top to bottom and left to right).

  • no_text_inbetween (bool) – Only connect text regions that are not separated by other text regions.

  • **flags (bool) – Other flags.

dump(camel_case: bool = False) list[str]
classmethod load(resource: list[str]) Self
class cognite.client.data_classes.contextualization.ContextualizationJob(
job_id: int,
status: str,
status_time: int,
created_time: int,
error_message: str | None,
)

Bases: CogniteResourceWithClientRef, ABC

Data class for the result of a contextualization job.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

get_result() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

async get_result_async() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

set_client_ref(client: AsyncCogniteClient) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

abstract update_status() str
abstract async update_status_async() str
wait_for_completion(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.ContextualizationJobList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceListWithClientRef[ContextualizationJob]

append(item)

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S
copy()
count(
value,
) integer -- return number of occurrences of value
dump(
camel_case: bool = True,
) list[dict[str, Any]]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A list of dicts representing the instance.

Return type:

list[dict[str, Any]]

dump_raw(
camel_case: bool = True,
) dict[str, Any]

This method dumps the list with extra information in addition to the items.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the list.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instances into a YAML formatted string.

Returns:

A YAML formatted string representing the instances.

Return type:

str

extend(
other: Iterable[Any],
) None

S.extend(iterable) – extend sequence by appending elements from the iterable

get(
id: int | None = None,
external_id: str | None = None,
instance_id: InstanceId | tuple[str, str] | None = None,
) T_CogniteResource | None

Get an item from this list by id, external_id or instance_id.

Parameters:
  • id (int | None) – The id of the item to get.

  • external_id (str | None) – The external_id of the item to get.

  • instance_id (InstanceId | tuple[str, str] | None) – The instance_id of the item to get.

Returns:

The requested item if present, otherwise None.

Return type:

T_CogniteResource | None

index(
value[,
start[,
stop,]]
) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

classmethod load(
resource: Sequence[dict[str, Any]] | str,
) Self

Load a resource from a YAML/JSON string or iterable of dict.

pop(
[index,]
) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

set_client_ref(client: AsyncCogniteClient) Self
sort(*args, **kwds)
to_pandas(
camel_case: bool = False,
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.

Parameters:
  • camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

  • expand_metadata (bool) – Expand the metadata column into separate columns.

  • metadata_prefix (str) – Prefix to use for metadata columns.

  • convert_timestamps (bool) – Convert known columns storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The Cognite resource as a dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.ContextualizationJobType(value)

Bases: Enum

An enumeration.

DIAGRAMS = 'diagrams'
ENTITY_MATCHING = 'entity_matching'
VISION = 'vision'
class cognite.client.data_classes.contextualization.CustomizeFuzziness(
fuzzy_score: float | None = None,
max_boxes: int | None = None,
min_chars: int | None = None,
)

Bases: CogniteResource

Additional requirements for the fuzzy matching algorithm. The fuzzy match is allowed if any of these are true for each match candidate. The overall minFuzzyScore still applies, but a stricter fuzzyScore can be set here, which would not be enforced if either the minChars or maxBoxes conditions are met, making it possible to exclude detections using replacements if they are either short, or combined from many boxes.

Parameters:
  • fuzzy_score (float | None) – The minimum fuzzy score of the candidate match.

  • max_boxes (int | None) – Maximum number of text boxes the potential match is composed of.

  • min_chars (int | None) – The minimum number of characters that must be present in the candidate match string.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DetectJobBundle(job_ids: list[int], client: AsyncCogniteClient)

Bases: object

async fetch_results() list[dict[str, Any]]
get_result() tuple[list[dict[str, Any]], list[dict[str, Any]]]

Waits for the job to finish and returns the results.

async get_result_async() tuple[list[dict[str, Any]], list[dict[str, Any]]]

Waits for the job to finish and returns the results.

property result: tuple[list[dict[str, Any]], list[dict[str, Any]]]

Get the result of the detect job bundle.

wait_for_completion(timeout: int | None = None) None

Waits for all jobs to complete, generally not needed to call as it is called by result.

Parameters:

timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)

async wait_for_completion_async(timeout: int | None = None) None

Waits for all jobs to complete, generally not needed to call as it is called by result.

Parameters:

timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)

class cognite.client.data_classes.contextualization.DiagramConvertItem(
file_id: int,
file_external_id: str | None,
results: list[dict[str, Any]],
)

Bases: CogniteResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

property pages: DiagramConvertPageList
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DiagramConvertPage(page: int, png_url: str, svg_url: str)

Bases: CogniteResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DiagramConvertPageList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[DiagramConvertPage]

append(item)

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S
copy()
count(
value,
) integer -- return number of occurrences of value
dump(
camel_case: bool = True,
) list[dict[str, Any]]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A list of dicts representing the instance.

Return type:

list[dict[str, Any]]

dump_raw(
camel_case: bool = True,
) dict[str, Any]

This method dumps the list with extra information in addition to the items.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the list.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instances into a YAML formatted string.

Returns:

A YAML formatted string representing the instances.

Return type:

str

extend(
other: Iterable[Any],
) None

S.extend(iterable) – extend sequence by appending elements from the iterable

get(
id: int | None = None,
external_id: str | None = None,
instance_id: InstanceId | tuple[str, str] | None = None,
) T_CogniteResource | None

Get an item from this list by id, external_id or instance_id.

Parameters:
  • id (int | None) – The id of the item to get.

  • external_id (str | None) – The external_id of the item to get.

  • instance_id (InstanceId | tuple[str, str] | None) – The instance_id of the item to get.

Returns:

The requested item if present, otherwise None.

Return type:

T_CogniteResource | None

index(
value[,
start[,
stop,]]
) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

classmethod load(
resource: Sequence[dict[str, Any]] | str,
) Self

Load a resource from a YAML/JSON string or iterable of dict.

pop(
[index,]
) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

sort(*args, **kwds)
to_pandas(
camel_case: bool = False,
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.

Parameters:
  • camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

  • expand_metadata (bool) – Expand the metadata column into separate columns.

  • metadata_prefix (str) – Prefix to use for metadata columns.

  • convert_timestamps (bool) – Convert known columns storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The Cognite resource as a dataframe.

Return type:

pandas.DataFrame

final class cognite.client.data_classes.contextualization.DiagramConvertResults(
job_id: int,
status: str,
status_time: int,
created_time: int,
items: list[DiagramConvertItem],
start_time: int,
error_message: str | None,
)

Bases: ContextualizationJob

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

get_result() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

async get_result_async() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

property result: dict[str, Any]

Get the result of the diagram conversion job.

set_client_ref(client: AsyncCogniteClient) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

update_status() str

Updates the model status and returns it

async update_status_async() str

Updates the model status and returns it

wait_for_completion(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.DiagramDetectConfig(
annotation_extract: bool | None = None,
case_sensitive: bool | None = None,
connection_flags: ConnectionFlags | list[str] | None = None,
customize_fuzziness: CustomizeFuzziness | dict[str, Any] | None = None,
direction_delta: float | None = None,
direction_weights: DirectionWeights | dict[str, Any] | None = None,
min_fuzzy_score: float | None = None,
read_embedded_text: bool | None = None,
remove_leading_zeros: bool | None = None,
substitutions: dict[str, list[str]] | None = None,
**params: Any,
)

Bases: CogniteResource

Configuration options for the diagrams/detect endpoint.

Parameters:
  • annotation_extract (bool | None) – Read SHX text embedded in the diagram file. If present, this text will override overlapping OCR text. Cannot be used at the same time as read_embedded_text.

  • case_sensitive (bool | None) – Case sensitive text matching. Defaults to True.

  • connection_flags (ConnectionFlags | list[str] | None) – Connection flags for token graph. Two flags are supported thus far: no_text_inbetween and natural_reading_order.

  • customize_fuzziness (CustomizeFuzziness | dict[str, Any] | None) – Additional requirements for the fuzzy matching algorithm. The fuzzy match is allowed if any of these are true for each match candidate. The overall minFuzzyScore still applies, but a stricter fuzzyScore can be set here, which would not be enforced if either the minChars or maxBoxes conditions are met, making it possible to exclude detections using replacements if they are either short, or combined from many boxes.

  • direction_delta (float | None) – Maximum angle between the direction of two text boxes for them to be connected. Directions are currently multiples of 90 degrees.

  • direction_weights (DirectionWeights | dict[str, Any] | None) – Direction weights that control how far subsequent ocr text boxes can be from another in a particular direction and still be combined into the same detection. Lower value means larger distance is allowed. The direction is relative to the text orientation.

  • min_fuzzy_score (float | None) – For each detection, this controls to which degree characters can be replaced from the OCR text with similar characters, e.g. I and 1. A value of 1 will disable character replacements entirely.

  • read_embedded_text (bool | None) – Read text embedded in the PDF file. If present, this text will override overlapping OCR text.

  • remove_leading_zeros (bool | None) – Disregard leading zeroes when matching tags (e.g. “A0001” will match “A1”)

  • substitutions (dict[str, list[str]] | None) – Override the default mapping of characters to an array of allowed substitute characters. The default mapping contains characters commonly confused by OCR. Provide your custom mapping in the format like so: {“0”: [“O”, “Q”], “1”: [“l”, “I”]}. This means: 0 (zero) is allowed to be replaced by uppercase letter O or Q, and 1 (one) is allowed to be replaced by lowercase letter l or uppercase letter I. No other replacements are allowed.

  • **params (Any) – Other parameters. The parameter name will be converted to camel case but the value will be passed as is.

Example

Configure a call to digrams detect endpoint:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.contextualization import ConnectionFlags, DiagramDetectConfig
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> config = DiagramDetectConfig(
...     remove_leading_zeros=True,
...     connection_flags=ConnectionFlags(
...         no_text_inbetween=True,
...         natural_reading_order=True,
...     )
... )
>>> job = client.diagrams.detect(entities=[{"name": "A1"}], file_id=123, config=config)

If you want to use an undocumented parameter, you can pass it as a keyword argument:

>>> config_with_undoducmented_params = DiagramDetectConfig(
...     remove_leading_zeros=True,
...     connection_flags=ConnectionFlags(new_undocumented_flag=True),
...     new_undocumented_param={"can_be_anything": True},
... )
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DiagramDetectItem(
file_id: int,
file_external_id: str | None,
file_instance_id: dict[str, str] | None,
annotations: list[dict[str, Any]] | None,
page_range: dict[str, int] | None,
page_count: int | None,
)

Bases: CogniteResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

final class cognite.client.data_classes.contextualization.DiagramDetectResults(
job_id: int,
status: str,
status_time: int,
created_time: int,
items: list[DiagramDetectItem],
start_time: int,
error_message: str | None,
)

Bases: ContextualizationJob

convert() DiagramConvertResults

Convert a P&ID to an interactive SVG where the provided annotations are highlighted

async convert_async() DiagramConvertResults

Convert a P&ID to an interactive SVG where the provided annotations are highlighted

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

property errors: list[str]

Get the errors from the diagram detection job.

get_errors() list[str]

Returns a list of all error messages across files. Will wait for results if not available.

async get_errors_async() list[str]

Returns a list of all error messages across files. Will wait for results if not available.

get_result() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

async get_result_async() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

property result: dict[str, Any]

Get the result of the diagram detection job.

set_client_ref(client: AsyncCogniteClient) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

update_status() str
async update_status_async() str
wait_for_completion(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.DialGaugeDetection(
threshold: 'float | None' = None,
min_level: 'float | None' = None,
max_level: 'float | None' = None,
dead_angle: 'float | None' = None,
non_linear_angle: 'float | None' = None,
)

Bases: VisionResource, ThresholdParameter

dead_angle: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

max_level: float | None = None
min_level: float | None = None
non_linear_angle: float | None = None
threshold: float | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DigitalGaugeDetection(
threshold: 'float | None' = None,
comma_position: 'int | None' = None,
min_num_digits: 'int | None' = None,
max_num_digits: 'int | None' = None,
)

Bases: VisionResource, ThresholdParameter

comma_position: int | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

max_num_digits: int | None = None
min_num_digits: int | None = None
threshold: float | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.DirectionWeights(
left: float | None = None,
right: float | None = None,
up: float | None = None,
down: float | None = None,
)

Bases: CogniteResource

Direction weights for the text graph that control how far text boxes can be one from another in a particular direction before they are no longer connected in the same graph. Lower value means larger distance is allowed.

Parameters:
  • left (float | None) – Weight for the connection towards text boxes to the left.

  • right (float | None) – Weight for the connection towards text boxes to the right.

  • up (float | None) – Weight for the connection towards text boxes above.

  • down (float | None) – Weight for the connection towards text boxes below.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.EntityMatchingModel(
id: int,
created_time: int,
status: str | None = None,
error_message: str | None = None,
start_time: int | None = None,
status_time: int | None = None,
classifier: str | None = None,
feature_type: str | None = None,
match_fields: list[str] | None = None,
model_type: str | None = None,
name: str | None = None,
description: str | None = None,
external_id: str | None = None,
)

Bases: CogniteResourceWithClientRef

Entity matching model. See the fit method for the meaning of these fields.

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

predict(
sources: list[dict] | None = None,
targets: list[dict] | None = None,
num_matches: int = 1,
score_threshold: float | None = None,
) EntityMatchingPredictionResult

Predict entity matching.

Note

Blocks and waits for the model to be ready if it has been recently created.

Parameters:
  • sources (list[dict] | None) – entities to match from, does not need an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). If omitted, will use data from fit.

  • targets (list[dict] | None) – entities to match to, does not need an ‘id’ field. Tolerant to passing more than is needed or used. If omitted, will use data from fit.

  • num_matches (int) – number of matches to return for each item.

  • score_threshold (float | None) – only return matches with a score above this threshold

Returns:

object which can be used to wait for and retrieve results.

Return type:

EntityMatchingPredictionResult

async predict_async(
sources: list[dict] | None = None,
targets: list[dict] | None = None,
num_matches: int = 1,
score_threshold: float | None = None,
) EntityMatchingPredictionResult

Predict entity matching.

Note

Blocks and waits for the model to be ready if it has been recently created.

Parameters:
  • sources (list[dict] | None) – entities to match from, does not need an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). If omitted, will use data from fit.

  • targets (list[dict] | None) – entities to match to, does not need an ‘id’ field. Tolerant to passing more than is needed or used. If omitted, will use data from fit.

  • num_matches (int) – number of matches to return for each item.

  • score_threshold (float | None) – only return matches with a score above this threshold

Returns:

object which can be used to wait for and retrieve results.

Return type:

EntityMatchingPredictionResult

refit(
true_matches: Sequence[dict | tuple[int | str, int | str]],
) EntityMatchingModel

Re-fits an entity matching model, using the combination of the old and new true matches.

Parameters:

true_matches (Sequence[dict | tuple[int | str, int | str]]) – Updated known valid matches given as a list of dicts with keys ‘fromId’, ‘fromExternalId’, ‘toId’, ‘toExternalId’). A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.

Returns:

new model refitted to true_matches.

Return type:

EntityMatchingModel

async refit_async(
true_matches: Sequence[dict | tuple[int | str, int | str]],
) EntityMatchingModel

Re-fits an entity matching model, using the combination of the old and new true matches.

Parameters:

true_matches (Sequence[dict | tuple[int | str, int | str]]) – Updated known valid matches given as a list of dicts with keys ‘fromId’, ‘fromExternalId’, ‘toId’, ‘toExternalId’). A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.

Returns:

new model refitted to true_matches.

Return type:

EntityMatchingModel

set_client_ref(client: AsyncCogniteClient) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

update_status() str

Updates the model status and returns it

async update_status_async() str

Updates the model status and returns it

wait_for_completion(
timeout: int | None = None,
interval: int = 10,
) None

Waits for model completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (int) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: int | None = None,
interval: int = 10,
) None

Waits for model completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (int) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.EntityMatchingModelList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceListWithClientRef[EntityMatchingModel], IdTransformerMixin

append(item)

S.append(value) – append value to the end of the sequence

as_external_ids() list[str]

Returns the external ids of all resources.

Raises:

ValueError – If any resource in the list does not have an external id.

Returns:

The external ids of all resources in the list.

Return type:

list[str]

as_ids() list[int]

Returns the ids of all resources.

Raises:

ValueError – If any resource in the list does not have an id.

Returns:

The ids of all resources in the list.

Return type:

list[int]

clear() None -- remove all items from S
copy()
count(
value,
) integer -- return number of occurrences of value
dump(
camel_case: bool = True,
) list[dict[str, Any]]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A list of dicts representing the instance.

Return type:

list[dict[str, Any]]

dump_raw(
camel_case: bool = True,
) dict[str, Any]

This method dumps the list with extra information in addition to the items.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the list.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instances into a YAML formatted string.

Returns:

A YAML formatted string representing the instances.

Return type:

str

extend(
other: Iterable[Any],
) None

S.extend(iterable) – extend sequence by appending elements from the iterable

get(
id: int | None = None,
external_id: str | None = None,
instance_id: InstanceId | tuple[str, str] | None = None,
) T_CogniteResource | None

Get an item from this list by id, external_id or instance_id.

Parameters:
  • id (int | None) – The id of the item to get.

  • external_id (str | None) – The external_id of the item to get.

  • instance_id (InstanceId | tuple[str, str] | None) – The instance_id of the item to get.

Returns:

The requested item if present, otherwise None.

Return type:

T_CogniteResource | None

index(
value[,
start[,
stop,]]
) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

classmethod load(
resource: Sequence[dict[str, Any]] | str,
) Self

Load a resource from a YAML/JSON string or iterable of dict.

pop(
[index,]
) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

set_client_ref(client: AsyncCogniteClient) Self
sort(*args, **kwds)
to_pandas(
camel_case: bool = False,
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.

Parameters:
  • camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

  • expand_metadata (bool) – Expand the metadata column into separate columns.

  • metadata_prefix (str) – Prefix to use for metadata columns.

  • convert_timestamps (bool) – Convert known columns storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The Cognite resource as a dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.EntityMatchingModelUpdate(id: int | None = None, external_id: str | None = None)

Bases: CogniteUpdate

Changes applied to entity matching model

Parameters:
  • id (int) – A server-generated ID for the object.

  • external_id (str) – The external ID provided by the client. Must be unique for the resource type.

property description: _PrimitiveUpdate
dump(
camel_case: Literal[True] = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (Literal[True]) – No description.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

property name: _PrimitiveUpdate
final class cognite.client.data_classes.contextualization.EntityMatchingPredictionResult(
job_id: int,
status: str,
status_time: int,
created_time: int,
start_time: int,
error_message: str | None,
)

Bases: ContextualizationJob

dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

get_result() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

async get_result_async() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

classmethod load(
resource: dict | str,
) Self

Load a resource from a YAML/JSON string or dict.

set_client_ref(
client: AsyncCogniteClient,
) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

update_status() str

Updates the model status and returns it

async update_status_async() str

Updates the model status and returns it

wait_for_completion(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.FeatureParameters(
text_detection_parameters: 'TextDetectionParameters | None' = None,
asset_tag_detection_parameters: 'AssetTagDetectionParameters | None' = None,
people_detection_parameters: 'PeopleDetectionParameters | None' = None,
industrial_object_detection_parameters: 'IndustrialObjectDetectionParameters | None' = None,
personal_protective_equipment_detection_parameters: 'PersonalProtectiveEquipmentDetectionParameters | None' = None,
digital_gauge_detection_parameters: 'DigitalGaugeDetection | None' = None,
dial_gauge_detection_parameters: 'DialGaugeDetection | None' = None,
level_gauge_detection_parameters: 'LevelGaugeDetection | None' = None,
valve_detection_parameters: 'ValveDetection | None' = None,
)

Bases: VisionResource

asset_tag_detection_parameters: AssetTagDetectionParameters | None = None
dial_gauge_detection_parameters: DialGaugeDetection | None = None
digital_gauge_detection_parameters: DigitalGaugeDetection | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

industrial_object_detection_parameters: IndustrialObjectDetectionParameters | None = None
level_gauge_detection_parameters: LevelGaugeDetection | None = None
classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

people_detection_parameters: PeopleDetectionParameters | None = None
personal_protective_equipment_detection_parameters: PersonalProtectiveEquipmentDetectionParameters | None = None
text_detection_parameters: TextDetectionParameters | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

valve_detection_parameters: ValveDetection | None = None
class cognite.client.data_classes.contextualization.FileReference(
file_id: int | None = None,
file_external_id: str | None = None,
file_instance_id: NodeId | None = None,
first_page: int | None = None,
last_page: int | None = None,
)

Bases: object

to_api_item() dict[str, str | int | dict[str, int] | dict[str, str]]
class cognite.client.data_classes.contextualization.IndustrialObjectDetectionParameters(threshold: 'float | None' = None)

Bases: VisionResource, ThresholdParameter

dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(
resource: dict | str,
) Self

Load a resource from a YAML/JSON string or dict.

threshold: float | None = None
to_pandas(
camel_case: bool = False,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.JobStatus(value)

Bases: Enum

An enumeration.

COLLECTING = 'Collecting'
COMPLETED = 'Completed'
DISTRIBUTED = 'Distributed'
DISTRIBUTING = 'Distributing'
FAILED = 'Failed'
QUEUED = 'Queued'
RUNNING = 'Running'
is_finished() bool
is_not_finished() bool
class cognite.client.data_classes.contextualization.LevelGaugeDetection(
threshold: 'float | None' = None,
min_level: 'float | None' = None,
max_level: 'float | None' = None,
)

Bases: VisionResource, ThresholdParameter

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

max_level: float | None = None
min_level: float | None = None
threshold: float | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.PeopleDetectionParameters(threshold: 'float | None' = None)

Bases: VisionResource, ThresholdParameter

dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

threshold: float | None = None
to_pandas(
camel_case: bool = False,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.PersonalProtectiveEquipmentDetectionParameters(threshold: 'float | None' = None)

Bases: VisionResource, ThresholdParameter

dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(
resource: dict | str,
) Self

Load a resource from a YAML/JSON string or dict.

threshold: float | None = None
to_pandas(
camel_case: bool = False,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.ResourceReference(
id: int | None = None,
external_id: str | None = None,
cognite_client: None | AsyncCogniteClient = None,
)

Bases: CogniteResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.ResourceReferenceList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[ResourceReference], IdTransformerMixin

append(item)

S.append(value) – append value to the end of the sequence

as_external_ids() list[str]

Returns the external ids of all resources.

Raises:

ValueError – If any resource in the list does not have an external id.

Returns:

The external ids of all resources in the list.

Return type:

list[str]

as_ids() list[int]

Returns the ids of all resources.

Raises:

ValueError – If any resource in the list does not have an id.

Returns:

The ids of all resources in the list.

Return type:

list[int]

clear() None -- remove all items from S
copy()
count(
value,
) integer -- return number of occurrences of value
dump(
camel_case: bool = True,
) list[dict[str, Any]]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A list of dicts representing the instance.

Return type:

list[dict[str, Any]]

dump_raw(
camel_case: bool = True,
) dict[str, Any]

This method dumps the list with extra information in addition to the items.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the list.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instances into a YAML formatted string.

Returns:

A YAML formatted string representing the instances.

Return type:

str

extend(
other: Iterable[Any],
) None

S.extend(iterable) – extend sequence by appending elements from the iterable

get(
id: int | None = None,
external_id: str | None = None,
instance_id: InstanceId | tuple[str, str] | None = None,
) T_CogniteResource | None

Get an item from this list by id, external_id or instance_id.

Parameters:
  • id (int | None) – The id of the item to get.

  • external_id (str | None) – The external_id of the item to get.

  • instance_id (InstanceId | tuple[str, str] | None) – The instance_id of the item to get.

Returns:

The requested item if present, otherwise None.

Return type:

T_CogniteResource | None

index(
value[,
start[,
stop,]]
) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

classmethod load(
resource: Sequence[dict[str, Any]] | str,
) Self

Load a resource from a YAML/JSON string or iterable of dict.

pop(
[index,]
) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

sort(*args, **kwds)
to_pandas(
camel_case: bool = False,
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.

Parameters:
  • camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

  • expand_metadata (bool) – Expand the metadata column into separate columns.

  • metadata_prefix (str) – Prefix to use for metadata columns.

  • convert_timestamps (bool) – Convert known columns storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The Cognite resource as a dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.TextDetectionParameters(threshold: 'float | None' = None)

Bases: VisionResource, ThresholdParameter

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

threshold: float | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.ThresholdParameter(threshold: 'float | None' = None)

Bases: object

threshold: float | None = None
class cognite.client.data_classes.contextualization.ValveDetection(threshold: 'float | None' = None)

Bases: VisionResource, ThresholdParameter

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

threshold: float | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.contextualization.VisionExtractItem(
file_id: int,
predictions: VisionExtractPredictions,
file_external_id: str | None,
error_message: str | None,
)

Bases: CogniteResource

Data class for storing predictions for a single image file

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

final class cognite.client.data_classes.contextualization.VisionExtractJob(
job_id: int,
status: str,
status_time: int,
created_time: int,
items: list[VisionExtractItem],
start_time: int | None,
error_message: str | None,
)

Bases: ContextualizationJob, Generic[P]

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

get_errors() list[str]

Returns a list of all error messages across files. Will wait for results if not available.

async get_errors_async() list[str]

Returns a list of all error messages across files. Will wait for results if not available.

get_result() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

async get_result_async() dict[str, Any]

Returns results if available, else waits for the job to finish, then returns the results.

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

save_predictions(
creating_user: str,
creating_app: str | None = None,
creating_app_version: str | None = None,
) Annotation | AnnotationList

Saves all predictions made by the feature extractors in CDF using the Annotations API. See https://docs.cognite.com/api/v1/#operation/annotationsSuggest

Parameters:
  • creating_user (str) – (str, optional): A username, or email, or name.

  • creating_app (str | None) – The name of the app from which this annotation was created. Defaults to ‘cognite-sdk-python’.

  • creating_app_version (str | None) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string. Defaults to client version.

Returns:

(suggested) annotation(s) stored in CDF.

Return type:

Annotation | AnnotationList

async save_predictions_async(
creating_user: str,
creating_app: str | None = None,
creating_app_version: str | None = None,
) Annotation | AnnotationList

Saves all predictions made by the feature extractors in CDF using the Annotations API. See https://docs.cognite.com/api/v1/#operation/annotationsSuggest

Parameters:
  • creating_user (str) – (str, optional): A username, or email, or name.

  • creating_app (str | None) – The name of the app from which this annotation was created. Defaults to ‘cognite-sdk-python’.

  • creating_app_version (str | None) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string. Defaults to client version.

Returns:

(suggested) annotation(s) stored in CDF.

Return type:

Annotation | AnnotationList

set_client_ref(client: AsyncCogniteClient) Self
to_pandas(
expand_metadata: bool = False,
metadata_prefix: str = 'metadata.',
ignore: list[str] | None = None,
camel_case: bool = False,
convert_timestamps: bool = True,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand_metadata (bool) – Expand the metadata into separate rows (default: False).

  • metadata_prefix (str) – Prefix to use for the metadata rows, if expanded.

  • ignore (list[str] | None) – List of row keys to skip when converting to a data frame. Is applied before expansions.

  • camel_case (bool) – Convert attribute names to camel case (e.g. externalId instead of external_id). Does not affect custom data like metadata if expanded.

  • convert_timestamps (bool) – Convert known attributes storing CDF timestamps (milliseconds since epoch) to datetime. Does not affect custom data like metadata.

Returns:

The dataframe.

Return type:

pandas.DataFrame

update_status() str
async update_status_async() str
wait_for_completion(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

async wait_for_completion_async(
timeout: float | None = None,
interval: float = 10,
) None

Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.

Parameters:
  • timeout (float | None) – Time out after this many seconds. (None means wait indefinitely)

  • interval (float) – Influence how often to poll status (seconds).

Raises:

CogniteModelFailedError – The model fit failed.

class cognite.client.data_classes.contextualization.VisionExtractPredictions(
text_predictions: 'list[TextRegion] | None' = None,
asset_tag_predictions: 'list[AssetLink] | None' = None,
industrial_object_predictions: 'list[ObjectDetection] | None' = None,
people_predictions: 'list[ObjectDetection] | None' = None,
personal_protective_equipment_predictions: 'list[ObjectDetection] | None' = None,
digital_gauge_predictions: 'list[ObjectDetection] | None' = None,
dial_gauge_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None,
level_gauge_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None,
valve_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None,
)

Bases: VisionResource

asset_tag_predictions: list[AssetLink] | None = None
dial_gauge_predictions: list[KeypointCollectionWithObjectDetection] | None = None
digital_gauge_predictions: list[ObjectDetection] | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

industrial_object_predictions: list[ObjectDetection] | None = None
level_gauge_predictions: list[KeypointCollectionWithObjectDetection] | None = None
classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

people_predictions: list[ObjectDetection] | None = None
personal_protective_equipment_predictions: list[ObjectDetection] | None = None
text_predictions: list[TextRegion] | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

valve_predictions: list[KeypointCollectionWithObjectDetection] | None = None
class cognite.client.data_classes.contextualization.VisionFeature(value)

Bases: str, Enum

An enumeration.

ASSET_TAG_DETECTION = 'AssetTagDetection'
DIAL_GAUGE_DETECTION = 'DialGaugeDetection'
DIGITAL_GAUGE_DETECTION = 'DigitalGaugeDetection'
INDUSTRIAL_OBJECT_DETECTION = 'IndustrialObjectDetection'
LEVEL_GAUGE_DETECTION = 'LevelGaugeDetection'
PEOPLE_DETECTION = 'PeopleDetection'
PERSONAL_PROTECTIVE_EQUIPMENT_DETECTION = 'PersonalProtectiveEquipmentDetection'
TEXT_DETECTION = 'TextDetection'
VALVE_DETECTION = 'ValveDetection'
classmethod beta_features() set[VisionFeature]

Returns a set of VisionFeature’s that are currently in beta

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

Bases: VisionResource

asset_ref: CdfResourceRef
confidence: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

text: str
text_region: BoundingBox
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.images.KeypointCollection(
label: 'str',
keypoints: 'dict[str, Keypoint]',
attributes: 'dict[str, Attribute] | None' = None,
confidence: 'float | None' = None,
)

Bases: VisionResource

attributes: dict[str, Attribute] | None = None
confidence: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

keypoints: dict[str, Keypoint]
label: str
classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.images.KeypointCollectionWithObjectDetection(
object_detection: 'ObjectDetection',
keypoint_collection: 'KeypointCollection',
)

Bases: VisionResource

dump(
camel_case: bool = True,
) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

keypoint_collection: KeypointCollection
classmethod load(
resource: dict | str,
) Self

Load a resource from a YAML/JSON string or dict.

object_detection: ObjectDetection
to_pandas(
camel_case: bool = False,
) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.images.ObjectDetection(
label: 'str',
confidence: 'float | None' = None,
attributes: 'dict[str, Attribute] | None' = None,
bounding_box: 'BoundingBox | None' = None,
polygon: 'Polygon | None' = None,
polyline: 'Polyline | None' = None,
)

Bases: VisionResource

attributes: dict[str, Attribute] | None = None
bounding_box: BoundingBox | None = None
confidence: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

label: str
classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

polygon: Polygon | None = None
polyline: Polyline | None = None
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.images.TextRegion(
text: 'str',
text_region: 'BoundingBox',
confidence: 'float | None' = None,
)

Bases: VisionResource

confidence: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

text: str
text_region: BoundingBox
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.primitives.Attribute(
type: "Literal['boolean', 'numerical']",
value: 'bool | float',
description: 'str | None' = None,
)

Bases: VisionResource

description: str | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

type: Literal['boolean', 'numerical']
value: bool | float
class cognite.client.data_classes.annotation_types.primitives.BoundingBox(x_min: 'float', x_max: 'float', y_min: 'float', y_max: 'float')

Bases: VisionResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

x_max: float
x_min: float
y_max: float
y_min: float
class cognite.client.data_classes.annotation_types.primitives.CdfResourceRef(id: 'int | None' = None, external_id: 'str | None' = None)

Bases: VisionResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

external_id: str | None = None
id: int | None = None
classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.primitives.Keypoint(point: 'Point', confidence: 'float | None' = None)

Bases: VisionResource

confidence: float | None = None
dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

point: Point
to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

class cognite.client.data_classes.annotation_types.primitives.Point(x: 'float', y: 'float')

Bases: VisionResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

x: float
y: float
class cognite.client.data_classes.annotation_types.primitives.Polygon(vertices: 'list[Point]')

Bases: VisionResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

vertices: list[Point]
class cognite.client.data_classes.annotation_types.primitives.Polyline(vertices: 'list[Point]')

Bases: VisionResource

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame

vertices: list[Point]
class cognite.client.data_classes.annotation_types.primitives.VisionResource

Bases: CogniteResource, ABC

dump(camel_case: bool = True) dict[str, Any]

Dump the instance into a json serializable Python data type.

Parameters:

camel_case (bool) – Use camelCase for attribute names. Defaults to True.

Returns:

A dictionary representation of the instance.

Return type:

dict[str, Any]

dump_yaml() str

Dump the instance into a YAML formatted string.

Returns:

A YAML formatted string representing the instance.

Return type:

str

classmethod load(resource: dict | str) Self

Load a resource from a YAML/JSON string or dict.

to_pandas(camel_case: bool = False) pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:

camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)

Returns:

The dataframe.

Return type:

pandas.DataFrame