Transformations

TransformationsAPI

Create transformations

TransformationsAPI.create(transformation: cognite.client.data_classes.transformations.Transformation | cognite.client.data_classes.transformations.TransformationWrite) Transformation
TransformationsAPI.create(transformation: collections.abc.Sequence[cognite.client.data_classes.transformations.Transformation] | collections.abc.Sequence[cognite.client.data_classes.transformations.TransformationWrite]) TransformationList

Create one or more transformations.

Parameters

transformation (Transformation | TransformationWrite | Sequence[Transformation] | Sequence[TransformationWrite]) – Transformation or list of transformations to create.

Returns

Created transformation(s)

Return type

Transformation | TransformationList

Examples

Create new transformations:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import TransformationWrite, TransformationDestination
>>> from cognite.client.data_classes.transformations.common import ViewInfo, EdgeType, DataModelInfo
>>> client = CogniteClient()
>>> transformations = [
>>>     TransformationWrite(
>>>         external_id="transformation1",
>>>         name="transformation1",
>>>         ignore_null_fields=False,
>>>         destination=TransformationDestination.assets()
>>>     ),
>>>     TransformationWrite(
>>>         external_id="transformation2",
>>>         name="transformation2",
>>>         ignore_null_fields=False,
>>>         destination=TransformationDestination.raw("myDatabase", "myTable")
>>>     ),
>>>      TransformationWrite(
>>>          external_id="transformation3",
>>>          name="transformation3",
>>>          ignore_null_fields=False,
>>>          view = ViewInfo(space="TypeSpace", external_id="TypeExtId", version="version"),
>>>          destination=TransformationDestination.nodes(view, "InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation4",
>>>          name="transformation4",
>>>          ignore_null_fields=False,
>>>          view = ViewInfo(space="TypeSpace", external_id="TypeExtId", version="version"),
>>>          destination=TransformationDestination.edges(view, "InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation5",
>>>          name="transformation5",
>>>          ignore_null_fields=False,
>>>          edge_type = EdgeType(space="TypeSpace", external_id="TypeExtId"),
>>>          destination=TransformationDestination.edges(edge_type,"InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation6",
>>>          name="transformation6",
>>>          ignore_null_fields=False,
>>>          data_model = DataModelInfo(space="modelSpace", external_id="modelExternalId",version="modelVersion",destination_type="viewExternalId"),
>>>          destination=TransformationDestination.instances(data_model,"InstanceSpace")
>>>      ),
>>>      TransformationWrite(
>>>          external_id="transformation7",
>>>          name="transformation7",
>>>          ignore_null_fields=False,
>>>          data_model = DataModelInfo(space="modelSpace", external_id="modelExternalId",version="modelVersion",destination_type="viewExternalId", destination_relationship_from_type="connectionPropertyName"),
>>>          destination=TransformationDestination.instances(data_model,"InstanceSpace")
>>>      ),
>>> ]
>>> res = client.transformations.create(transformations)

Retrieve transformations by id

TransformationsAPI.retrieve(id: Optional[int] = None, external_id: Optional[str] = None) cognite.client.data_classes.transformations.Transformation | None

Retrieve a single transformation by id.

Parameters
  • id (int | None) – ID

  • external_id (str | None) – No description.

Returns

Requested transformation or None if it does not exist.

Return type

Transformation | None

Examples

Get transformation by id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.retrieve(id=1)

Get transformation by external id:

>>> res = client.transformations.retrieve(external_id="1")
TransformationsAPI.retrieve_multiple(ids: Optional[Sequence[int]] = None, external_ids: Optional[SequenceNotStr[str]] = None, ignore_unknown_ids: bool = False) TransformationList

Retrieve multiple transformations.

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

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

  • ignore_unknown_ids (bool) – Ignore IDs and external IDs that are not found rather than throw an exception.

Returns

Requested transformation or None if it does not exist.

Return type

TransformationList

Examples

Get multiple transformations:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.retrieve_multiple(ids=[1,2,3], external_ids=['transform-1','transform-2'])

Run transformations by id

TransformationsAPI.run(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None, wait: bool = True, timeout: Optional[float] = None) TransformationJob

Run a transformation.

Parameters
  • transformation_id (int | None) – Transformation internal id

  • transformation_external_id (str | None) – Transformation external id

  • wait (bool) – Wait until the transformation run is finished. Defaults to True.

  • timeout (float | None) – maximum time (s) to wait, default is None (infinite time). Once the timeout is reached, it returns with the current status. Won’t have any effect if wait is False.

Returns

Created transformation job

Return type

TransformationJob

Examples

Run transformation to completion by id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>>
>>> res = client.transformations.run(transformation_id = 1)

Start running transformation by id:

>>>
>>> res = client.transformations.run(transformation_id = 1, wait = False)
async TransformationsAPI.run_async(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None, timeout: Optional[float] = None) TransformationJob

Run a transformation to completion asynchronously.

Parameters
  • transformation_id (int | None) – internal Transformation id

  • transformation_external_id (str | None) – external Transformation id

  • timeout (float | None) – maximum time (s) to wait, default is None (infinite time). Once the timeout is reached, it returns with the current status.

Returns

Completed (if finished) or running (if timeout reached) transformation job.

Return type

TransformationJob

Examples

Run transformation asynchronously by id:

>>> import asyncio
>>> from cognite.client import CogniteClient
>>>
>>> client = CogniteClient()
>>>
>>> async def run_transformation():
>>>     res = await client.transformations.run_async(id = 1)
>>>
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(run_transformation())
>>> loop.close()

Preview transformations

TransformationsAPI.preview(query: Optional[str] = None, convert_to_string: bool = False, limit: int | None = 100, source_limit: int | None = 100, infer_schema_limit: int | None = 10000, timeout: int | None = 240) TransformationPreviewResult

Preview the result of a query.

Parameters
  • query (str | None) – SQL query to run for preview.

  • convert_to_string (bool) – Stringify values in the query results, default is False.

  • limit (int | None) – Maximum number of rows to return in the final result, default is 100.

  • source_limit (int | None) – Maximum number of items to read from the data source or None to run without limit, default is 100.

  • infer_schema_limit (int | None) – Limit for how many rows that are used for inferring result schema, default is 10 000.

  • timeout (int | None) – Number of seconds to wait before cancelling a query. The default, and maximum, is 240.

Returns

Result of the executed query

Return type

TransformationPreviewResult

Examples

Preview transformation results as schema and list of rows:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>>
>>> query_result = client.transformations.preview(query="select * from _cdf.assets")

Preview transformation results as pandas dataframe:

>>>
>>> df = client.transformations.preview(query="select * from _cdf.assets").to_pandas()

Notice that the results are limited both by the limit and source_limit parameters. If you have a query that converts one source row to one result row, you may need to increase the source_limit. For example, given that you have a query that reads from a raw table with 10,903 rows

>>>
>>> result = client.transformations.preview(query="select * from my_raw_db.my_raw_table", limit=None)
>>> print(result.results)
100

To get all rows, you also need to set the source_limit to None:

>>>
>>> result = client.transformations.preview(query="select * from my_raw_db.my_raw_table", limit=None, source_limit=None)
>>> print(result.results)
10903

Cancel transformation run by id

TransformationsAPI.cancel(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None) None

Cancel a running transformation.

Parameters
  • transformation_id (int | None) – Transformation internal id

  • transformation_external_id (str | None) – Transformation external id

Examples

Wait transformation for 1 minute and cancel if still running:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import TransformationJobStatus
>>> client = CogniteClient()
>>>
>>> res = client.transformations.run(id = 1, timeout = 60.0)
>>> if res.status == TransformationJobStatus.RUNNING:
>>>     res.cancel()

List transformations

TransformationsAPI.list(include_public: bool = True, name_regex: Optional[str] = None, query_regex: Optional[str] = None, destination_type: Optional[str] = None, conflict_mode: Optional[str] = None, cdf_project_name: Optional[str] = None, has_blocked_error: Optional[bool] = None, created_time: Optional[Union[dict[str, Any], TimestampRange]] = None, last_updated_time: Optional[Union[dict[str, Any], TimestampRange]] = None, data_set_ids: Optional[Union[int, list[int]]] = None, data_set_external_ids: Optional[Union[str, list[str]]] = None, tags: Optional[TagsFilter] = None, limit: int | None = 25) TransformationList

List all transformations.

Parameters
  • include_public (bool) – Whether public transformations should be included in the results. (default true).

  • name_regex (str | None) – Regex expression to match the transformation name

  • query_regex (str | None) – Regex expression to match the transformation query

  • destination_type (str | None) – Transformation destination resource name to filter by.

  • conflict_mode (str | None) – Filters by a selected transformation action type: abort/create, upsert, update, delete

  • cdf_project_name (str | None) – Project name to filter by configured source and destination project

  • has_blocked_error (bool | None) – Whether only the blocked transformations should be included in the results.

  • created_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps

  • last_updated_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps

  • data_set_ids (int | list[int] | None) – Return only transformations in the specified data sets with these id(s).

  • data_set_external_ids (str | list[str] | None) – Return only transformations in the specified data sets with these external id(s).

  • tags (TagsFilter | None) – Return only the resource matching the specified tags constraints. It only supports ContainsAny as of now.

  • limit (int | None) – Limits the number of results to be returned. To retrieve all results use limit=-1, default limit is 25.

Returns

List of transformations

Return type

TransformationList

Example

List transformations:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> transformations_list = client.transformations.list()

Update transformations

TransformationsAPI.update(item: cognite.client.data_classes.transformations.Transformation | cognite.client.data_classes.transformations.TransformationWrite | cognite.client.data_classes.transformations.TransformationUpdate, mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null') Transformation
TransformationsAPI.update(item: Sequence[cognite.client.data_classes.transformations.Transformation | cognite.client.data_classes.transformations.TransformationWrite | cognite.client.data_classes.transformations.TransformationUpdate], mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null') TransformationList

Update one or more transformations

Parameters
  • item (Transformation | TransformationWrite | TransformationUpdate | Sequence[Transformation | TransformationWrite | TransformationUpdate]) – Transformation(s) to update

  • mode (Literal['replace_ignore_null', 'patch', 'replace']) – How to update data when a non-update object is given (Transformation or -Write). 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

Updated transformation(s)

Return type

Transformation | TransformationList

Examples

Update a transformation that you have fetched. This will perform a full update of the transformation:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> transformation = client.transformations.retrieve(id=1)
>>> transformation.query = "SELECT * FROM _cdf.assets"
>>> res = client.transformations.update(transformation)

Perform a partial update on a transformation, updating the query and making it private:

>>> from cognite.client.data_classes import TransformationUpdate
>>> my_update = TransformationUpdate(id=1).query.set("SELECT * FROM _cdf.assets").is_public.set(False)
>>> res = client.transformations.update(my_update)

Update the session used for reading (source) and writing (destination) when authenticating for all transformations in a given data set:

>>> from cognite.client.data_classes import NonceCredentials
>>> to_update = client.transformations.list(data_set_external_ids=["foo"])
>>> new_session = client.iam.sessions.create()
>>> new_nonce = NonceCredentials(
...     session_id=new_session.id,
...     nonce=new_session.nonce,
...     cdf_project_name=client.config.project
... )
>>> for tr in to_update:
...     tr.source_nonce = new_nonce
...     tr.destination_nonce = new_nonce
>>> res = client.transformations.update(to_update)

Delete transformations

TransformationsAPI.delete(id: Optional[Union[int, Sequence[int]]] = None, external_id: Optional[Union[str, SequenceNotStr[str]]] = None, ignore_unknown_ids: bool = False) None

Delete one or more transformations.

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

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

  • ignore_unknown_ids (bool) – Ignore IDs and external IDs that are not found rather than throw an exception.

Example

Delete transformations by id or external id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> client.transformations.delete(id=[1,2,3], external_id="function3")

Transformation Schedules

Create transformation Schedules

TransformationSchedulesAPI.create(schedule: cognite.client.data_classes.transformations.schedules.TransformationSchedule | cognite.client.data_classes.transformations.schedules.TransformationScheduleWrite) TransformationSchedule
TransformationSchedulesAPI.create(schedule: collections.abc.Sequence[cognite.client.data_classes.transformations.schedules.TransformationSchedule] | collections.abc.Sequence[cognite.client.data_classes.transformations.schedules.TransformationScheduleWrite]) TransformationScheduleList

Schedule the specified transformation with the specified configuration(s).

Parameters

schedule (TransformationSchedule | TransformationScheduleWrite | Sequence[TransformationSchedule] | Sequence[TransformationScheduleWrite]) – Configuration or list of configurations of the schedules to create.

Returns

Created schedule(s)

Return type

TransformationSchedule | TransformationScheduleList

Examples

Create new schedules:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import TransformationScheduleWrite
>>> client = CogniteClient()
>>> schedules = [TransformationScheduleWrite(id = 1, interval = "0 * * * *"), TransformationScheduleWrite(external_id="transformation2", interval = "5 * * * *"))]
>>> res = client.transformations.schedules.create(schedules)

Retrieve transformation schedules

TransformationSchedulesAPI.retrieve(id: Optional[int] = None, external_id: Optional[str] = None) cognite.client.data_classes.transformations.schedules.TransformationSchedule | None

Retrieve a single transformation schedule by the id or external id of its transformation.

Parameters
  • id (int | None) – transformation ID

  • external_id (str | None) – transformation External ID

Returns

Requested transformation schedule or None if it does not exist.

Return type

TransformationSchedule | None

Examples

Get transformation schedule by transformation id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.schedules.retrieve(id=1)

Get transformation schedule by transformation external id:

>>> res = client.transformations.schedules.retrieve(external_id="1")

Retrieve multiple transformation schedules

TransformationSchedulesAPI.retrieve_multiple(ids: Optional[Sequence[int]] = None, external_ids: Optional[SequenceNotStr[str]] = None, ignore_unknown_ids: bool = False) TransformationScheduleList

Retrieve multiple transformation schedules by the ids or external ids of the corresponding transformations.

Parameters
  • ids (Sequence[int] | None) – transformation IDs

  • external_ids (SequenceNotStr[str] | None) – transformation External IDs

  • ignore_unknown_ids (bool) – Ignore IDs and external IDs that are not found rather than throw an exception.

Returns

Requested transformation schedules.

Return type

TransformationScheduleList

Examples

Get transformation schedules by transformation ids:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.schedules.retrieve_multiple(ids=[1, 2, 3])

Get transformation schedules by transformation external ids:

>>> res = client.transformations.schedules.retrieve_multiple(external_ids=["t1", "t2"])

List transformation schedules

TransformationSchedulesAPI.list(include_public: bool = True, limit: int | None = 25) TransformationScheduleList

List all transformation schedules.

Parameters
  • include_public (bool) – Whether public transformations should be included in the results. (default true).

  • limit (int | None) – Limits the number of results to be returned. To retrieve all results use limit=-1, default limit is 25.

Returns

List of schedules

Return type

TransformationScheduleList

Example

List schedules:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> schedules_list = client.transformations.schedules.list()

Update transformation schedules

TransformationSchedulesAPI.update(item: cognite.client.data_classes.transformations.schedules.TransformationSchedule | cognite.client.data_classes.transformations.schedules.TransformationScheduleWrite | cognite.client.data_classes.transformations.schedules.TransformationScheduleUpdate, mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null') TransformationSchedule
TransformationSchedulesAPI.update(item: Sequence[cognite.client.data_classes.transformations.schedules.TransformationSchedule | cognite.client.data_classes.transformations.schedules.TransformationScheduleWrite | cognite.client.data_classes.transformations.schedules.TransformationScheduleUpdate], mode: Literal['replace_ignore_null', 'patch', 'replace'] = 'replace_ignore_null') TransformationScheduleList

Update one or more transformation schedules

Parameters
Returns

Updated transformation schedule(s)

Return type

TransformationSchedule | TransformationScheduleList

Examples

Update a transformation schedule that you have fetched. This will perform a full update of the schedule:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> transformation_schedule = client.transformations.schedules.retrieve(id=1)
>>> transformation_schedule.is_paused = True
>>> res = client.transformations.schedules.update(transformation_schedule)

Perform a partial update on a transformation schedule, updating the interval and unpausing it:

>>> from cognite.client.data_classes import TransformationScheduleUpdate
>>> my_update = TransformationScheduleUpdate(id=1).interval.set("0 * * * *").is_paused.set(False)
>>> res = client.transformations.schedules.update(my_update)

Delete transformation schedules

TransformationSchedulesAPI.delete(id: Optional[Union[int, Sequence[int]]] = None, external_id: Optional[Union[str, SequenceNotStr[str]]] = None, ignore_unknown_ids: bool = False) None

Unschedule one or more transformations

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

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

  • ignore_unknown_ids (bool) – Ignore IDs and external IDs that are not found rather than throw an exception.

Examples

Delete schedules by id or external id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> client.transformations.schedules.delete(id=[1,2,3], external_id="3")

Transformation Notifications

Create transformation notifications

TransformationNotificationsAPI.create(notification: cognite.client.data_classes.transformations.notifications.TransformationNotification | cognite.client.data_classes.transformations.notifications.TransformationNotificationWrite) TransformationNotification
TransformationNotificationsAPI.create(notification: collections.abc.Sequence[cognite.client.data_classes.transformations.notifications.TransformationNotification] | collections.abc.Sequence[cognite.client.data_classes.transformations.notifications.TransformationNotificationWrite]) TransformationNotificationList

Subscribe for notifications on the transformation errors.

Parameters

notification (TransformationNotification | TransformationNotificationWrite | Sequence[TransformationNotification] | Sequence[TransformationNotificationWrite]) – Notification or list of notifications to create.

Returns

Created notification(s)

Return type

TransformationNotification | TransformationNotificationList

Examples

Create new notifications:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import TransformationNotification
>>> client = CogniteClient()
>>> notifications = [TransformationNotification(transformation_id = 1, destination="[email protected]"), TransformationNotification(transformation_external_id="transformation2", destination="[email protected]"))]
>>> res = client.transformations.notifications.create(notifications)

List transformation notifications

TransformationNotificationsAPI.list(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None, destination: Optional[str] = None, limit: int | None = 25) TransformationNotificationList

List notification subscriptions.

Parameters
  • transformation_id (int | None) – Filter by transformation internal numeric ID.

  • transformation_external_id (str | None) – Filter by transformation externalId.

  • destination (str | None) – Filter by notification destination.

  • limit (int | None) – Limits the number of results to be returned. To retrieve all results use limit=-1, default limit is 25.

Returns

List of transformation notifications

Return type

TransformationNotificationList

Example

List all notifications:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> notifications_list = client.transformations.notifications.list()

List all notifications by transformation id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> notifications_list = client.transformations.notifications.list(transformation_id = 1)

Delete transformation notifications

TransformationNotificationsAPI.delete(id: Optional[Union[int, Sequence[int]]] = None) None

Deletes the specified notification subscriptions on the transformation. Does nothing when the subscriptions already don’t exist

Parameters

id (int | Sequence[int] | None) – Id or list of transformation notification ids

Examples

Delete schedules by id or external id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> client.transformations.notifications.delete(id=[1,2,3])

Transformation Jobs

Retrieve transformation jobs

TransformationJobsAPI.retrieve(id: int) cognite.client.data_classes.transformations.jobs.TransformationJob | None

Retrieve a single transformation job by id.

Parameters

id (int) – Job internal Id

Returns

Requested transformation job or None if it does not exist.

Return type

TransformationJob | None

Examples

Get transformation job by id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.jobs.retrieve(id=1)
TransformationJobsAPI.retrieve_multiple(ids: Sequence[int], ignore_unknown_ids: bool = False) TransformationJobList

Retrieve multiple transformation jobs by id.

Parameters
  • ids (Sequence[int]) – Job internal Ids

  • ignore_unknown_ids (bool) – Ignore IDs that are not found rather than throw an exception.

Returns

Requested transformation jobs.

Return type

TransformationJobList

Examples

Get jobs by id:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.transformations.jobs.retrieve_multiple(ids=[1, 2, 3])

List transformation jobs

TransformationJobsAPI.list(limit: int | None = 25, transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None) TransformationJobList

List all running transformation jobs.

Parameters
  • limit (int | None) – Limits the number of results to be returned. To retrieve all results use limit=-1, default limit is 25.

  • transformation_id (int | None) – Filters the results by the internal transformation id.

  • transformation_external_id (str | None) – Filters the results by the external transformation id.

Returns

List of transformation jobs

Return type

TransformationJobList

Example

List transformation jobs:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> transformation_jobs_list = client.transformations.jobs.list()

List transformation jobs of a single transformation:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> transformation_jobs_list = client.transformations.jobs.list(transformation_id=1)

Transformation Schema

Get transformation schema

TransformationSchemaAPI.retrieve(destination: TransformationDestination, conflict_mode: Optional[str] = None) TransformationSchemaColumnList

Get expected schema for a transformation destination.

Parameters
  • destination (TransformationDestination) – destination for which the schema is requested.

  • conflict_mode (str | None) – conflict mode for which the schema is requested.

Returns

List of column descriptions

Return type

TransformationSchemaColumnList

Example

Get the schema for a transformation producing assets:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes import TransformationDestination
>>> client = CogniteClient()
>>> columns = client.transformations.schema.retrieve(destination = TransformationDestination.assets())

Data classes

class cognite.client.data_classes.transformations.ContainsAny(tags: Optional[list[str]] = None)

Bases: TagsFilter

Return transformations that has one of the tags specified.

Parameters

tags (list[str] | None) – The resource item contains at least one of the listed tags. The tags are defined by a list of external ids.

Examples

List only resources marked as a PUMP or as a VALVE:

>>> from cognite.client.data_classes.transformations import ContainsAny
>>> my_tag_filter = ContainsAny(tags=["PUMP", "VALVE"])
class cognite.client.data_classes.transformations.SessionDetails(session_id: Optional[int] = None, client_id: Optional[str] = None, project_name: Optional[str] = None)

Bases: object

Details of a source session.

Parameters
  • session_id (int | None) – CDF source session ID

  • client_id (str | None) – Idp source client ID

  • project_name (str | None) – CDF source project name

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]

class cognite.client.data_classes.transformations.Transformation(id: int | None = None, external_id: str | None = None, name: str | None = None, query: str | None = None, destination: TransformationDestination | None = None, conflict_mode: str | None = None, is_public: bool = True, ignore_null_fields: bool = False, source_oidc_credentials: OidcCredentials | None = None, destination_oidc_credentials: OidcCredentials | None = None, created_time: int | None = None, last_updated_time: int | None = None, owner: str | None = None, owner_is_current_user: bool = True, has_source_oidc_credentials: bool | None = None, has_destination_oidc_credentials: bool | None = None, running_job: TransformationJob | None = None, last_finished_job: TransformationJob | None = None, blocked: TransformationBlockedInfo | None = None, schedule: TransformationSchedule | None = None, data_set_id: int | None = None, cognite_client: CogniteClient | None = None, source_nonce: NonceCredentials | None = None, destination_nonce: NonceCredentials | None = None, source_session: SessionDetails | None = None, destination_session: SessionDetails | None = None, tags: list[str] | None = None, **kwargs: Any)

Bases: TransformationCore

The transformation resource allows transforming data in CDF.

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

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

  • name (str | None) – The name of the Transformation.

  • query (str | None) – SQL query of the transformation.

  • destination (TransformationDestination | None) – see TransformationDestination for options.

  • conflict_mode (str | None) – What to do in case of id collisions: either “abort”, “upsert”, “update” or “delete”

  • is_public (bool) – Indicates if the transformation is visible to all in project or only to the owner.

  • ignore_null_fields (bool) – Indicates how null values are handled on updates: ignore or set null.

  • source_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials key on the destination.

  • destination_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials on the destination.

  • created_time (int | None) – The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

  • last_updated_time (int | None) – The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

  • owner (str | None) – Owner of the transformation: requester’s identity.

  • owner_is_current_user (bool) – Indicates if the transformation belongs to the current user.

  • has_source_oidc_credentials (bool | None) – Indicates if the transformation is configured with a source oidc credentials set.

  • has_destination_oidc_credentials (bool | None) – Indicates if the transformation is configured with a destination oidc credentials set.

  • running_job (TransformationJob | None) – Details for the job of this transformation currently running.

  • last_finished_job (TransformationJob | None) – Details for the last finished job of this transformation.

  • blocked (TransformationBlockedInfo | None) – Provides reason and time if the transformation is blocked.

  • schedule (TransformationSchedule | None) – Details for the schedule if the transformation is scheduled.

  • data_set_id (int | None) – No description.

  • cognite_client (CogniteClient | None) – The client to associate with this object.

  • source_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for reading.

  • destination_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for writing.

  • source_session (SessionDetails | None) – Details for the session used to read from the source project.

  • destination_session (SessionDetails | None) – Details for the session used to write to the destination project.

  • tags (list[str] | None) – No description.

  • **kwargs (Any) – No description.

as_write() TransformationWrite

Returns a writeable version of this transformation.

class cognite.client.data_classes.transformations.TransformationCore(external_id: Optional[str] = None, name: Optional[str] = None, query: Optional[str] = None, destination: Optional[TransformationDestination] = None, conflict_mode: Optional[str] = None, is_public: bool = True, ignore_null_fields: bool = False, source_oidc_credentials: Optional[OidcCredentials] = None, destination_oidc_credentials: Optional[OidcCredentials] = None, data_set_id: Optional[int] = None, source_nonce: Optional[NonceCredentials] = None, destination_nonce: Optional[NonceCredentials] = None, tags: Optional[list[str]] = None)

Bases: WriteableCogniteResource[TransformationWrite], ABC

The transformation resource allows transforming data in CDF.

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

  • name (str | None) – The name of the Transformation.

  • query (str | None) – SQL query of the transformation.

  • destination (TransformationDestination | None) – see TransformationDestination for options.

  • conflict_mode (str | None) – What to do in case of id collisions: either “abort”, “upsert”, “update” or “delete”

  • is_public (bool) – Indicates if the transformation is visible to all in project or only to the owner.

  • ignore_null_fields (bool) – Indicates how null values are handled on updates: ignore or set null.

  • source_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials key on the destination.

  • destination_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials on the destination.

  • data_set_id (int | None) – No description.

  • source_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for reading.

  • destination_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for writing.

  • tags (list[str] | None) – No description.

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]

class cognite.client.data_classes.transformations.TransformationFilter(include_public: bool = True, name_regex: Optional[str] = None, query_regex: Optional[str] = None, destination_type: Optional[str] = None, conflict_mode: Optional[str] = None, cdf_project_name: Optional[str] = None, has_blocked_error: Optional[bool] = None, created_time: Optional[Union[dict[str, Any], TimestampRange]] = None, last_updated_time: Optional[Union[dict[str, Any], TimestampRange]] = None, data_set_ids: Optional[list[dict[str, Any]]] = None, tags: Optional[TagsFilter] = None)

Bases: CogniteFilter

No description.

Parameters
  • include_public (bool) – Whether public transformations should be included in the results. The default is true.

  • name_regex (str | None) – Regex expression to match the transformation name

  • query_regex (str | None) – Regex expression to match the transformation query

  • destination_type (str | None) – Transformation destination resource name to filter by.

  • conflict_mode (str | None) – Filters by a selected transformation action type: abort/create, upsert, update, delete

  • cdf_project_name (str | None) – Project name to filter by configured source and destination project

  • has_blocked_error (bool | None) – Whether only the blocked transformations should be included in the results.

  • created_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps

  • last_updated_time (dict[str, Any] | TimestampRange | None) – Range between two timestamps

  • data_set_ids (list[dict[str, Any]] | None) – Return only transformations in the specified data sets with these ids, e.g. [{“id”: 1}, {“externalId”: “foo”}].

  • tags (TagsFilter | None) – Return only the resource matching the specified tags constraints. It only supports ContainsAny as of now.

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]

class cognite.client.data_classes.transformations.TransformationList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: WriteableCogniteResourceList[TransformationWrite, Transformation], IdTransformerMixin

class cognite.client.data_classes.transformations.TransformationPreviewResult(schema: TransformationSchemaColumnList | None = None, results: list[dict] | None = None, cognite_client: CogniteClient | None = None)

Bases: CogniteResource

Allows previewing the result of a sql transformation before executing it.

Parameters
  • schema (TransformationSchemaColumnList | None) – List of column descriptions.

  • results (list[dict] | None) – List of resulting rows. Each row is a dictionary where the key is the column name and the value is the entry.

  • cognite_client (CogniteClient | None) – No description.

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]

