Skip to content

Commit

Permalink
Mark data workflows as GA (#1778)
Browse files Browse the repository at this point in the history
Data Workflows going into GA 💯
- Remove maturity warning for both the SDK (alpha -> GA) and API (Beta -> GA)
  • Loading branch information
VerstraeteBert authored Jun 4, 2024
1 parent 5678a0d commit 4a6bf55
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 41 deletions.
4 changes: 4 additions & 0 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.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`.
Expand Down
41 changes: 4 additions & 37 deletions cognite/client/_api/workflows.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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={
Expand Down Expand Up @@ -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
)
Expand All @@ -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:
Expand Down Expand Up @@ -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.")

Expand Down Expand Up @@ -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),
Expand All @@ -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, '')}",
Expand Down Expand Up @@ -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:
Expand All @@ -499,7 +471,7 @@ def list(
)


class WorkflowAPI(BetaWorkflowAPIClient):
class WorkflowAPI(APIClient):
_RESOURCE_PATH = "/workflows"

def __init__(
Expand Down Expand Up @@ -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.")

Expand All @@ -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:
Expand All @@ -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},
Expand All @@ -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,
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.47.0"
__version__ = "7.48.0"
__api_subversion__ = "20230101"
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.47.0"
version = "7.48.0"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
3 changes: 1 addition & 2 deletions tests/tests_unit/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down

0 comments on commit 4a6bf55

Please sign in to comment.