From 4a6bf557ac7579a9b1c6950cf3177f2d7ed7463d Mon Sep 17 00:00:00 2001 From: Bert Verstraete Date: Tue, 4 Jun 2024 13:34:00 +0200 Subject: [PATCH] Mark data workflows as GA (#1778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Data Workflows going into GA 💯 - Remove maturity warning for both the SDK (alpha -> GA) and API (Beta -> GA) --- CHANGELOG.md | 4 ++++ cognite/client/_api/workflows.py | 41 ++++---------------------------- cognite/client/_version.py | 2 +- pyproject.toml | 2 +- tests/tests_unit/test_testing.py | 3 +-- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6123193f84..d3dc213017 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.48.0] - 2024-06-04 +### Changed +- Mark Data Workflows SDK implementation as Generally Available. + ## [7.47.0] - 2024-06-04 ### Added - Support for retrieving `Labels`, `client.labels.retrieve`. diff --git a/cognite/client/_api/workflows.py b/cognite/client/_api/workflows.py index fd276dae7a..8403efdca8 100644 --- a/cognite/client/_api/workflows.py +++ b/cognite/client/_api/workflows.py @@ -1,6 +1,5 @@ from __future__ import annotations -from abc import ABC from typing import TYPE_CHECKING, Any, Literal, MutableSequence, Tuple, Union from urllib.parse import quote @@ -23,7 +22,6 @@ WorkflowVersionUpsert, ) from cognite.client.exceptions import CogniteAPIError -from cognite.client.utils._experimental import FeaturePreviewWarning from cognite.client.utils._identifier import ( IdentifierSequence, WorkflowVersionIdentifierSequence, @@ -35,26 +33,11 @@ from cognite.client import ClientConfig, CogniteClient from cognite.client.data_classes import ClientCredentials - -class BetaWorkflowAPIClient(APIClient, ABC): - def __init__( - self, - config: ClientConfig, - api_version: str | None, - cognite_client: CogniteClient, - ) -> None: - super().__init__(config, api_version, cognite_client) - self._api_subversion = "beta" - self._warning = FeaturePreviewWarning( - api_maturity="beta", sdk_maturity="alpha", feature_name="Workflow Orchestration" - ) - - WorkflowIdentifier: TypeAlias = Union[WorkflowVersionId, Tuple[str, str], str] WorkflowVersionIdentifier: TypeAlias = Union[WorkflowVersionId, Tuple[str, str]] -class WorkflowTaskAPI(BetaWorkflowAPIClient): +class WorkflowTaskAPI(APIClient): _RESOURCE_PATH = "/workflows/tasks" def update( @@ -95,8 +78,6 @@ def update( >>> res = client.workflows.tasks.update(res.tasks[1].id, "completed") """ - self._warning.warn() - body: dict[str, Any] = {"status": status.upper()} if output is not None: body["output"] = output @@ -107,7 +88,7 @@ def update( return WorkflowTaskExecution.load(response.json()) -class WorkflowExecutionAPI(BetaWorkflowAPIClient): +class WorkflowExecutionAPI(APIClient): _RESOURCE_PATH = "/workflows/executions" def retrieve_detailed(self, id: str) -> WorkflowExecutionDetailed | None: @@ -135,7 +116,6 @@ def retrieve_detailed(self, id: str) -> WorkflowExecutionDetailed | None: >>> res = client.workflows.executions.retrieve_detailed(res[0].id) """ - self._warning.warn() try: response = self._get(url_path=f"{self._RESOURCE_PATH}/{id}") except CogniteAPIError as e: @@ -194,7 +174,6 @@ def trigger( >>> credentials = ClientCredentials("my-client-id", os.environ["MY_CLIENT_SECRET"]) >>> res = client.workflows.executions.trigger("foo", "1", client_credentials=credentials) """ - self._warning.warn() nonce = create_session_and_return_nonce( self._cognite_client, api_name="Workflow API", client_credentials=client_credentials ) @@ -242,7 +221,6 @@ def list( >>> res = client.workflows.executions.list(created_time_start=int((datetime.now() - timedelta(days=1)).timestamp() * 1000)) """ - self._warning.warn() filter_: dict[str, Any] = {} if workflow_version_ids is not None: filter_["workflowFilters"] = WorkflowIds.load(workflow_version_ids).dump( @@ -284,7 +262,6 @@ def cancel(self, id: str, reason: str | None) -> WorkflowExecution: >>> res = client.workflows.executions.trigger("foo", "1") >>> client.workflows.executions.cancel(id="foo", reason="test cancelation") """ - self._warning.warn() response = self._post( url_path=f"{self._RESOURCE_PATH}/{id}/cancel", json={ @@ -315,7 +292,6 @@ def retry(self, id: str, client_credentials: ClientCredentials | None = None) -> >>> client.workflows.executions.cancel(id=res.id, reason="test cancellation") >>> client.workflows.executions.retry(res.id) """ - self._warning.warn() nonce = create_session_and_return_nonce( self._cognite_client, api_name="Workflow API", client_credentials=client_credentials ) @@ -326,7 +302,7 @@ def retry(self, id: str, client_credentials: ClientCredentials | None = None) -> return WorkflowExecution._load(response.json()) -class WorkflowVersionAPI(BetaWorkflowAPIClient): +class WorkflowVersionAPI(APIClient): _RESOURCE_PATH = "/workflows/versions" def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None: @@ -372,7 +348,6 @@ def upsert(self, version: WorkflowVersionUpsert, mode: Literal["replace"] = "rep ... ) >>> res = client.workflows.versions.upsert(new_version) """ - self._warning.warn() if mode != "replace": raise ValueError("Only replace mode is supported for upserting workflow versions.") @@ -410,7 +385,6 @@ def delete( >>> client.workflows.versions.delete([WorkflowVersionId("my workflow", "1"), WorkflowVersionId("my workflow 2", "2")]) """ - self._warning.warn() identifiers = WorkflowIds.load(workflow_version_id).dump(camel_case=True) self._delete_multiple( identifiers=WorkflowVersionIdentifierSequence.load(identifiers), @@ -436,7 +410,6 @@ def retrieve(self, workflow_external_id: str, version: str) -> WorkflowVersion | >>> client = CogniteClient() >>> res = client.workflows.versions.retrieve("my workflow", "1") """ - self._warning.warn() try: response = self._get( url_path=f"/workflows/{quote(workflow_external_id, '')}/versions/{quote(version, '')}", @@ -484,7 +457,6 @@ def list( >>> res = client.workflows.versions.list([("my_workflow", "1"), ("my_workflow_2", "2")]) """ - self._warning.warn() if workflow_version_ids is None: workflow_ids_dumped = [] else: @@ -499,7 +471,7 @@ def list( ) -class WorkflowAPI(BetaWorkflowAPIClient): +class WorkflowAPI(APIClient): _RESOURCE_PATH = "/workflows" def __init__( @@ -535,7 +507,6 @@ def upsert(self, workflow: WorkflowUpsert, mode: Literal["replace"] = "replace") >>> client = CogniteClient() >>> res = client.workflows.upsert(WorkflowUpsert(external_id="my workflow", description="my workflow description")) """ - self._warning.warn() if mode != "replace": raise ValueError("Only replace mode is supported for upserting workflows.") @@ -562,7 +533,6 @@ def retrieve(self, external_id: str) -> Workflow | None: >>> client = CogniteClient() >>> res = client.workflows.retrieve("my workflow") """ - self._warning.warn() try: response = self._get(url_path=f"{self._RESOURCE_PATH}/{quote(external_id, '')}") except CogniteAPIError as e: @@ -586,7 +556,6 @@ def delete(self, external_id: str | SequenceNotStr[str], ignore_unknown_ids: boo >>> client = CogniteClient() >>> client.workflows.delete("my workflow") """ - self._warning.warn() self._delete_multiple( identifiers=IdentifierSequence.load(external_ids=external_id), params={"ignoreUnknownIds": ignore_unknown_ids}, @@ -609,8 +578,6 @@ def list(self, limit: int = DEFAULT_LIMIT_READ) -> WorkflowList: >>> client = CogniteClient() >>> res = client.workflows.list() """ - self._warning.warn() - return self._list( method="GET", resource_cls=Workflow, diff --git a/cognite/client/_version.py b/cognite/client/_version.py index 68ccb80c68..e719d37aac 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.47.0" +__version__ = "7.48.0" __api_subversion__ = "20230101" diff --git a/pyproject.toml b/pyproject.toml index 529bd1f1cf..d6c917bc82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.47.0" +version = "7.48.0" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com" diff --git a/tests/tests_unit/test_testing.py b/tests/tests_unit/test_testing.py index 1c1a484532..4f7bbf1865 100644 --- a/tests/tests_unit/test_testing.py +++ b/tests/tests_unit/test_testing.py @@ -3,7 +3,6 @@ import pytest from cognite.client import ClientConfig, CogniteClient -from cognite.client._api.workflows import BetaWorkflowAPIClient from cognite.client._api_client import APIClient from cognite.client.credentials import Token from cognite.client.testing import CogniteClientMock, monkeypatch_cognite_client @@ -13,7 +12,7 @@ def test_ensure_all_apis_are_available_on_cognite_mock(): mocked_apis = all_mock_children(CogniteClientMock()) available = {v.__class__ for v in mocked_apis.values()} - expected = set(all_subclasses(APIClient)) - {BetaWorkflowAPIClient} + expected = set(all_subclasses(APIClient)) # Any new APIs that have not been added to CogniteClientMock? assert not expected.difference(available), f"Missing APIs: {expected.difference(available)}" # Any removed APIs that are still available on CogniteClientMock?