class cognite.client.data_classes.transformations.TransformationUpdate(id: Optional[int] = None, external_id: Optional[str] = None)

Bases: CogniteUpdate

Changes applied to transformation

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

  • external_id (str) – External Id provided by client. Should be unique within the project.

dump(camel_case: bool = 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]

class cognite.client.data_classes.transformations.TransformationWrite(external_id: str, name: str, ignore_null_fields: bool, query: Optional[str] = None, destination: Optional[TransformationDestination] = None, conflict_mode: Optional[Literal['abort', 'delete', 'update', 'upsert']] = None, is_public: bool = True, source_oidc_credentials: Optional[OidcCredentials] = None, destination_oidc_credentials: Optional[OidcCredentials] = None, data_set_id: Optional[int] = None, source_nonce: Optional[NonceCredentials] = None, destination_nonce: Optional[NonceCredentials] = None, tags: Optional[list[str]] = None)

Bases: TransformationCore

The transformation resource allows transforming data in CDF.

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

  • name (str) – The name of the Transformation.

  • ignore_null_fields (bool) – Indicates how null values are handled on updates: ignore or set null.

  • query (str | None) – SQL query of the transformation.

  • destination (TransformationDestination | None) – see TransformationDestination for options.

  • conflict_mode (Literal['abort', 'delete', 'update', 'upsert'] | None) – What to do in case of id collisions: either “abort”, “upsert”, “update” or “delete”

  • is_public (bool) – Indicates if the transformation is visible to all in project or only to the owner.

  • source_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials key on the destination.

  • destination_oidc_credentials (OidcCredentials | None) – Configure the transformation to authenticate with the given oidc credentials on the destination.

  • data_set_id (int | None) – No description.

  • source_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for reading.

  • destination_nonce (NonceCredentials | None) – Single use credentials to bind to a CDF session for writing.

  • tags (list[str] | None) – No description.

