Skip to content

Commit baecf3d

Browse files
feat(workflows): add maxConcurrentExecutions support (#2479)
1 parent c18ef7f commit baecf3d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

cognite/client/data_classes/workflows.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@
4545

4646

4747
class WorkflowCore(WriteableCogniteResource["WorkflowUpsert"], ABC):
48-
def __init__(self, external_id: str, description: str | None = None, data_set_id: int | None = None) -> None:
48+
def __init__(
49+
self,
50+
external_id: str,
51+
description: str | None = None,
52+
data_set_id: int | None = None,
53+
max_concurrent_executions: int | None = None,
54+
) -> None:
4955
self.external_id = external_id
5056
self.description = description
5157
self.data_set_id = data_set_id
58+
self.max_concurrent_executions = max_concurrent_executions
5259

5360

5461
class WorkflowUpsert(WorkflowCore):
@@ -64,6 +71,9 @@ class WorkflowUpsert(WorkflowCore):
6471
If a dataSetId is provided, any operations on this workflow, or its versions, executions,
6572
and triggers will require appropriate access to the data set. More information on data sets
6673
and their configuration can be found here: https://docs.cognite.com/cdf/data_governance/concepts/datasets/
74+
max_concurrent_executions (int | None): Maximum concurrent executions for this workflow. Defaults to the
75+
project limit if not specified or explicitly set to None. Values exceeding the project limit
76+
are dynamically capped at runtime.
6777
"""
6878

6979
@classmethod
@@ -72,6 +82,7 @@ def _load(cls, resource: dict, cognite_client: CogniteClient | None = None) -> S
7282
external_id=resource["externalId"],
7383
description=resource.get("description"),
7484
data_set_id=resource.get("dataSetId"),
85+
max_concurrent_executions=resource.get("maxConcurrentExecutions"),
7586
)
7687

7788
def as_write(self) -> WorkflowUpsert:
@@ -89,6 +100,9 @@ class Workflow(WorkflowCore):
89100
last_updated_time (int): The time when the workflow was last updated. Unix timestamp in milliseconds.
90101
description (str | None): Description of the workflow. Defaults to None.
91102
data_set_id (int | None): The id of the data set this workflow belongs to.
103+
max_concurrent_executions (int | None): Maximum concurrent executions for this workflow. Defaults to the
104+
project limit if not specified or explicitly set to None. Values exceeding the project limit
105+
are dynamically capped at runtime.
92106
"""
93107

94108
def __init__(
@@ -98,8 +112,9 @@ def __init__(
98112
last_updated_time: int,
99113
description: str | None = None,
100114
data_set_id: int | None = None,
115+
max_concurrent_executions: int | None = None,
101116
) -> None:
102-
super().__init__(external_id, description, data_set_id)
117+
super().__init__(external_id, description, data_set_id, max_concurrent_executions)
103118
self.created_time = created_time
104119
self.last_updated_time = last_updated_time
105120

@@ -111,6 +126,7 @@ def _load(cls, resource: dict, cognite_client: CogniteClient | None = None) -> S
111126
created_time=resource["createdTime"],
112127
last_updated_time=resource["lastUpdatedTime"],
113128
data_set_id=resource.get("dataSetId"),
129+
max_concurrent_executions=resource.get("maxConcurrentExecutions"),
114130
)
115131

116132
def as_write(self) -> WorkflowUpsert:
@@ -119,6 +135,7 @@ def as_write(self) -> WorkflowUpsert:
119135
external_id=self.external_id,
120136
description=self.description,
121137
data_set_id=self.data_set_id,
138+
max_concurrent_executions=self.max_concurrent_executions,
122139
)
123140

124141

0 commit comments

Comments
 (0)