From 405ca1471fb146b8cb2fc774f574c37559cc5d34 Mon Sep 17 00:00:00 2001 From: Bert Verstraete Date: Tue, 20 Feb 2024 14:03:53 +0100 Subject: [PATCH] Data Workflows: Fix transformation task output (#1633) jobId may not be available in case of a Transformations task in a scheduled state or in case of Transformation call failure --- CHANGELOG.md | 6 +++++- cognite/client/_version.py | 2 +- cognite/client/data_classes/workflows.py | 6 +++--- pyproject.toml | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db9b1797f7..b695c2ddc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,13 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [7.21.1] - 2024-02-20 +### Fixed +- Data Workflows: mark parameter `jobId` as optional in `TransformationTaskOutput`, as it may not be populated in case of a failure. + ## [7.21.0] - 2024-02-10 ### Added -- Parameter `sort` to `client.documents.list. +- Parameter `sort` to `client.documents.list`. ## [7.20.1] - 2024-02-19 ### Fixed diff --git a/cognite/client/_version.py b/cognite/client/_version.py index 43abd6f969..4a2355e470 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.21.0" +__version__ = "7.21.1" __api_subversion__ = "20230101" diff --git a/cognite/client/data_classes/workflows.py b/cognite/client/data_classes/workflows.py index e9df367d82..ba7d3462d1 100644 --- a/cognite/client/data_classes/workflows.py +++ b/cognite/client/data_classes/workflows.py @@ -527,18 +527,18 @@ class TransformationTaskOutput(WorkflowTaskOutput): The transformation output is used to specify the output of a transformation task. Args: - job_id (int): The job id of the transformation job. + job_id (int | None): The job id of the transformation job. """ task_type: ClassVar[str] = "transformation" - def __init__(self, job_id: int) -> None: + def __init__(self, job_id: int | None) -> None: self.job_id = job_id @classmethod def load(cls, data: dict[str, Any]) -> TransformationTaskOutput: output = data["output"] - return cls(output["jobId"]) + return cls(output.get("jobId")) def dump(self, camel_case: bool = True) -> dict[str, Any]: return {("jobId" if camel_case else "job_id"): self.job_id} diff --git a/pyproject.toml b/pyproject.toml index 45b29ccfca..5144f1f7cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.21.0" +version = "7.21.1" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com"