Skip to content

Commit e2a0596

Browse files
committed
Ugh, StrEnum only 3.11
1 parent 800c123 commit e2a0596

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

nexus_multiple_args/caller/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from temporalio.worker import Worker
77

88
from nexus_multiple_args.caller.workflows import CallerWorkflow
9-
from nexus_multiple_args.service import Language
109

1110
NAMESPACE = "nexus-multiple-args-caller-namespace"
1211
TASK_QUEUE = "nexus-multiple-args-caller-task-queue"
@@ -28,15 +27,15 @@ async def execute_caller_workflow(
2827
# Execute workflow with English language
2928
result1 = await client.execute_workflow(
3029
CallerWorkflow.run,
31-
args=["Nexus", Language.EN],
30+
args=["Nexus", "en"],
3231
id=str(uuid.uuid4()),
3332
task_queue=TASK_QUEUE,
3433
)
3534

3635
# Execute workflow with Spanish language
3736
result2 = await client.execute_workflow(
3837
CallerWorkflow.run,
39-
args=["Nexus", Language.ES],
38+
args=["Nexus", "es"],
4039
id=str(uuid.uuid4()),
4140
task_queue=TASK_QUEUE,
4241
)

nexus_multiple_args/caller/workflows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from temporalio import workflow
22

33
with workflow.unsafe.imports_passed_through():
4-
from nexus_multiple_args.service import HelloInput, Language, MyNexusService
4+
from nexus_multiple_args.service import HelloInput, MyNexusService
55

66
NEXUS_ENDPOINT = "nexus-multiple-args-nexus-endpoint"
77

@@ -20,7 +20,7 @@ def __init__(self):
2020
# The workflow run method demonstrates calling a nexus operation with multiple arguments
2121
# packed into an input object.
2222
@workflow.run
23-
async def run(self, name: str, language: Language) -> str:
23+
async def run(self, name: str, language: str) -> str:
2424
# Start the nexus operation and wait for the result in one go, using execute_operation.
2525
# The multiple arguments (name and language) are packed into a HelloInput object.
2626
result = await self.nexus_client.execute_operation(

nexus_multiple_args/handler/workflows.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
from temporalio import workflow
22

33
with workflow.unsafe.imports_passed_through():
4-
from nexus_multiple_args.service import HelloInput, HelloOutput, Language
4+
from nexus_multiple_args.service import HelloOutput
55

66

77
# This is the workflow that is started by the `hello` nexus operation.
88
# It demonstrates handling multiple arguments passed from the Nexus service.
99
@workflow.defn
1010
class HelloHandlerWorkflow:
1111
@workflow.run
12-
async def run(self, name: str, language: Language) -> HelloOutput:
12+
async def run(self, name: str, language: str) -> HelloOutput:
1313
"""
1414
Handle the hello workflow with multiple arguments.
1515
1616
This method receives the individual arguments (name and language)
1717
that were unpacked from the HelloInput in the service handler.
1818
"""
19-
if language == Language.EN:
19+
if language == "en":
2020
message = f"Hello {name} 👋"
21-
elif language == Language.FR:
21+
elif language == "fr":
2222
message = f"Bonjour {name} 👋"
23-
elif language == Language.DE:
23+
elif language == "de":
2424
message = f"Hallo {name} 👋"
25-
elif language == Language.ES:
25+
elif language == "es":
2626
message = f"¡Hola! {name} 👋"
27-
elif language == Language.TR:
27+
elif language == "tr":
2828
message = f"Merhaba {name} 👋"
2929
else:
3030
raise ValueError(f"Unsupported language: {language}")

nexus_multiple_args/service.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,14 @@
1414
"""
1515

1616
from dataclasses import dataclass
17-
from enum import StrEnum
1817

1918
import nexusrpc
2019

2120

22-
class Language(StrEnum):
23-
EN = "EN"
24-
FR = "FR"
25-
DE = "DE"
26-
ES = "ES"
27-
TR = "TR"
28-
29-
3021
@dataclass
3122
class HelloInput:
3223
name: str
33-
language: Language
24+
language: str
3425

3526

3627
@dataclass

0 commit comments

Comments
 (0)