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
- EntityMatchingAPI.fit(sources: Sequence[dict | cognite.client.data_classes._base.CogniteResource], targets: Sequence[dict | cognite.client.data_classes._base.CogniteResource], true_matches: Optional[Sequence[dict | tuple[int | str, int | str]]] = None, match_fields: Optional[Union[dict, Sequence[tuple[str, str]]]] = None, feature_type: Optional[str] = None, classifier: Optional[str] = None, ignore_missing_fields: bool = False, name: Optional[str] = None, description: Optional[str] = None, external_id: Optional[str] = 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
Example
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> 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
- EntityMatchingAPI.refit(true_matches: Sequence[dict | tuple[int | str, int | str]], id: Optional[int] = None, external_id: Optional[str] = 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) – ids of the model to use.
external_id (str | None) – external ids of the model to use.
- Returns
new model refitted to true_matches.
- Return type
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> 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, description="AssetMatchingJob1", id=1)
Retrieve Entity Matching Models
- EntityMatchingAPI.retrieve(id: Optional[int] = None, external_id: Optional[str] = None) cognite.client.data_classes.contextualization.EntityMatchingModel | None
Retrieve model :param id: id of the model to retrieve. :type id: int | None :param external_id: external id of the model to retrieve. :type external_id: str | None
- Returns
Model requested.
- Return type
EntityMatchingModel | None
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> retrieved_model = client.entity_matching.retrieve(id=1)
- EntityMatchingAPI.retrieve_multiple(ids: Optional[Sequence[int]] = None, external_ids: Optional[SequenceNotStr[str]] = None) EntityMatchingModelList
-
- 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
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> retrieved_models = client.entity_matching.retrieve_multiple([1,2,3])
- EntityMatchingAPI.list(name: Optional[str] = None, description: Optional[str] = None, original_id: Optional[int] = None, feature_type: Optional[str] = None, classifier: Optional[str] = None, limit: int | None = 25) EntityMatchingModelList
-
- 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
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> client.entity_matching.list(limit=1, name="test")
Delete Entity Matching Models
- EntityMatchingAPI.delete(id: Optional[Union[int, Sequence[int]]] = None, external_id: Optional[Union[str, SequenceNotStr[str]]] = None) None
-
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 >>> client = CogniteClient() >>> client.entity_matching.delete(id=1)
Update Entity Matching Models
- EntityMatchingAPI.update(item: cognite.client.data_classes.contextualization.EntityMatchingModel | cognite.client.data_classes.contextualization.EntityMatchingModelUpdate | collections.abc.Sequence[cognite.client.data_classes.contextualization.EntityMatchingModel | cognite.client.data_classes.contextualization.EntityMatchingModelUpdate], mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null') cognite.client.data_classes.contextualization.EntityMatchingModelList | cognite.client.data_classes.contextualization.EntityMatchingModel
-
- 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
Examples
>>> from cognite.client.data_classes.contextualization import EntityMatchingModelUpdate >>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> client.entity_matching.update(EntityMatchingModelUpdate(id=1).name.set("New name"))
Predict Using an Entity Matching Model
- EntityMatchingAPI.predict(sources: Optional[Sequence[dict]] = None, targets: Optional[Sequence[dict]] = None, num_matches: int = 1, score_threshold: Optional[float] = None, id: Optional[int] = None, external_id: Optional[str] = None) ContextualizationJob
-
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) – ids of the model to use.
external_id (str | None) – external ids of the model to use.
- Returns
object which can be used to wait for and retrieve results.
- Return type
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> 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
- DiagramsAPI.detect(entities: Sequence[dict | cognite.client.data_classes._base.CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | collections.abc.Sequence[int] | None = None, file_external_ids: Optional[Union[str, SequenceNotStr[str]]] = None, file_instance_ids: cognite.client.data_classes.data_modeling.ids.NodeId | collections.abc.Sequence[cognite.client.data_classes.data_modeling.ids.NodeId] | None = None, file_references: list[cognite.client.data_classes.contextualization.FileReference] | cognite.client.data_classes.contextualization.FileReference | None = None, pattern_mode: bool = False, configuration: dict[str, Any] | None = None, *, multiple_jobs: Literal[False]) DiagramDetectResults
- DiagramsAPI.detect(entities: Sequence[dict | cognite.client.data_classes._base.CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | collections.abc.Sequence[int] | None = None, file_external_ids: Optional[Union[str, SequenceNotStr[str]]] = None, file_instance_ids: cognite.client.data_classes.data_modeling.ids.NodeId | collections.abc.Sequence[cognite.client.data_classes.data_modeling.ids.NodeId] | None = None, file_references: list[cognite.client.data_classes.contextualization.FileReference] | cognite.client.data_classes.contextualization.FileReference | None = None, pattern_mode: bool = False, configuration: cognite.client.data_classes.contextualization.DiagramDetectConfig | dict[str, Any] | None = None, *, multiple_jobs: Literal[True]) tuple[cognite.client.data_classes.contextualization.DetectJobBundle | None, list[dict[str, Any]]]
- DiagramsAPI.detect(entities: Sequence[dict | cognite.client.data_classes._base.CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | collections.abc.Sequence[int] | None = None, file_external_ids: Optional[Union[str, SequenceNotStr[str]]] = None, file_instance_ids: cognite.client.data_classes.data_modeling.ids.NodeId | collections.abc.Sequence[cognite.client.data_classes.data_modeling.ids.NodeId] | None = None, file_references: list[cognite.client.data_classes.contextualization.FileReference] | cognite.client.data_classes.contextualization.FileReference | None = None, pattern_mode: bool = False, configuration: cognite.client.data_classes.contextualization.DiagramDetectConfig | dict[str, Any] | None = None) DiagramDetectResults
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 | dict[str, Any] | 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 | None, 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() >>> 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.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
- DiagramsAPI.convert(detect_job: DiagramDetectResults) DiagramConvertResults
Convert a P&ID to interactive SVGs where the provided annotations are highlighted.
- Parameters
detect_job (DiagramDetectResults) – detect job
- Returns
Resulting queued job. Note that .result property of this job will block waiting for results.
- Return type
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> 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
- VisionAPI.extract(features: cognite.client.data_classes.contextualization.VisionFeature | list[cognite.client.data_classes.contextualization.VisionFeature], file_ids: Optional[list[int]] = None, file_external_ids: Optional[list[str]] = None, parameters: Optional[FeatureParameters] = 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
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() >>> 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
- 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
Examples
Retrieve a vision extract job by ID:
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> 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, cognite_client: CogniteClient | None = None) 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], cognite_client: CogniteClient | None = None) Self
- class cognite.client.data_classes.contextualization.ContextualizationJob(job_id: int | None = None, model_id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | None = None, start_time: int | None = None, status_time: int | None = None, status_path: str | None = None, job_token: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
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
- classmethod load(resource: dict | str, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) None
Waits for job 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) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.ContextualizationJobList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[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: Optional[int] = None, external_id: Optional[str] = None, instance_id: Optional[Union[InstanceId, tuple[str, str]]] = None) Optional[T_CogniteResource]
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: Iterable[dict[str, Any]] | str, cognite_client: CogniteClient | None = None) 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.ContextualizationJobType(value)
Bases:
Enum
An enumeration.
- DIAGRAMS = 'diagrams'
- ENTITY_MATCHING = 'entity_matching'
- VISION = 'vision'
- class cognite.client.data_classes.contextualization.CustomizeFuzziness(fuzzy_score: Optional[float] = None, max_boxes: Optional[int] = None, min_chars: Optional[int] = None)
Bases:
CogniteObject
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, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- class cognite.client.data_classes.contextualization.DetectJobBundle(job_ids: list[int], cognite_client: CogniteClient | None = None)
Bases:
object
- fetch_results() list[dict[str, Any]]
- property result: tuple[list[dict[str, Any]], list[dict[str, Any]]]
Waits for the job to finish and returns the results.
- wait_for_completion(timeout: Optional[int] = 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 | None = None, file_external_id: str | None = None, results: list | None = None, cognite_client: CogniteClient | None = 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, cognite_client: CogniteClient | None = None) 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 | None = None, png_url: str | None = None, svg_url: str | None = None, cognite_client: CogniteClient | None = 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, cognite_client: CogniteClient | None = None) 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: Iterable[Any], cognite_client: CogniteClient | None = None)
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: Optional[int] = None, external_id: Optional[str] = None, instance_id: Optional[Union[InstanceId, tuple[str, str]]] = None) Optional[T_CogniteResource]
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: Iterable[dict[str, Any]] | str, cognite_client: CogniteClient | None = None) 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.DiagramConvertResults(**kwargs: Any)
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
- property items: list[cognite.client.data_classes.contextualization.DiagramConvertItem] | None
returns a list of all results by file
- classmethod load(resource: dict | str, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) None
Waits for job 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) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.DiagramDetectConfig(annotation_extract: Optional[bool] = None, case_sensitive: Optional[bool] = None, connection_flags: Optional[Union[ConnectionFlags, list[str]]] = None, customize_fuzziness: Optional[Union[CustomizeFuzziness, dict[str, Any]]] = None, direction_delta: Optional[float] = None, direction_weights: Optional[Union[DirectionWeights, dict[str, Any]]] = None, min_fuzzy_score: Optional[float] = None, read_embedded_text: Optional[bool] = None, remove_leading_zeros: Optional[bool] = None, substitutions: Optional[dict[str, list[str]]] = None, **params: Any)
Bases:
CogniteObject
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() >>> 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, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- class cognite.client.data_classes.contextualization.DiagramDetectItem(file_id: int | None = None, file_external_id: str | None = None, file_instance_id: dict[str, str] | None = None, annotations: list | None = None, error_message: str | None = None, cognite_client: CogniteClient | None = None, page_range: dict[str, int] | None = None, page_count: int | None = 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, cognite_client: CogniteClient | None = None) 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.contextualization.DiagramDetectResults(**kwargs: Any)
Bases:
ContextualizationJob
- convert() 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]
Returns a list of all error messages across files
- property items: list[cognite.client.data_classes.contextualization.DiagramDetectItem] | None
Returns a list of all results by file
- classmethod load(resource: dict | str, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) None
Waits for job 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) – Poll status every this many seconds.
- Raises
ModelFailedException – 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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: Optional[float] = None, right: Optional[float] = None, up: Optional[float] = None, down: Optional[float] = None)
Bases:
CogniteObject
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, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- class cognite.client.data_classes.contextualization.EntityMatchingModel(id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | 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, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
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, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- predict(sources: Optional[list[dict]] = None, targets: Optional[list[dict]] = None, num_matches: int = 1, score_threshold: Optional[float] = None) ContextualizationJob
Predict entity matching. NB. 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
- 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
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) 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) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.EntityMatchingModelList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[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: Optional[int] = None, external_id: Optional[str] = None, instance_id: Optional[Union[InstanceId, tuple[str, str]]] = None) Optional[T_CogniteResource]
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: Iterable[dict[str, Any]] | str, cognite_client: CogniteClient | None = None) 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.EntityMatchingModelUpdate(id: Optional[int] = None, external_id: Optional[str] = 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
- 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, cognite_client: CogniteClient | None = None) 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: Optional[int] = None, file_external_id: Optional[str] = None, file_instance_id: Optional[NodeId] = None, first_page: Optional[int] = None, last_page: Optional[int] = 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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 | CogniteClient = 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, cognite_client: CogniteClient | None = None) 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: Iterable[Any], cognite_client: CogniteClient | None = None)
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: Optional[int] = None, external_id: Optional[str] = None, instance_id: Optional[Union[InstanceId, tuple[str, str]]] = None) Optional[T_CogniteResource]
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: Iterable[dict[str, Any]] | str, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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 | None = None, predictions: dict[str, Any] | None = None, file_external_id: str | None = None, error_message: str | None = None, cognite_client: CogniteClient | None = 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, cognite_client: CogniteClient | None = None) 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.VisionExtractJob(*args: Any, **kwargs: Any)
Bases:
VisionJob
- 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]
Returns a list of all error messages across files
- property items: list[cognite.client.data_classes.contextualization.VisionExtractItem] | None
Returns a list of all predictions by file
- classmethod load(resource: dict | str, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- save_predictions(creating_user: Optional[str] = None, creating_app: Optional[str] = None, creating_app_version: Optional[str] = None) cognite.client.data_classes.annotations.Annotation | cognite.client.data_classes.annotations.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 | None) – (str, optional): A username, or email, or name. This is not checked nor enforced. If the value is None, it means the annotation was created by a service.
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
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) None
Waits for job 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) – Poll status every this many seconds.
- Raises
ModelFailedException – 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
- 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, cognite_client: CogniteClient | None = None) 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[cognite.client.data_classes.contextualization.VisionFeature]
Returns a set of VisionFeature’s that are currently in beta
- class cognite.client.data_classes.contextualization.VisionJob(job_id: int | None = None, model_id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | None = None, start_time: int | None = None, status_time: int | None = None, status_path: str | None = None, job_token: str | None = None, cognite_client: CogniteClient | None = 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
- classmethod load(resource: dict | str, cognite_client: CogniteClient | None = None) Self
Load a resource from a YAML/JSON string or dict.
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- 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
- wait_for_completion(timeout: Optional[int] = None, interval: int = 1) None
Waits for job 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) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.annotation_types.images.AssetLink(text: 'str', text_region: 'BoundingBox', asset_ref: 'CdfResourceRef', confidence: 'float | None' = None)
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, cognite_client: CogniteClient | None = None) 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
- 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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
- 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, cognite_client: CogniteClient | None = None) 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.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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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.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, cognite_client: CogniteClient | None = None) 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, cognite_client: CogniteClient | None = None) 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.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, cognite_client: CogniteClient | None = None) 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.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, cognite_client: CogniteClient | None = None) 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