Skip to content

Commit ff0f134

Browse files
update samples to use environment configuration for client (#233)
* update samples to use environment configuration for client * linting fixes * update to direct profile mutation * mutate config as dict * update client config usage * Update temporalio dependency (includes optional profile commit) * remove unused toml & util * Update SDK version to 1.18 (#247) * Update SDK version to 1.18 * Update openai breaking change * update samples to use environment configuration for client * linting fixes * update to direct profile mutation * update new samples to use envconfig * linting again * remove redundant files/code --------- Co-authored-by: tconley1428 <timothy.conley@temporal.io>
1 parent 092eaad commit ff0f134

File tree

127 files changed

+728
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+728
-293
lines changed

activity_worker/activity_worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from temporalio import activity
66
from temporalio.client import Client
7+
from temporalio.envconfig import ClientConfig
78
from temporalio.worker import Worker
89

910
task_queue = "say-hello-task-queue"
@@ -18,7 +19,9 @@ async def say_hello_activity(name: str) -> str:
1819

1920
async def main():
2021
# Create client to localhost on default namespace
21-
client = await Client.connect("localhost:7233")
22+
config = ClientConfig.load_client_connect_config()
23+
config.setdefault("target_host", "localhost:7233")
24+
client = await Client.connect(**config)
2225

2326
# Run activity worker
2427
async with Worker(client, task_queue=task_queue, activities=[say_hello_activity]):

batch_sliding_window/starter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77

88
from temporalio.client import Client
9+
from temporalio.envconfig import ClientConfig
910

1011
from batch_sliding_window.batch_workflow import (
1112
ProcessBatchWorkflow,
@@ -19,7 +20,9 @@ async def main():
1920
logging.basicConfig(level=logging.INFO)
2021

2122
# Create client
22-
client = await Client.connect("localhost:7233")
23+
config = ClientConfig.load_client_connect_config()
24+
config.setdefault("target_host", "localhost:7233")
25+
client = await Client.connect(**config)
2326

2427
# Create unique workflow ID with timestamp
2528
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")

batch_sliding_window/worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from temporalio import worker
88
from temporalio.client import Client
9+
from temporalio.envconfig import ClientConfig
910

1011
from batch_sliding_window.batch_workflow import ProcessBatchWorkflow
1112
from batch_sliding_window.record_loader_activity import RecordLoader
@@ -19,7 +20,9 @@ async def main():
1920
logging.basicConfig(level=logging.INFO)
2021

2122
# Create client
22-
client = await Client.connect("localhost:7233")
23+
config = ClientConfig.load_client_connect_config()
24+
config.setdefault("target_host", "localhost:7233")
25+
client = await Client.connect(**config)
2326

2427
# Create RecordLoader activity with sample data
2528
record_loader = RecordLoader(record_count=90)

bedrock/basic/run_worker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44

55
from temporalio.client import Client
6+
from temporalio.envconfig import ClientConfig
67
from temporalio.worker import Worker
78
from workflows import BasicBedrockWorkflow
89

@@ -11,7 +12,10 @@
1112

1213
async def main():
1314
# Create client connected to server at the given address
14-
client = await Client.connect("localhost:7233")
15+
config = ClientConfig.load_client_connect_config()
16+
config.setdefault("target_host", "localhost:7233")
17+
client = await Client.connect(**config)
18+
1519
activities = BedrockActivities()
1620

1721
# Run the worker

bedrock/basic/send_message.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import sys
33

44
from temporalio.client import Client
5+
from temporalio.envconfig import ClientConfig
56
from workflows import BasicBedrockWorkflow
67

78

89
async def main(prompt: str) -> str:
910
# Create client connected to server at the given address
10-
client = await Client.connect("localhost:7233")
11+
config = ClientConfig.load_client_connect_config()
12+
config.setdefault("target_host", "localhost:7233")
13+
client = await Client.connect(**config)
1114

1215
# Start the workflow
1316
workflow_id = "basic-bedrock-workflow"

bedrock/entity/end_chat.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import sys
33

44
from temporalio.client import Client
5+
from temporalio.envconfig import ClientConfig
56
from workflows import EntityBedrockWorkflow
67

78

89
async def main():
910
# Create client connected to server at the given address
10-
client = await Client.connect("localhost:7233")
11+
config = ClientConfig.load_client_connect_config()
12+
config.setdefault("target_host", "localhost:7233")
13+
client = await Client.connect(**config)
1114

1215
workflow_id = "entity-bedrock-workflow"
1316

bedrock/entity/get_history.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import asyncio
22

33
from temporalio.client import Client
4+
from temporalio.envconfig import ClientConfig
45
from workflows import EntityBedrockWorkflow
56

67

78
async def main():
89
# Create client connected to server at the given address
9-
client = await Client.connect("localhost:7233")
10+
config = ClientConfig.load_client_connect_config()
11+
config.setdefault("target_host", "localhost:7233")
12+
client = await Client.connect(**config)
13+
1014
workflow_id = "entity-bedrock-workflow"
1115

1216
handle = client.get_workflow_handle(workflow_id)

bedrock/entity/run_worker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44

55
from temporalio.client import Client
6+
from temporalio.envconfig import ClientConfig
67
from temporalio.worker import Worker
78
from workflows import EntityBedrockWorkflow
89

@@ -11,7 +12,10 @@
1112

1213
async def main():
1314
# Create client connected to server at the given address
14-
client = await Client.connect("localhost:7233")
15+
config = ClientConfig.load_client_connect_config()
16+
config.setdefault("target_host", "localhost:7233")
17+
client = await Client.connect(**config)
18+
1519
activities = BedrockActivities()
1620

1721
# Run the worker

bedrock/entity/send_message.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import sys
33

44
from temporalio.client import Client
5+
from temporalio.envconfig import ClientConfig
56
from workflows import BedrockParams, EntityBedrockWorkflow
67

78

89
async def main(prompt):
910
# Create client connected to server at the given address
10-
client = await Client.connect("localhost:7233")
11+
config = ClientConfig.load_client_connect_config()
12+
config.setdefault("target_host", "localhost:7233")
13+
client = await Client.connect(**config)
1114

1215
workflow_id = "entity-bedrock-workflow"
1316

bedrock/signals_and_queries/get_history.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import asyncio
22

33
from temporalio.client import Client
4+
from temporalio.envconfig import ClientConfig
45
from workflows import SignalQueryBedrockWorkflow
56

67

78
async def main():
89
# Create client connected to server at the given address
9-
client = await Client.connect("localhost:7233")
10+
config = ClientConfig.load_client_connect_config()
11+
config.setdefault("target_host", "localhost:7233")
12+
client = await Client.connect(**config)
13+
1014
workflow_id = "bedrock-workflow-with-signals"
1115

1216
handle = client.get_workflow_handle(workflow_id)

0 commit comments

Comments
 (0)