as_write() TransformationWrite

Returns this TransformationWrite instance.

class cognite.client.data_classes.transformations.TransformationWriteList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationWrite], ExternalIDTransformerMixin

class cognite.client.data_classes.transformations.schedules.TransformationSchedule(id: int | None = None, external_id: str | None = None, created_time: int | None = None, last_updated_time: int | None = None, interval: str | None = None, is_paused: bool = False, cognite_client: CogniteClient | None = None)

Bases: TransformationScheduleCore

The transformation schedules resource allows running recurrent transformations.

Parameters
  • id (int | None) – Transformation id.

  • external_id (str | None) – Transformation external id.

  • created_time (int | None) – Time when the schedule was created.

  • last_updated_time (int | None) – Time when the schedule was last updated.

  • interval (str | None) – Cron expression controls when the transformation will be run. Use http://www.cronmaker.com to create one.

  • is_paused (bool) – If true, the transformation is not scheduled.

  • cognite_client (CogniteClient | None) – The client to associate with this object.

as_write() TransformationScheduleWrite

Returns this TransformationSchedule as a TransformationScheduleWrite

class cognite.client.data_classes.transformations.schedules.TransformationScheduleCore(id: Optional[int] = None, external_id: Optional[str] = None, interval: Optional[str] = None, is_paused: bool = False)

