Skip to content

Commit

Permalink
Support Workflows (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored Sep 28, 2023
1 parent 7d9535c commit a9d3c06
Show file tree
Hide file tree
Showing 18 changed files with 2,153 additions and 26 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.

## [6.28.0] - 2023-09-26
### Added
- Support for the WorkflowOrchestrationAPI with the implementation `client.workflows`.

## [6.27.0] - 2023-09-13
### Changed
- Reduce concurrency in data modeling client to 1
Expand Down
21 changes: 5 additions & 16 deletions cognite/client/_api/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from cognite.client import utils
from cognite.client._api_client import APIClient
from cognite.client._constants import DEFAULT_LIMIT_READ
from cognite.client.credentials import OAuthClientCertificate
from cognite.client.data_classes import (
ClientCredentials,
Function,
Expand All @@ -34,9 +33,9 @@
TimestampRange,
)
from cognite.client.data_classes.functions import FunctionCallsFilter, FunctionsStatus
from cognite.client.exceptions import CogniteAuthError
from cognite.client.utils._auxiliary import is_unlimited
from cognite.client.utils._identifier import Identifier, IdentifierSequence
from cognite.client.utils._session import create_session_and_return_nonce

if TYPE_CHECKING:
from cognite.client import CogniteClient
Expand Down Expand Up @@ -395,7 +394,7 @@ def call(
"""
identifier = IdentifierSequence.load(ids=id, external_ids=external_id).as_singleton()[0]
id = _get_function_internal_id(self._cognite_client, identifier)
nonce = _create_session_and_return_nonce(self._cognite_client)
nonce = create_session_and_return_nonce(self._cognite_client, api_name="Functions API")

if data is None:
data = {}
Expand Down Expand Up @@ -523,18 +522,6 @@ def status(self) -> FunctionsStatus:
return FunctionsStatus._load(res.json())


def _create_session_and_return_nonce(
client: CogniteClient,
client_credentials: dict | ClientCredentials | None = None,
) -> str:
if client_credentials is None:
if isinstance(client._config.credentials, OAuthClientCertificate):
raise CogniteAuthError("Client certificate credentials is not supported with the Functions API")
elif isinstance(client_credentials, dict):
client_credentials = ClientCredentials(client_credentials["client_id"], client_credentials["client_secret"])
return client.iam.sessions.create(client_credentials).nonce


def get_handle_function_node(file_path: Path) -> ast.FunctionDef | None:
return next(
(
Expand Down Expand Up @@ -1037,7 +1024,9 @@ def create(
"""
_get_function_identifier(function_id, function_external_id)
nonce = _create_session_and_return_nonce(self._cognite_client, client_credentials)
nonce = create_session_and_return_nonce(
self._cognite_client, api_name="Functions API", client_credentials=client_credentials
)
body: dict[str, list[dict[str, str | int | None | dict]]] = {
"items": [
{
Expand Down
Loading

0 comments on commit a9d3c06

Please sign in to comment.