Skip to content

Commit e218c06

Browse files
v1r3nmp-orkes
andauthored
Support for older python versions (#242)
Co-authored-by: Miguel Prieto <miguel.prieto@orkes.io>
1 parent 5e76647 commit e218c06

23 files changed

+62
-48
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG SDK_ORIGIN=no_sdk
22

3-
FROM python:3.11-alpine as python_base
3+
FROM python:3.7-alpine as python_base
44
RUN apk add --no-cache tk
55

66
FROM python_base as python_test_base

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ get_workflow(workflow_id: str, include_tasks: Optional[bool] = True) -> Workflow
691691
Variables inside a workflow are the equivalent of global variables in a program.
692692

693693
```python
694-
update_variables(self, workflow_id: str, variables: dict[str, object] = {})
694+
update_variables(self, workflow_id: str, variables: Dict[str, object] = {})
695695
```
696696

697697
### Terminate Running Workflows

examples/orkes/copilot/open_ai_copilot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import random
44
import string
5-
from typing import List
5+
from typing import List, Dict
66

77
from conductor.client.ai.configuration import LLMProvider
88
from conductor.client.ai.integrations import OpenAIConfig
@@ -71,7 +71,7 @@ def send_email(customer: list[Customer], promo_code: str) -> str:
7171

7272

7373
@worker_task(task_definition_name='create_workflow')
74-
def create_workflow(steps: list[str], inputs: dict[str, object]) -> dict:
74+
def create_workflow(steps: list[str], inputs: Dict[str, object]) -> dict:
7575
executor = OrkesClients().get_workflow_executor()
7676
workflow = ConductorWorkflow(executor=executor, name='copilot_execution', version=1)
7777

src/conductor/client/http/api_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import tempfile
77
import time
88
from typing import Dict
9+
import uuid
910

1011
import six
1112
import urllib3
@@ -198,6 +199,8 @@ def sanitize_for_serialization(self, obj):
198199
for sub_obj in obj)
199200
elif isinstance(obj, (datetime.datetime, datetime.date)):
200201
return obj.isoformat()
202+
elif isinstance(obj, uuid.UUID): # needed for compatibility with Python 3.7
203+
return str(obj) # Convert UUID to string
201204

202205
if isinstance(obj, dict) or isinstance(obj, CaseInsensitiveDict):
203206
obj_dict = obj

src/conductor/client/http/models/schema_def.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pprint
22
from enum import Enum
3+
from typing import Dict
34

45
import six
56

@@ -30,7 +31,7 @@ class SchemaDef(object):
3031
'external_ref': 'externalRef'
3132
}
3233

33-
def __init__(self, name : str =None, version : int =1, type : SchemaType =None, data : dict[str, object] =None,
34+
def __init__(self, name : str =None, version : int =1, type : SchemaType =None, data : Dict[str, object] =None,
3435
external_ref : str =None): # noqa: E501
3536
self._name = None
3637
self._version = None
@@ -104,20 +105,20 @@ def type(self, type:SchemaType):
104105
self._type = type
105106

106107
@property
107-
def data(self) -> dict[str, object]:
108+
def data(self) -> Dict[str, object]:
108109
"""Gets the data of this SchemaDef. # noqa: E501
109110
110111
:return: The data of this SchemaDef. # noqa: E501
111-
:rtype: dict[str, object]
112+
:rtype: Dict[str, object]
112113
"""
113114
return self._data
114115

115116
@data.setter
116-
def data(self, data: dict[str, object]):
117+
def data(self, data: Dict[str, object]):
117118
"""Sets the data of this SchemaDef.
118119
119120
:param data: The data of this SchemaDef. # noqa: E501
120-
:type: dict[str, object]
121+
:type: Dict[str, object]
121122
"""
122123
self._data = data
123124

src/conductor/client/http/models/state_change_event.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import Enum
2-
from typing import Union, List
2+
from typing import Union, List, Dict
33
from typing_extensions import Self
44

55

@@ -14,15 +14,15 @@ class StateChangeEventType(Enum):
1414
class StateChangeEvent:
1515
swagger_types = {
1616
'type': 'str',
17-
'payload': 'dict[str, object]'
17+
'payload': 'Dict[str, object]'
1818
}
1919

2020
attribute_map = {
2121
'type': 'type',
2222
'payload': 'payload'
2323
}
2424

25-
def __init__(self, type: str, payload: dict[str, object]) -> None:
25+
def __init__(self, type: str, payload: Dict[str, object]) -> None:
2626
self._type = type
2727
self._payload = payload
2828

@@ -39,7 +39,7 @@ def payload(self):
3939
return self._payload
4040

4141
@payload.setter
42-
def payload(self, payload: dict[str, object]) -> Self:
42+
def payload(self, payload: Dict[str, object]) -> Self:
4343
self._payload = payload
4444

4545

src/conductor/client/http/models/workflow_state_update.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Dict
12
import pprint
23
import re # noqa: F401
34

@@ -31,7 +32,7 @@ class WorkflowStateUpdate(object):
3132
}
3233