Bases: WriteableCogniteResource[TransformationScheduleWrite], ABC

The transformation schedules resource allows running recurrent transformations.

Parameters
  • id (int | None) – Transformation id.

  • external_id (str | None) – Transformation external id.

  • interval (str | None) – Cron expression controls when the transformation will be run. Use http://www.cronmaker.com to create one.

  • is_paused (bool) – If true, the transformation is not scheduled.

class cognite.client.data_classes.transformations.schedules.TransformationScheduleList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: WriteableCogniteResourceList[TransformationScheduleWrite, TransformationSchedule], IdTransformerMixin

class cognite.client.data_classes.transformations.schedules.TransformationScheduleUpdate(id: Optional[int] = None, external_id: Optional[str] = None)

Bases: CogniteUpdate

Changes applied to transformation schedule

Parameters
  • id (int) – Transformation id.

  • external_id (str) – Transformation externalId.

class cognite.client.data_classes.transformations.schedules.TransformationScheduleWrite(interval: str, id: Optional[int] = None, external_id: Optional[str] = None, is_paused: bool = False)

Bases: TransformationScheduleCore

The transformation schedules resource allows running recurrent transformations.

Parameters
  • interval (str) – Cron expression controls when the transformation will be run. Use http://www.cronmaker.com to create one.

  • id (int | None) – Transformation id.

  • external_id (str | None) – Transformation external id.

  • is_paused (bool) – If true, the transformation is not scheduled.

