diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2b6c39a..c2f896219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [7.64.5] - 2024-11-01 +### Fixed +- The `client.functions.schedules.create` method no longer mutates the input `FunctionScheduleWrite` object. + ## [7.64.4] - 2024-11-01 ### Fixed - Data Workflows: apply more robust path parameter encoding. diff --git a/cognite/client/_api/functions.py b/cognite/client/_api/functions.py index d1d4a4b10..24dbc2d35 100644 --- a/cognite/client/_api/functions.py +++ b/cognite/client/_api/functions.py @@ -1284,7 +1284,8 @@ def create( raise ValueError("cron_expression must be specified when creating a new schedule.") item = FunctionScheduleWrite(name, cron_expression, function_id, function_external_id, description, data) else: - item = name + # We serialize the object as we mutate `item` using the result from _get_function_internal_id. + item = FunctionScheduleWrite._load(name.dump()) identifier = _get_function_identifier(item.function_id, item.function_external_id) if item.function_id is None: item.function_id = _get_function_internal_id(self._cognite_client, identifier) diff --git a/cognite/client/_version.py b/cognite/client/_version.py index d6047efe9..38b06ea1f 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.64.4" +__version__ = "7.64.5" __api_subversion__ = "20230101" diff --git a/pyproject.toml b/pyproject.toml index 07a58aa2d..43da3b218 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.64.4" +version = "7.64.5" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com" diff --git a/tests/tests_integration/test_api/test_functions.py b/tests/tests_integration/test_api/test_functions.py index d3c456f6d..d073cf566 100644 --- a/tests/tests_integration/test_api/test_functions.py +++ b/tests/tests_integration/test_api/test_functions.py @@ -92,12 +92,20 @@ def test_create_retrieve_delete(self, cognite_client: CogniteClient, a_function: function_external_id=a_function.external_id, data={"key": "value"}, ) + original_schedule = FunctionScheduleWrite._load(my_schedule.dump()) created: FunctionSchedule | None = None try: created = cognite_client.functions.schedules.create(my_schedule) - assert created.as_write().dump() == my_schedule.dump() + created_dump = created.as_write().dump() + created_dump.pop("functionId") + my_dump = my_schedule.dump() + my_dump.pop("functionExternalId") + + assert created_dump == my_dump + # This check is to ensure that the original schedule is not modified + assert my_schedule.dump() == original_schedule.dump() retrieved = cognite_client.functions.schedules.retrieve(id=created.id) assert isinstance(retrieved, FunctionSchedule)