3334
def __init__(self, task_reference_name: str = None, task_result: TaskResult = None,
34-
variables: dict[str, object] = None): # noqa: E501
35+
variables: Dict[str, object] = None): # noqa: E501
3536
"""WorkflowStateUpdate - a model defined in Swagger""" # noqa: E501
3637
self._task_reference_name = None
3738
self._task_result = None
@@ -86,7 +87,7 @@ def task_result(self, task_result: TaskResult):
8687
self._task_result = task_result
8788

8889
@property
89-
def variables(self) -> dict[str, object]:
90+
def variables(self) -> Dict[str, object]:
9091
"""Gets the variables of this WorkflowStateUpdate. # noqa: E501
9192
9293
@@ -96,7 +97,7 @@ def variables(self) -> dict[str, object]:
9697
return self._variables
9798

9899
@variables.setter
99-
def variables(self, variables: dict[str, object]):
100+
def variables(self, variables: Dict[str, object]):
100101
"""Sets the variables of this WorkflowStateUpdate.
101102
102103

src/conductor/client/http/models/workflow_task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pprint
22
import re # noqa: F401
3-
from typing import List
3+
from typing import List, Dict
44

55
import six
66

@@ -124,7 +124,7 @@ def __init__(self, name=None, task_reference_name=None, description=None, input_
124124
sub_workflow_param=None, join_on=None, sink=None, optional=None, task_definition : 'TaskDef' =None,
125125
rate_limited=None, default_exclusive_join_task=None, async_complete=None, loop_condition=None,
126126
loop_over=None, retry_count=None, evaluator_type=None, expression=None,
127-
workflow_task_type=None, on_state_change: dict[str, StateChangeConfig] = None,
127+
workflow_task_type=None, on_state_change: Dict[str, StateChangeConfig] = None,
128128
cache_config: CacheConfig = None): # noqa: E501
129129
"""WorkflowTask - a model defined in Swagger""" # noqa: E501
130130
self._name = None
@@ -850,7 +850,7 @@ def workflow_task_type(self, workflow_task_type):
850850
self._workflow_task_type = workflow_task_type
851851

852852
@property
853-
def on_state_change(self) -> dict[str, List[StateChangeEvent]]:
853+
def on_state_change(self) -> Dict[str, List[StateChangeEvent]]:
854854
return self._on_state_change
855855

856856
@on_state_change.setter

src/conductor/client/orkes/orkes_secret_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from typing import List, Set
22

33
from conductor.client.configuration.configuration import Configuration
44
from conductor.client.orkes.models.metadata_tag import MetadataTag
@@ -16,7 +16,7 @@ def put_secret(self, key: str, value: str):
1616
def get_secret(self, key: str) -> str:
1717
return self.secretResourceApi.get_secret(key)
1818

19-
def list_all_secret_names(self) -> set[str]:
19+
def list_all_secret_names(self) -> Set[str]:
2020
return set(self.secretResourceApi.list_all_secret_names())
2121

2222
def list_secrets_that_user_can_grant_access_to(self) -> List[str]:

src/conductor/client/orkes/orkes_workflow_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, List
1+
from typing import Optional, List, Dict
22

33
from conductor.client.configuration.configuration import Configuration
44
from conductor.client.http.models import SkipTaskRequest, WorkflowStatus, \
@@ -24,7 +24,7 @@ def __init__(
2424
def start_workflow_by_name(
2525
self,
2626
name: str,
27-
input: dict[str, object],
27+
input: Dict[str, object],
2828
version: Optional[int] = None,
2929
correlationId: Optional[str] = None,
3030
priority: Optional[int] = None,
@@ -130,7 +130,7 @@ def get_by_correlation_ids_in_batch(
130130
self,
131131
batch_request: CorrelationIdsSearchRequest,
132132
include_completed: bool = False,
133-
include_tasks: bool = False) -> dict[str, List[Workflow]]:
133+
include_tasks: bool = False) -> Dict[str, List[Workflow]]:
134134

135135
"""Given the list of correlation ids and list of workflow names, find and return workflows
136136
Returns a map with key as correlationId and value as a list of Workflows
@@ -150,7 +150,7 @@ def get_by_correlation_ids(
150150
correlation_ids: List[str],
151151
include_completed: bool = False,
152152
include_tasks: bool = False
153-
) -> dict[str, List[Workflow]]:
153+
) -> Dict[str, List[Workflow]]:
154154
"""Lists workflows for the given correlation id list"""
155155
kwargs = {}
156156
if include_tasks:
@@ -167,7 +167,7 @@ def get_by_correlation_ids(
167167
def remove_workflow(self, workflow_id: str):
168168
self.workflowResourceApi.delete(workflow_id)
169169

170-
def update_variables(self, workflow_id: str, variables: dict[str, object] = {}) -> None:
170+
def update_variables(self, workflow_id: str, variables: Dict[str, object] = {}) -> None:
171171
self.workflowResourceApi.update_workflow_state(variables, workflow_id)
172172

173173
def update_state(self, workflow_id: str, update_requesst: WorkflowStateUpdate,

0 commit comments

Comments
 (0)