as_write() TransformationScheduleWrite

Returns this TransformationScheduleWrite instance.

class cognite.client.data_classes.transformations.schedules.TransformationScheduleWriteList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationScheduleWrite], IdTransformerMixin

class cognite.client.data_classes.transformations.notifications.TransformationNotification(id: int | None = None, transformation_id: int | None = None, transformation_external_id: str | None = None, destination: str | None = None, created_time: int | None = None, last_updated_time: int | None = None, cognite_client: CogniteClient | None = None)

Bases: TransformationNotificationCore

The transformation notification resource allows configuring email alerts on events related to a transformation run. This is the read format of a transformation notification.

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

  • transformation_id (int | None) – Transformation Id.

  • transformation_external_id (str | None) – Transformation external Id.

  • destination (str | None) – Email address where notifications should be sent.

  • created_time (int | None) – Time when the notification was created.

  • last_updated_time (int | None) – Time when the notification was last updated.

  • cognite_client (CogniteClient | None) – The client to associate with this object.

as_write() TransformationNotificationWrite

Returns this Asset in its writing format.

class cognite.client.data_classes.transformations.notifications.TransformationNotificationCore(destination: Optional[str] = None)

Bases: WriteableCogniteResource[TransformationNotificationWrite], ABC

The transformation notification resource allows configuring email alerts on events related to a transformation run.

