Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix WorkflowDefinitionUpsert storing built-in hash function #1539

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.5.2] - 2023-12-05
### Fixed
- The built-in `hash` function was mistakenly stored on `WorkflowDefinitionUpsert` instances after `__init__` and has been removed.

## [7.5.1] - 2023-12-01
### Changed
- Raise an exception if `ClientConfig:base_url` is set to `None` or an empty string
Expand All @@ -32,8 +36,7 @@ Changes are grouped as follows

## [7.4.1] - 2023-11-28
### Fixed
- Error in logic when creating a `Transformation`. This is causing when calling `client.transformations.update`.
This is now fixed.
- Error in validation logic when creating a `Transformation` caused many calls to `client.transformations.update` to fail.

## [7.4.0] - 2023-11-27
### Changed
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.5.1"
__version__ = "7.5.2"
__api_subversion__ = "V20220125"
5 changes: 2 additions & 3 deletions cognite/client/data_classes/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ def load(cls, data: dict[str, Any]) -> FunctionTaskOutput:

def dump(self, camel_case: bool = True) -> dict[str, Any]:
return {
("callId" if camel_case else "call_id"): self.call_id,
("functionId" if camel_case else "function_id"): self.function_id,
"callId" if camel_case else "call_id": self.call_id,
"functionId" if camel_case else "function_id": self.function_id,
"response": self.response,
}

Expand Down Expand Up @@ -629,7 +629,6 @@ def __init__(
tasks: list[WorkflowTask],
description: str | None,
) -> None:
self.hash = hash
self.tasks = tasks
self.description = description

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.5.1"
version = "7.5.2"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_integration/test_api/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_upsert_delete(self, cognite_client: CogniteClient) -> None:

assert created_version.workflow_external_id == version.workflow_external_id
assert created_version.workflow_definition.description == version.workflow_definition.description
assert created_version.workflow_definition.hash is not None
assert isinstance(created_version.workflow_definition.hash_, str)
finally:
if created_version is not None:
cognite_client.workflows.versions.delete(
Expand Down
12 changes: 12 additions & 0 deletions tests/tests_unit/test_data_classes/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
FunctionTaskOutput,
FunctionTaskParameters,
TransformationTaskOutput,
TransformationTaskParameters,
WorkflowDefinition,
WorkflowDefinitionUpsert,
WorkflowExecutionDetailed,
WorkflowIds,
WorkflowTask,
Expand All @@ -19,6 +22,15 @@
)


class TestWorkFlowDefinitions:
def test_upsert_variant_doesnt_accept_hash(self):
task = WorkflowTask(external_id="foo", parameters=TransformationTaskParameters(external_id="something"))
WorkflowDefinition(tasks=[task], description="desc", hash_="very-random")

with pytest.raises(TypeError, match="unexpected keyword argument 'hash_'$"):
WorkflowDefinitionUpsert(tasks=[task], description="desc", hash_="very-random")


class TestWorkflowTaskOutput:
@pytest.mark.parametrize(
["output", "expected"],
Expand Down