Parameters

destination (str | None) – Email address where notifications should be sent.

class cognite.client.data_classes.transformations.notifications.TransformationNotificationFilter(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None, destination: Optional[str] = None)

Bases: CogniteFilter

Parameters
  • transformation_id (int | None) – Filter by transformation internal numeric ID.

  • transformation_external_id (str | None) – Filter by transformation externalId.

  • destination (str | None) – Filter by notification destination.

class cognite.client.data_classes.transformations.notifications.TransformationNotificationList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: WriteableCogniteResourceList[TransformationNotificationWrite, TransformationNotification], InternalIdTransformerMixin

as_write() TransformationNotificationWriteList

Returns this TransformationNotificationList instance

class cognite.client.data_classes.transformations.notifications.TransformationNotificationWrite(destination: str, transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None)

Bases: TransformationNotificationCore

The transformation notification resource allows configuring email alerts on events related to a transformation run. This is the write format of a transformation notification.

Parameters
  • destination (str) – Email address where notifications should be sent.

  • transformation_id (int | None) – Transformation ID.

  • transformation_external_id (str | None) – Transformation external ID.

as_write() TransformationNotificationWrite

Returns this TransformationNotification instance

class cognite.client.data_classes.transformations.notifications.TransformationNotificationWriteList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationNotificationWrite]

class cognite.client.data_classes.transformations.jobs.TransformationJob(id: int | None = None, status: TransformationJobStatus | None = None, transformation_id: int | None = None, transformation_external_id: str | None = None, source_project: str | None = None, destination_project: str | None = None, destination: TransformationDestination | None = None, conflict_mode: str | None = None, query: str | None = None, error: str | None = None, ignore_null_fields: bool = False, created_time: int | None = None, started_time: int | None = None, finished_time: int | None = None, last_seen_time: int | None = None, cognite_client: CogniteClient | None = None)

Bases: CogniteResource

The transformation job resource allows following the status of execution of a transformation run.

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

  • status (TransformationJobStatus | None) – Status of the job.

  • transformation_id (int | None) – Server-generated ID of the transformation.

  • transformation_external_id (str | None) – external ID of the transformation.

  • source_project (str | None) – Name of the CDF project the data will be read from.

  • destination_project (str | None) – Name of the CDF project the data will be written to.

  • destination (TransformationDestination | None) – No description.

  • conflict_mode (str | None) – What to do in case of id collisions: either “abort”, “upsert”, “update” or “delete”.

  • query (str | None) – Query of the transformation that is being executed.

  • error (str | None) – Error message from the server.

  • ignore_null_fields (bool) – Indicates how null values are handled on updates: ignore or set null.

  • created_time (int | None) – Time when the job was created.

  • started_time (int | None) – Time when the job started running.

  • finished_time (int | None) – Time when the job finished running.

  • last_seen_time (int | None) – Time of the last status update from the job.

  • cognite_client (CogniteClient | None) – The client to associate with this object.

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]

metrics() TransformationJobMetricList

Get job metrics.

update() None

Get updated job status.

wait(polling_interval: float = 1, timeout: Optional[float] = None) TransformationJob

Waits for the job to finish.

Parameters
  • polling_interval (float) – time (s) to wait between job status updates, default is one second.

  • timeout (float | None) – maximum time (s) to wait, default is None (infinite time). Once the timeout is reached, it returns with the current status.

Returns

self.

Return type

TransformationJob

Examples

run transformations 1 and 2 in parallel, and run 3 once they finish successfully:

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>>
>>> job1 = client.transformations.run(id = 1, wait = False)
>>> job2 = client.transformations.run(id = 2, wait = False)
>>> job1.wait()
>>> job2.wait()
>>> if TransformationJobStatus.FAILED not in [job1.status, job2.status]:
>>>     client.transformations.run(id = 3, wait = False)

wait transformation for 5 minutes and do something if still running:

>>>
>>> job = client.transformations.run(id = 1, wait = False)
>>> job.wait(timeout = 5.0*60)
>>> if job.status == TransformationJobStatus.FAILED:
>>>     # do something if job failed
>>> elif job.status == TransformationJobStatus.COMPLETED:
>>>     # do something if job completed successfully
>>> else:
>>>     # do something if job is still running
async wait_async(polling_interval: float = 1, timeout: Optional[float] = None) TransformationJob

Asyncio coroutine, waits for the job to finish asynchronously.

Parameters
  • polling_interval (float) – time (s) to wait between job status updates, default is one second.

  • timeout (float | None) – maximum time (s) to wait, default is None (infinite time). Once the timeout is reached, it returns with the current status.

Returns

coroutine object that will finish when the job finishes and resolves to self.

Return type

TransformationJob

Examples

run transformations 1 and 2 in parallel, and run 3 once they finish successfully:

>>> from asyncio import ensure_future
>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>>
>>> async def run_successive_transformations():
>>>     job1 = client.transformations.run(id = 1, wait = False)
>>>     job2 = client.transformations.run(id = 2, wait = False)
>>>     await job1.wait_async()
>>>     await job2.wait_async()
>>>     if TransformationJobStatus.FAILED not in [job1.status, job2.status]:
>>>         client.transformations.run(id = 3, wait = False)
>>>
>>> ensure_future(run_successive_transformations())

wait transformation for 5 minutes and do something if still running:

>>> from asyncio import ensure_future
>>>
>>> async def run_successive_transformations():
>>>     job = client.transformations.run(id = 1, wait = False)
>>>     await job.wait_async(timeout = 5.0*60)
>>>     if job.status == TransformationJobStatus.FAILED:
>>>         # do something if job failed
>>>     elif job.status == TransformationJobStatus.COMPLETED:
>>>         # do something if job completed successfully
>>>     else:
>>>         # do something if job is still running
>>>
>>> ensure_future(run_successive_transformations())
class cognite.client.data_classes.transformations.jobs.TransformationJobFilter(transformation_id: Optional[int] = None, transformation_external_id: Optional[str] = None)

Bases: CogniteFilter

Parameters
  • transformation_id (int | None) – Filter jobs by transformation internal numeric ID.

  • transformation_external_id (str | None) – Filter jobs by transformation external ID.

class cognite.client.data_classes.transformations.jobs.TransformationJobList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationJob], InternalIdTransformerMixin

class cognite.client.data_classes.transformations.jobs.TransformationJobMetric(id: int | None = None, timestamp: int | None = None, name: str | None = None, count: int | None = None, cognite_client: CogniteClient | None = None)

Bases: CogniteResource

The transformation job metric resource allows following details of execution of a transformation run.

Parameters
  • id (int | None) – No description.

  • timestamp (int | None) – Time of the last metric update.

  • name (str | None) – Name of the metric.

  • count (int | None) – Value of the metric.

  • cognite_client (CogniteClient | None) – The client to associate with this object.

class cognite.client.data_classes.transformations.jobs.TransformationJobMetricList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationJobMetric], InternalIdTransformerMixin

class cognite.client.data_classes.transformations.jobs.TransformationJobStatus(value)

Bases: str, Enum

An enumeration.

class cognite.client.data_classes.transformations.schema.TransformationSchemaArrayType(type: Optional[str] = None, element_type: Optional[str] = None, contains_null: bool = False)

Bases: TransformationSchemaType

class cognite.client.data_classes.transformations.schema.TransformationSchemaColumn(name: str | None = None, sql_type: str | None = None, type: TransformationSchemaType | None = None, nullable: bool = False, cognite_client: CogniteClient | None = None)

Bases: CogniteResource

Represents a column of the expected sql structure for a destination type.

Parameters
  • name (str | None) – Column name

  • sql_type (str | None) – Type of the column in sql format.

  • type (TransformationSchemaType | None) – Type of the column in json format.

  • nullable (bool) – Values for the column can be null or not

  • cognite_client (CogniteClient | None) – The client to associate with this object.

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]

class cognite.client.data_classes.transformations.schema.TransformationSchemaColumnList(resources: Iterable[Any], cognite_client: CogniteClient | None = None)

Bases: CogniteResourceList[TransformationSchemaColumn]

class cognite.client.data_classes.transformations.schema.TransformationSchemaMapType(type: str, key_type: Optional[str] = None, value_type: Optional[str] = None, value_contains_null: bool = False)

Bases: TransformationSchemaType

class cognite.client.data_classes.transformations.schema.TransformationSchemaStructType(type: Optional[str] = None, fields: Optional[list[dict[str, Any]]] = None)

Bases: TransformationSchemaType

dump(camel_case: bool = True) dict

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]

class cognite.client.data_classes.transformations.schema.TransformationSchemaType(type: Optional[str] = None)

Bases: CogniteObject

class cognite.client.data_classes.transformations.schema.TransformationSchemaUnknownType(raw_schema: dict[str, Any])

Bases: TransformationSchemaType

dump(camel_case: Literal[True] = 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]

class cognite.client.data_classes.transformations.common.DataModelInfo(space: str, external_id: str, version: str, destination_type: str, destination_relationship_from_type: Optional[str] = None)

Bases: CogniteObject

class cognite.client.data_classes.transformations.common.EdgeType(space: str, external_id: str)

Bases: CogniteObject

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]

class cognite.client.data_classes.transformations.common.Edges(view: Optional[ViewInfo] = None, instance_space: Optional[str] = None, edge_type: Optional[EdgeType] = None)

Bases: TransformationDestination

class cognite.client.data_classes.transformations.common.Instances(data_model: Optional[DataModelInfo] = None, instance_space: Optional[str] = None)

Bases: TransformationDestination

class cognite.client.data_classes.transformations.common.Nodes(view: Optional[ViewInfo] = None, instance_space: Optional[str] = None)

Bases: TransformationDestination

class cognite.client.data_classes.transformations.common.OidcCredentials(client_id: str, client_secret: str, scopes: str | list[str], token_uri: str, cdf_project_name: str, audience: Optional[str] = None)

Bases: object

Class that represents OpenID Connect (OIDC) credentials used to authenticate towards Cognite Data Fusion (CDF).

Note

Is currently only used to specify inputs to TransformationsAPI like source_oidc_credentials and destination_oidc_credentials.

Parameters
  • client_id (str) – Your application’s client id.

  • client_secret (str) – Your application’s client secret

  • scopes (str | list[str]) – A list of scopes or a comma-separated string (for backwards compatibility).

  • token_uri (str) – OAuth token url

  • cdf_project_name (str) – Name of CDF project

  • audience (str | None) – Audience (optional)

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]

classmethod load(data: dict[str, Any]) Self

Load data into the instance.

Parameters

data (dict[str, Any]) – A dictionary representation of the instance.

Returns

No description.

Return type

Self

class cognite.client.data_classes.transformations.common.RawTable(database: Optional[str] = None, table: Optional[str] = None)

Bases: TransformationDestination

class cognite.client.data_classes.transformations.common.SequenceRowsDestination(external_id: Optional[str] = None)

Bases: TransformationDestination

class cognite.client.data_classes.transformations.common.TransformationBlockedInfo(reason: str, created_time: int)

Bases: object

Information about the reason why and when a transformation is blocked.

Parameters
  • reason (str) – Reason why the transformation is blocked.

  • created_time (int) – Timestamp when the transformation was blocked.

class cognite.client.data_classes.transformations.common.TransformationDestination(type: Optional[str] = None)

Bases: CogniteObject

TransformationDestination has static methods to define the target resource type of a transformation

Parameters

type (str | None) – Used as data type identifier on transformation creation/retrieval.

static asset_hierarchy() TransformationDestination

To be used when the transformation is meant to produce asset hierarchies.

static assets() TransformationDestination

To be used when the transformation is meant to produce assets.

static data_sets() TransformationDestination

To be used when the transformation is meant to produce data sets.

static datapoints() TransformationDestination

To be used when the transformation is meant to produce numeric data points.

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]

static edges(view: Optional[ViewInfo] = None, instance_space: Optional[str] = None, edge_type: Optional[EdgeType] = None) Edges
Parameters
  • view (ViewInfo | None) – information of the view.

  • instance_space (str | None) – space id of the instance.

  • edge_type (EdgeType | None) – information about the type of the edge

Returns

pointing to the target flexible data model.

Return type

Edges

static events() TransformationDestination

To be used when the transformation is meant to produce events.

static files() TransformationDestination

To be used when the transformation is meant to produce files.

static instances(data_model: Optional[DataModelInfo] = None, instance_space: Optional[str] = None) Instances
Parameters
  • data_model (DataModelInfo | None) – information of the Data Model.

  • instance_space (str | None) – space id of the instance.

Returns

pointing to the target centric data model.

Return type

Instances

static labels() TransformationDestination

To be used when the transformation is meant to produce labels.

static nodes(view: Optional[ViewInfo] = None, instance_space: Optional[str] = None) Nodes
Parameters
  • view (ViewInfo | None) – information of the view.

  • instance_space (str | None) – space id of the instance.

Returns

pointing to the target flexible data model.

Return type

Nodes

static raw(database: str = '', table: str = '') RawTable

To be used when the transformation is meant to produce raw table rows.

Parameters
  • database (str) – database name of the target raw table.

  • table (str) – name of the target raw table

Returns

TransformationDestination pointing to the target table

Return type

RawTable

static relationships() TransformationDestination

To be used when the transformation is meant to produce relationships.

static sequence_rows(external_id: str = '') SequenceRowsDestination

To be used when the transformation is meant to produce sequence rows.

Parameters

external_id (str) – Sequence external id.

Returns

TransformationDestination pointing to the target sequence rows

Return type

SequenceRowsDestination

static sequences() TransformationDestination

To be used when the transformation is meant to produce sequences.

static string_datapoints() TransformationDestination

To be used when the transformation is meant to produce string data points.

static timeseries() TransformationDestination

To be used when the transformation is meant to produce time series.

class cognite.client.data_classes.transformations.common.ViewInfo(space: str, external_id: str, version: str)

Bases: CogniteObject