From 3033cb1d3acc05ed26c7af9672680d3e9ed37d38 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 11 Aug 2025 22:57:26 -0400 Subject: [PATCH 01/14] update samples to use environment configuration for client --- activity_worker/activity_worker.py | 9 ++++++- batch_sliding_window/starter.py | 7 +++++- batch_sliding_window/worker.py | 7 +++++- bedrock/basic/run_worker.py | 7 +++++- bedrock/basic/send_message.py | 7 +++++- bedrock/entity/end_chat.py | 7 +++++- bedrock/entity/get_history.py | 7 +++++- bedrock/entity/run_worker.py | 7 +++++- bedrock/entity/send_message.py | 7 +++++- bedrock/signals_and_queries/get_history.py | 7 +++++- bedrock/signals_and_queries/run_worker.py | 7 +++++- bedrock/signals_and_queries/send_message.py | 7 +++++- cloud_export_to_parquet/create_schedule.py | 7 +++++- cloud_export_to_parquet/run_worker.py | 7 +++++- context_propagation/starter.py | 23 +++++++++++++---- context_propagation/worker.py | 23 +++++++++++++---- custom_converter/starter.py | 22 +++++++++++----- custom_converter/worker.py | 22 +++++++++++----- custom_decorator/starter.py | 7 +++++- custom_decorator/worker.py | 7 +++++- dsl/starter.py | 9 ++++++- dsl/worker.py | 9 ++++++- encryption/starter.py | 18 +++++++------ encryption/worker.py | 24 ++++++++++++------ gevent_async/starter.py | 7 +++++- gevent_async/worker.py | 7 +++++- hello/hello_activity.py | 9 ++++++- hello/hello_activity_async.py | 7 +++++- hello/hello_activity_choice.py | 12 ++++++++- hello/hello_activity_heartbeat.py | 7 +++++- hello/hello_activity_method.py | 7 +++++- hello/hello_activity_multiprocess.py | 7 +++++- hello/hello_activity_retry.py | 7 +++++- hello/hello_async_activity_completion.py | 7 +++++- hello/hello_cancellation.py | 12 ++++++++- hello/hello_change_log_level.py | 11 +++++++- hello/hello_child_workflow.py | 12 ++++++++- hello/hello_continue_as_new.py | 7 +++++- hello/hello_cron.py | 7 +++++- hello/hello_exception.py | 7 +++++- hello/hello_local_activity.py | 7 +++++- hello/hello_parallel_activity.py | 7 +++++- hello/hello_patch.py | 7 +++++- hello/hello_query.py | 12 ++++++++- hello/hello_search_attributes.py | 7 +++++- hello/hello_signal.py | 12 ++++++++- hello/hello_update.py | 11 +++++++- hello_nexus/caller/app.py | 18 ++++++++++--- hello_nexus/handler/worker.py | 18 ++++++++++--- langchain/starter.py | 17 ++++++++++--- langchain/worker.py | 7 +++++- message_passing/introduction/starter.py | 14 ++++++++++- message_passing/introduction/worker.py | 11 +++++++- .../safe_message_handlers/starter.py | 9 ++++++- .../safe_message_handlers/worker.py | 9 ++++++- .../lazy_initialization/starter.py | 13 +++++++--- .../lazy_initialization/worker.py | 11 +++++++- .../waiting_for_handlers/starter.py | 10 +++++++- .../waiting_for_handlers/worker.py | 11 +++++++- .../starter.py | 13 +++++++++- .../worker.py | 11 +++++++- open_telemetry/starter.py | 25 ++++++++++++++----- open_telemetry/worker.py | 25 ++++++++++++++----- .../basic/run_agent_lifecycle_workflow.py | 7 +++++- .../basic/run_remote_image_workflow.py | 22 +++++++++++----- .../handoffs/run_message_filter_workflow.py | 19 +++++++++----- patching/starter.py | 9 ++++++- patching/worker.py | 7 +++++- polling/frequent/run_frequent.py | 7 +++++- polling/frequent/run_worker.py | 7 +++++- polling/infrequent/run_infrequent.py | 7 +++++- polling/infrequent/run_worker.py | 7 +++++- polling/periodic_sequence/run_periodic.py | 7 +++++- polling/periodic_sequence/run_worker.py | 7 +++++- prometheus/starter.py | 21 +++++++++++++--- prometheus/worker.py | 21 +++++++++++++--- pydantic_converter/starter.py | 21 +++++++++++++--- pydantic_converter/worker.py | 21 +++++++++++++--- pydantic_converter_v1/starter.py | 21 +++++++++++++--- pydantic_converter_v1/worker.py | 21 +++++++++++++--- replay/replayer.py | 7 +++++- replay/starter.py | 7 +++++- replay/worker.py | 7 +++++- resource_pool/starter.py | 7 +++++- resource_pool/worker.py | 7 +++++- schedules/backfill_schedule.py | 7 +++++- schedules/delete_schedule.py | 7 +++++- schedules/describe_schedule.py | 7 +++++- schedules/list_schedule.py | 7 +++++- schedules/pause_schedule.py | 7 +++++- schedules/run_worker.py | 7 +++++- schedules/start_schedule.py | 7 +++++- schedules/trigger_schedule.py | 7 +++++- schedules/update_schedule.py | 7 +++++- sentry/starter.py | 15 ++++++++++- sentry/worker.py | 15 ++++++++++- sleep_for_days/starter.py | 14 ++++++++++- sleep_for_days/worker.py | 7 +++++- temporal.toml | 4 +++ trio_async/starter.py | 7 +++++- trio_async/worker.py | 7 +++++- updatable_timer/starter.py | 14 ++++++++++- updatable_timer/wake_up_time_updater.py | 14 ++++++++++- updatable_timer/worker.py | 11 +++++++- util.py | 15 +++++++++++ worker_specific_task_queues/starter.py | 7 +++++- worker_specific_task_queues/worker.py | 7 +++++- 107 files changed, 970 insertions(+), 179 deletions(-) create mode 100644 temporal.toml create mode 100644 util.py diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 3e613169..8ffa1fb6 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -1,9 +1,11 @@ import asyncio import random import string +from pathlib import Path from temporalio import activity from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker task_queue = "say-hello-task-queue" @@ -18,7 +20,12 @@ async def say_hello_activity(name: str) -> str: async def main(): # Create client to localhost on default namespace - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run activity worker async with Worker(client, task_queue=task_queue, activities=[say_hello_activity]): diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index d9a24971..2305abcf 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -19,7 +19,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Create unique workflow ID with timestamp timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index c0968bc3..850d90e5 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -19,7 +19,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Create RecordLoader activity with sample data record_loader = RecordLoader(record_count=90) diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index fee8aa5d..9385fdce 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -11,7 +11,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 1b4cc995..04380cf0 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -7,7 +7,12 @@ async def main(prompt: str) -> str: # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Start the workflow workflow_id = "basic-bedrock-workflow" diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 49125306..e279dec0 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -7,7 +7,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index 1600886e..9e1787d4 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -6,7 +6,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" handle = client.get_workflow_handle(workflow_id) diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 3e3b1e64..32ad137d 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -11,7 +11,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 177b4b69..4e5f48bc 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -7,7 +7,12 @@ async def main(prompt): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index 0bdf0861..80b6a205 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -6,7 +6,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" handle = client.get_workflow_handle(workflow_id) diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index b3e709a9..489d4e45 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -11,7 +11,12 @@ async def main(): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 67b8b37e..3a3f627f 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -7,7 +7,12 @@ async def main(prompt): # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" inactivity_timeout_minutes = 1 diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index f425d4c6..0cb97711 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -20,7 +20,12 @@ async def main() -> None: """Main function to run temporal workflow.""" # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # TODO: update s3_bucket and namespace to the actual usecase wf_input = ProtoToParquetWorkflowInput( num_delay_hour=2, diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index df02de11..4a8fd174 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -18,7 +18,12 @@ async def main() -> None: """Main worker function.""" # Create client connected to server at the given address - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run the worker worker: Worker = Worker( diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 2865eee2..491a6c4c 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from context_propagation import interceptor, shared, workflows @@ -12,12 +14,23 @@ async def main(): # Set the user ID shared.user_id.set("some-user") + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Use our interceptor + config["interceptors"] = [interceptor.ContextPropagationInterceptor()] + # Connect client - client = await Client.connect( - "localhost:7233", - # Use our interceptor - interceptors=[interceptor.ContextPropagationInterceptor()], - ) + client = await Client.connect(**config) # Start workflow, send signal, wait for completion, issue query handle = await client.start_workflow( diff --git a/context_propagation/worker.py b/context_propagation/worker.py index 14d954da..c7f7fb43 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows @@ -12,12 +14,23 @@ async def main(): logging.basicConfig(level=logging.INFO) + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Use our interceptor + config["interceptors"] = [interceptor.ContextPropagationInterceptor()] + # Connect client - client = await Client.connect( - "localhost:7233", - # Use our interceptor - interceptors=[interceptor.ContextPropagationInterceptor()], - ) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 54fdf162..a3618cd3 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,6 +1,8 @@ import asyncio +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from custom_converter.shared import ( GreetingInput, @@ -11,13 +13,21 @@ async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Without this we get: + # TypeError: Object of type GreetingInput is not JSON serializable + config["data_converter"] = greeting_data_converter + # Connect client - client = await Client.connect( - "localhost:7233", - # Without this we get: - # TypeError: Object of type GreetingInput is not JSON serializable - data_converter=greeting_data_converter, - ) + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/custom_converter/worker.py b/custom_converter/worker.py index 96214cdd..17291541 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,6 +1,8 @@ import asyncio +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_converter.shared import greeting_data_converter @@ -10,13 +12,21 @@ async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Without this, when trying to run a workflow, we get: + # KeyError: 'Unknown payload encoding my-greeting-encoding + config["data_converter"] = greeting_data_converter + # Connect client - client = await Client.connect( - "localhost:7233", - # Without this, when trying to run a workflow, we get: - # KeyError: 'Unknown payload encoding my-greeting-encoding - data_converter=greeting_data_converter, - ) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index 98bf542f..bb33026f 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -7,7 +7,12 @@ async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Start the workflow handle = await client.start_workflow( diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index 7d0d25ca..4c09d231 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -51,7 +51,12 @@ def cancel_activity(self) -> None: async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/dsl/starter.py b/dsl/starter.py index e530b10e..a8b13216 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -2,10 +2,12 @@ import logging import sys import uuid +from pathlib import Path import dacite import yaml from temporalio.client import Client +from temporalio.envconfig import ClientConfig from dsl.workflow import DSLInput, DSLWorkflow @@ -16,7 +18,12 @@ async def main(dsl_yaml: str) -> None: dsl_input = dacite.from_dict(DSLInput, yaml.safe_load(dsl_yaml)) # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/dsl/worker.py b/dsl/worker.py index 9945492e..d24fa132 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from dsl.activities import DSLActivities @@ -12,7 +14,12 @@ async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the activities and workflow activities = DSLActivities() diff --git a/encryption/starter.py b/encryption/starter.py index 4c39f553..5797a6ce 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -3,20 +3,24 @@ import temporalio.converter from temporalio.client import Client +from temporalio.envconfig import ClientConfig from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Connect client - client = await Client.connect( - "localhost:7233", - # Use the default converter, but change the codec - data_converter=dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() - ), + # Load configuration + config = ClientConfig.load_client_connect_config(config_file=str(get_temporal_config_path())) + config["target_host"] = "localhost:7233" + # Use the default converter, but change the codec + config["data_converter"] = dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() ) + + # Connect client + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/encryption/worker.py b/encryption/worker.py index b99a2eab..efd8e242 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -1,9 +1,11 @@ import asyncio import dataclasses +from pathlib import Path import temporalio.converter from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from encryption.codec import EncryptionCodec @@ -20,14 +22,22 @@ async def run(self, name: str) -> str: async def main(): - # Connect client - client = await Client.connect( - "localhost:7233", - # Use the default converter, but change the codec - data_converter=dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() - ), + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Use the default converter, but change the codec + config["data_converter"] = dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() ) + + # Connect client + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 43e8356b..ba85155d 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -24,7 +24,12 @@ def main(): async def async_main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 9b4945cf..f0d558b8 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -39,7 +39,12 @@ async def async_main(): ) # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Create an executor for use by Temporal. This cannot be the outer one # running this async main. The max_workers here needs to have enough room to diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 13b5fcbb..14b53ab5 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -5,8 +5,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -42,8 +45,12 @@ async def main(): # import logging # logging.basicConfig(level=logging.INFO) + # Load configuration + config = ClientConfig.load_client_connect_config(config_file=str(get_temporal_config_path())) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index fd14a2cf..39b2de75 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -42,7 +42,12 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index 7d01b019..0f266a0f 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -80,8 +80,18 @@ async def run(self, shopping_list: ShoppingList) -> str: async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 230621d3..b80f1662 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -41,7 +41,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index db527263..e4d8060a 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -32,7 +32,12 @@ async def run(self) -> None: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Create our database client that can then be used in the activity db_client = MyDatabaseClient() diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index 6630234d..2e7dc5c8 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -43,7 +43,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index f1acd529..49a20233 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -45,7 +45,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 10aa89df..c3f72e3d 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -68,7 +68,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow composer = GreetingComposer(client) diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 5bf38a66..1de78827 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -50,8 +50,18 @@ async def run(self) -> None: async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 89bb2e1d..0b856fae 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -50,7 +50,16 @@ async def run(self): async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, task_queue="hello-change-log-level-task-queue", diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 2be0bc1b..61251365 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -31,8 +31,18 @@ async def run(self, name: str) -> str: async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index 586aac1d..97cfab62 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -22,7 +22,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_cron.py b/hello/hello_cron.py index dbb5cba6..e5b3e5f9 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -33,7 +33,12 @@ async def run(self, name: str) -> None: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_exception.py b/hello/hello_exception.py index 628c10c5..ba4203d5 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -39,7 +39,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 374c29c5..21a080c8 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -32,7 +32,12 @@ async def run(self, name: str) -> str: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index b32b02bb..1bb80f88 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -41,7 +41,12 @@ async def run(self) -> List[str]: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_patch.py b/hello/hello_patch.py index e511ad5b..ca39bb47 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -101,7 +101,12 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Set workflow_class to the proper class based on version workflow_class = "" diff --git a/hello/hello_query.py b/hello/hello_query.py index 8deb30ba..9d06e9a1 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -26,8 +26,18 @@ def greeting(self) -> str: async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index 8b504ea6..efb91c1f 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -16,7 +16,12 @@ async def run(self) -> None: async def main(): # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_signal.py b/hello/hello_signal.py index a4f9b554..cbf8ffc0 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -40,8 +40,18 @@ def exit(self) -> None: async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_update.py b/hello/hello_update.py index 111d95b1..2ab6aadf 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -22,7 +22,16 @@ async def update_workflow_status(self) -> str: async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 40785b90..34b790eb 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -1,8 +1,10 @@ import asyncio import uuid +from pathlib import Path from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.caller.workflows import CallerWorkflow @@ -15,10 +17,18 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[MyOutput, MyOutput]: - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if not client: + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["namespace"] = NAMESPACE + client = await Client.connect(**config) async with Worker( client, diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index 0bdd6c01..cb6736d3 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -1,8 +1,10 @@ import asyncio import logging +from pathlib import Path from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.handler.service_handler import MyNexusServiceHandler @@ -17,10 +19,18 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if not client: + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["namespace"] = NAMESPACE + client = await Client.connect(**config) # Start the worker, passing the Nexus service handler instance, in addition to the # workflow classes that are started by your nexus operations, and any activities diff --git a/langchain/starter.py b/langchain/starter.py index 2e3d0d5a..a9ef33f6 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -1,4 +1,5 @@ from contextlib import asynccontextmanager +from pathlib import Path from typing import List from uuid import uuid4 @@ -7,14 +8,24 @@ from fastapi import FastAPI, HTTPException from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflow import LangChainWorkflow, TranslateWorkflowParams @asynccontextmanager async def lifespan(app: FastAPI): - app.state.temporal_client = await Client.connect( - "localhost:7233", interceptors=[LangChainContextPropagationInterceptor()] - ) + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["interceptors"] = [LangChainContextPropagationInterceptor()] + + app.state.temporal_client = await Client.connect(**config) yield diff --git a/langchain/worker.py b/langchain/worker.py index 1b680432..54f0beb7 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -10,7 +10,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, task_queue="langchain-task-queue", diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index b71dd44d..ca58bf63 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -1,7 +1,9 @@ import asyncio +from pathlib import Path from typing import Optional from temporalio.client import Client, WorkflowUpdateStage +from temporalio.envconfig import ClientConfig from message_passing.introduction import TASK_QUEUE from message_passing.introduction.workflows import ( @@ -14,7 +16,17 @@ async def main(client: Optional[Client] = None): - client = client or await Client.connect("localhost:7233") + if not client: + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) wf_handle = await client.start_workflow( GreetingWorkflow.run, id="greeting-workflow-1234", diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 25f4121f..fda7fded 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.introduction import TASK_QUEUE @@ -14,7 +16,14 @@ async def main(): logging.basicConfig(level=logging.INFO) - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 7ffe13d9..5f47e5c9 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -2,10 +2,12 @@ import asyncio import logging import uuid +from pathlib import Path from typing import Optional from temporalio import common from temporalio.client import Client, WorkflowHandle +from temporalio.envconfig import ClientConfig from message_passing.safe_message_handlers.workflow import ( ClusterManagerAssignNodesToJobInput, @@ -54,7 +56,12 @@ async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] async def main(should_test_continue_as_new: bool): # Connect to Temporal - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) print("Starting cluster") cluster_manager_handle = await client.start_workflow( diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index 34e71290..d225dc9a 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.safe_message_handlers.workflow import ( @@ -16,7 +18,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index b3274f9d..63c10ba8 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -1,5 +1,6 @@ import asyncio import uuid +from pathlib import Path from typing import Optional, Tuple from temporalio import common @@ -9,6 +10,7 @@ WorkflowHandle, WorkflowUpdateFailedError, ) +from temporalio.envconfig import ClientConfig from temporalio.exceptions import ApplicationError from message_passing.update_with_start.lazy_initialization import TASK_QUEUE @@ -61,12 +63,17 @@ async def handle_add_item_request( async def main(): print("🛒") session_id = f"session-{uuid.uuid4()}" - temporal_client = await Client.connect("localhost:7233") + # Get repo root - 3 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) subtotal_1, _ = await handle_add_item_request( - session_id, "sku-123", 1, temporal_client + session_id, "sku-123", 1, client ) subtotal_2, wf_handle = await handle_add_item_request( - session_id, "sku-456", 1, temporal_client + session_id, "sku-456", 1, client ) print(f"subtotals were, {[subtotal_1, subtotal_2]}") await wf_handle.signal(ShoppingCartWorkflow.checkout) diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index 1964b43e..a25f5962 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows @@ -13,7 +15,14 @@ async def main(): logging.basicConfig(level=logging.INFO) - client = await Client.connect("localhost:7233") + # Get repo root - 3 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent.parent + + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 908095c5..4299b611 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,6 +1,8 @@ import asyncio +from pathlib import Path from temporalio import client, common +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers import ( TASK_QUEUE, @@ -12,7 +14,13 @@ async def starter(exit_type: WorkflowExitType): - cl = await client.Client.connect("localhost:7233") + # Get repo root - we know message_passing/waiting_for_handlers/ is two levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersWorkflow.run, WorkflowInput(exit_type=exit_type), diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 9eea60a3..b4032876 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers import TASK_QUEUE @@ -16,7 +18,14 @@ async def main(): logging.basicConfig(level=logging.INFO) - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index 812bee5f..5c3d73ae 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,6 +1,8 @@ import asyncio +from pathlib import Path from temporalio import client, common +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers_and_compensation import ( TASK_QUEUE, @@ -14,7 +16,16 @@ async def starter(exit_type: WorkflowExitType): - cl = await client.Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersAndCompensationWorkflow.run, WorkflowInput(exit_type=exit_type), diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 7daf768f..3f666f63 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers_and_compensation import TASK_QUEUE @@ -20,7 +22,14 @@ async def main(): logging.basicConfig(level=logging.INFO) - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 86360368..5d4a43b4 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -1,7 +1,9 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor +from temporalio.envconfig import ClientConfig from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry @@ -9,13 +11,24 @@ async def main(): runtime = init_runtime_with_telemetry() + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Use OpenTelemetry interceptor + config["interceptors"] = [TracingInterceptor()] + config["runtime"] = runtime + # Connect client - client = await Client.connect( - "localhost:7233", - # Use OpenTelemetry interceptor - interceptors=[TracingInterceptor()], - runtime=runtime, - ) + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 04095ca7..7a0e2731 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -1,5 +1,6 @@ import asyncio from datetime import timedelta +from pathlib import Path from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter @@ -9,6 +10,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor +from temporalio.envconfig import ClientConfig from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -50,13 +52,24 @@ def init_runtime_with_telemetry() -> Runtime: async def main(): runtime = init_runtime_with_telemetry() + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Use OpenTelemetry interceptor + config["interceptors"] = [TracingInterceptor()] + config["runtime"] = runtime + # Connect client - client = await Client.connect( - "localhost:7233", - # Use OpenTelemetry interceptor - interceptors=[TracingInterceptor()], - runtime=runtime, - ) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 7d3d8619..4690edb8 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -8,7 +8,12 @@ async def main() -> None: - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) user_input = input("Enter a max number: ") max_number = int(user_input) diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index f7c41b9a..e38bc36d 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -1,18 +1,28 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow async def main(): - client = await Client.connect( - "localhost:7233", - plugins=[ - OpenAIAgentsPlugin(), - ], - ) + # Get repo root - 2 levels deep from root + + repo_root = Path(__file__).resolve().parent.parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["plugins"] = [ + OpenAIAgentsPlugin(), + ] + + client = await Client.connect(**config) # Use the URL from the original example image_url = ( diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 7ecb9f47..e7d6a35c 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -1,8 +1,10 @@ import asyncio import json +from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, @@ -10,13 +12,18 @@ async def main(): + # Get repo root - we know openai_agents/handoffs/ is two levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["plugins"] = [ + OpenAIAgentsPlugin(), + ] + # Create client connected to server at the given address - client = await Client.connect( - "localhost:7233", - plugins=[ - OpenAIAgentsPlugin(), - ], - ) + client = await Client.connect(**config) # Execute a workflow result = await client.execute_workflow( diff --git a/patching/starter.py b/patching/starter.py index 9e6d7f31..bf004650 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -1,7 +1,9 @@ import argparse import asyncio +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig # Since it's just used for typing purposes, it doesn't matter which one we # import @@ -17,7 +19,12 @@ async def main(): raise RuntimeError("Either --start-workflow or --query-workflow is required") # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) if args.start_workflow: handle = await client.start_workflow( diff --git a/patching/worker.py b/patching/worker.py index 8f1e3c82..23c061ac 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -30,7 +30,12 @@ async def main(): raise RuntimeError("Unrecognized workflow") # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 664a677c..0e1a024a 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -6,7 +6,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index 00fcc27e..af7c0076 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -8,7 +8,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index 7cf206f2..3386f800 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -6,7 +6,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index f600b949..da9b32aa 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -8,7 +8,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index f2ddcf7a..61bf9589 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -6,7 +6,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index e04ac4dc..6a500445 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -8,7 +8,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 2 levels deep from root + repo_root = Path(__file__).resolve().parent.parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, diff --git a/prometheus/starter.py b/prometheus/starter.py index b94f5601..447bfd4b 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,6 +1,8 @@ import asyncio +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus @@ -10,11 +12,22 @@ async def main(): runtime = init_runtime_with_prometheus(9001) + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["runtime"] = runtime + # Connect client - client = await Client.connect( - "localhost:7233", - runtime=runtime, - ) + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/prometheus/worker.py b/prometheus/worker.py index 5e7d64ab..981a6af9 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -1,8 +1,10 @@ import asyncio from datetime import timedelta +from pathlib import Path from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -38,11 +40,22 @@ def init_runtime_with_prometheus(port: int) -> Runtime: async def main(): runtime = init_runtime_with_prometheus(9000) + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + config["runtime"] = runtime + # Connect client - client = await Client.connect( - "localhost:7233", - runtime=runtime, - ) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 7cc4cc2d..6a618275 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -2,19 +2,34 @@ import logging from datetime import datetime from ipaddress import IPv4Address +from pathlib import Path from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter +from temporalio.envconfig import ClientConfig from pydantic_converter.worker import MyPydanticModel, MyWorkflow async def main(): logging.basicConfig(level=logging.INFO) + + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - client = await Client.connect( - "localhost:7233", data_converter=pydantic_data_converter - ) + config["data_converter"] = pydantic_data_converter + + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index eac0966c..78a45561 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -2,10 +2,12 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address +from pathlib import Path from typing import List from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # Always pass through external modules to the sandbox that you know are safe for @@ -41,10 +43,23 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: async def main(): logging.basicConfig(level=logging.INFO) + + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - client = await Client.connect( - "localhost:7233", data_converter=pydantic_data_converter - ) + config["data_converter"] = pydantic_data_converter + + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 8ab58bdc..0a17ce25 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -2,8 +2,10 @@ import logging from datetime import datetime from ipaddress import IPv4Address +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow @@ -11,10 +13,23 @@ async def main(): logging.basicConfig(level=logging.INFO) + + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - client = await Client.connect( - "localhost:7233", data_converter=pydantic_data_converter - ) + config["data_converter"] = pydantic_data_converter + + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 5c22b6f1..92779dfe 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -3,10 +3,12 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address +from pathlib import Path from typing import List from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -70,10 +72,23 @@ def new_sandbox_runner() -> SandboxedWorkflowRunner: async def main(): logging.basicConfig(level=logging.INFO) + + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - client = await Client.connect( - "localhost:7233", data_converter=pydantic_data_converter - ) + config["data_converter"] = pydantic_data_converter + + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/replay/replayer.py b/replay/replayer.py index 49f16313..5c95fbde 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -8,7 +8,12 @@ async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Fetch the histories of the workflows to be replayed workflows = client.list_workflows('WorkflowId="replayer-workflow-id"') diff --git a/replay/starter.py b/replay/starter.py index daf07098..59c5edb7 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -7,7 +7,12 @@ async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a few workflows # Importantly, normally we would *not* advise re-using the same workflow ID for all of these, diff --git a/replay/worker.py b/replay/worker.py index 3aebc099..1cd65fcc 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -71,7 +71,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/resource_pool/starter.py b/resource_pool/starter.py index 2ae1ab44..d0262710 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -17,7 +17,12 @@ async def main() -> None: # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Initialize the resource pool resource_pool_handle = await client.start_workflow( diff --git a/resource_pool/worker.py b/resource_pool/worker.py index cb3a06dd..fe578c67 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -12,7 +12,12 @@ async def main() -> None: logging.basicConfig(level=logging.INFO) # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker for the workflow worker = Worker( diff --git a/schedules/backfill_schedule.py b/schedules/backfill_schedule.py index 769b6a78..521b9edf 100644 --- a/schedules/backfill_schedule.py +++ b/schedules/backfill_schedule.py @@ -5,7 +5,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/delete_schedule.py b/schedules/delete_schedule.py index b6265636..5b7ac521 100644 --- a/schedules/delete_schedule.py +++ b/schedules/delete_schedule.py @@ -4,7 +4,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/describe_schedule.py b/schedules/describe_schedule.py index 22bb832d..deaff38a 100644 --- a/schedules/describe_schedule.py +++ b/schedules/describe_schedule.py @@ -4,7 +4,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/list_schedule.py b/schedules/list_schedule.py index a863aeee..adbf73fe 100644 --- a/schedules/list_schedule.py +++ b/schedules/list_schedule.py @@ -4,7 +4,12 @@ async def main() -> None: - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async for schedule in await client.list_schedules(): print(f"List Schedule Info: {schedule.info}.") diff --git a/schedules/pause_schedule.py b/schedules/pause_schedule.py index a6f8721c..4067a211 100644 --- a/schedules/pause_schedule.py +++ b/schedules/pause_schedule.py @@ -4,7 +4,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/run_worker.py b/schedules/run_worker.py index 5252b1f7..affacc8f 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -7,7 +7,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, task_queue="schedules-task-queue", diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 6089be95..42eb3cba 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -13,7 +13,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) await client.create_schedule( "workflow-schedule-id", Schedule( diff --git a/schedules/trigger_schedule.py b/schedules/trigger_schedule.py index ca1f38f1..8219a4d5 100644 --- a/schedules/trigger_schedule.py +++ b/schedules/trigger_schedule.py @@ -4,7 +4,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/update_schedule.py b/schedules/update_schedule.py index 979c23a8..b0f45560 100644 --- a/schedules/update_schedule.py +++ b/schedules/update_schedule.py @@ -9,7 +9,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/sentry/starter.py b/sentry/starter.py index 372a732c..c904e409 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,13 +1,26 @@ import asyncio +import os +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput async def main(): + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Connect client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run workflow try: diff --git a/sentry/worker.py b/sentry/worker.py index 723b8e52..f2dbca03 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -51,8 +51,21 @@ async def main(): # Initialize the Sentry SDK initialise_sentry() + # Get repo root - 1 level deep from root + + + repo_root = Path(__file__).resolve().parent.parent + + + config_file = repo_root / "temporal.toml" + + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + # Start client - client = await Client.connect("localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index 765842b2..189d743c 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -1,15 +1,27 @@ import asyncio import uuid +from pathlib import Path from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow async def main(client: Optional[Client] = None): - client = client or await Client.connect("localhost:7233") + if not client: + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) wf_handle = await client.start_workflow( SleepForDaysWorkflow.run, id=f"sleep-for-days-workflow-id-{uuid.uuid4()}", diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index d03ec726..de4a001b 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -10,7 +10,12 @@ async def main(): - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) worker = Worker( client, diff --git a/temporal.toml b/temporal.toml new file mode 100644 index 00000000..df78a1ab --- /dev/null +++ b/temporal.toml @@ -0,0 +1,4 @@ +# Default profile for local development +[profile.default] +address = "localhost:7233" +namespace = "default" \ No newline at end of file diff --git a/trio_async/starter.py b/trio_async/starter.py index 67f7568b..34c689bb 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -11,7 +11,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Execute the workflow result = await client.execute_workflow( diff --git a/trio_async/worker.py b/trio_async/worker.py index 29f059b4..77efd160 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -15,7 +15,12 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Temporal runs threaded activities and workflow tasks via run_in_executor. # Due to how trio_asyncio works, you can only do run_in_executor with their diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 88b4d0d4..90312c9a 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -1,10 +1,12 @@ import asyncio import logging from datetime import datetime, timedelta +from pathlib import Path from typing import Optional from temporalio import exceptions from temporalio.client import Client +from temporalio.envconfig import ClientConfig from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow @@ -13,7 +15,17 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) - client = client or await Client.connect("localhost:7233") + if not client: + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) try: handle = await client.start_workflow( Workflow.run, diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index f406c186..3c6a83bb 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -1,9 +1,11 @@ import asyncio import logging from datetime import datetime, timedelta +from pathlib import Path from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from updatable_timer.workflow import Workflow @@ -11,7 +13,17 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) - client = client or await Client.connect("localhost:7233") + if not client: + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + + + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow") # signal workflow about the wake up time change await handle.signal( diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 096fa1ff..14252588 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -1,7 +1,9 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from updatable_timer import TASK_QUEUE @@ -13,7 +15,14 @@ async def main(): logging.basicConfig(level=logging.INFO) - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + + repo_root = Path(__file__).resolve().parent.parent + + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) async with Worker( client, task_queue=TASK_QUEUE, diff --git a/util.py b/util.py new file mode 100644 index 00000000..5d107072 --- /dev/null +++ b/util.py @@ -0,0 +1,15 @@ +""" +Utility module +""" +from pathlib import Path + +def get_temporal_config_path() -> Path: + """ + Get the path to the temporal.toml configuration file. + + This assumes the temporal.toml file is in the root of the samples-python repository. + + Returns: + Path to temporal.toml + """ + return Path(__file__).resolve().parent / "temporal.toml" \ No newline at end of file diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index c55c63be..052c4bfb 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -8,7 +8,12 @@ async def main(): # Connect client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Start 10 concurrent workflows futures = [] diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index 30ea18b6..fe5bd5a1 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -31,7 +31,12 @@ async def select_task_queue() -> str: return task_queue # Start client - client = await Client.connect("localhost:7233") + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) # Run a worker to distribute the workflows run_futures = [] From a01cd3aee405f6bff387293ab45401ecdb427996 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 11 Aug 2025 23:54:03 -0400 Subject: [PATCH 02/14] linting fixes --- activity_worker/activity_worker.py | 12 ++++---- batch_sliding_window/starter.py | 11 ++++---- batch_sliding_window/worker.py | 11 ++++---- bedrock/basic/run_worker.py | 11 ++++---- bedrock/basic/send_message.py | 12 ++++---- bedrock/entity/end_chat.py | 12 ++++---- bedrock/entity/get_history.py | 12 ++++---- bedrock/entity/run_worker.py | 11 ++++---- bedrock/entity/send_message.py | 12 ++++---- bedrock/signals_and_queries/get_history.py | 12 ++++---- bedrock/signals_and_queries/run_worker.py | 11 ++++---- bedrock/signals_and_queries/send_message.py | 12 ++++---- cloud_export_to_parquet/create_schedule.py | 11 ++++---- cloud_export_to_parquet/run_worker.py | 11 ++++---- context_propagation/starter.py | 25 ++++++----------- context_propagation/worker.py | 25 ++++++----------- custom_converter/starter.py | 24 +++++++--------- custom_converter/worker.py | 24 +++++++--------- custom_decorator/starter.py | 11 ++++---- custom_decorator/worker.py | 11 ++++---- custom_metric/starter.py | 9 ++++-- custom_metric/worker.py | 7 ++++- dsl/starter.py | 11 ++++---- dsl/worker.py | 11 ++++---- encryption/starter.py | 17 ++++++----- encryption/worker.py | 26 ++++++++--------- gevent_async/starter.py | 11 ++++---- gevent_async/worker.py | 11 ++++---- hello/hello_activity.py | 7 +++-- hello/hello_activity_async.py | 12 ++++---- hello/hello_activity_choice.py | 15 ++++------ hello/hello_activity_heartbeat.py | 12 ++++---- hello/hello_activity_method.py | 12 ++++---- hello/hello_activity_multiprocess.py | 12 ++++---- hello/hello_activity_retry.py | 12 ++++---- hello/hello_async_activity_completion.py | 12 ++++---- hello/hello_cancellation.py | 15 ++++------ hello/hello_change_log_level.py | 14 ++++------ hello/hello_child_workflow.py | 15 ++++------ hello/hello_continue_as_new.py | 12 ++++---- hello/hello_cron.py | 12 ++++---- hello/hello_exception.py | 12 ++++---- hello/hello_local_activity.py | 12 ++++---- hello/hello_parallel_activity.py | 12 ++++---- hello/hello_patch.py | 12 ++++---- hello/hello_query.py | 15 ++++------ hello/hello_search_attributes.py | 12 ++++---- hello/hello_signal.py | 15 ++++------ hello/hello_update.py | 14 ++++------ hello_nexus/caller/app.py | 15 ++++------ hello_nexus/handler/worker.py | 15 ++++------ langchain/starter.py | 23 +++++++-------- langchain/worker.py | 12 ++++---- message_passing/introduction/starter.py | 13 +++------ message_passing/introduction/worker.py | 11 +++----- .../safe_message_handlers/starter.py | 11 ++++---- .../safe_message_handlers/worker.py | 11 ++++---- .../lazy_initialization/starter.py | 15 ++++------ .../lazy_initialization/worker.py | 11 +++----- .../waiting_for_handlers/starter.py | 12 ++++---- .../waiting_for_handlers/worker.py | 11 +++----- .../starter.py | 13 +++------ .../worker.py | 12 +++----- open_telemetry/starter.py | 27 +++++++----------- open_telemetry/worker.py | 28 ++++++++----------- .../basic/run_agent_lifecycle_workflow.py | 11 ++++---- .../basic/run_remote_image_workflow.py | 22 ++++++--------- .../handoffs/run_message_filter_workflow.py | 23 ++++++++------- patching/starter.py | 11 ++++---- patching/worker.py | 11 ++++---- polling/frequent/run_frequent.py | 11 ++++---- polling/frequent/run_worker.py | 11 ++++---- polling/infrequent/run_infrequent.py | 11 ++++---- polling/infrequent/run_worker.py | 11 ++++---- polling/periodic_sequence/run_periodic.py | 11 ++++---- polling/periodic_sequence/run_worker.py | 11 ++++---- prometheus/starter.py | 23 ++++++--------- prometheus/worker.py | 24 ++++++---------- pydantic_converter/starter.py | 24 ++++++---------- pydantic_converter/worker.py | 25 +++++++---------- pydantic_converter_v1/starter.py | 24 ++++++---------- pydantic_converter_v1/worker.py | 26 +++++++---------- replay/replayer.py | 11 ++++---- replay/starter.py | 11 ++++---- replay/worker.py | 12 ++++---- resource_pool/starter.py | 11 ++++---- resource_pool/worker.py | 11 ++++---- schedules/backfill_schedule.py | 12 ++++---- schedules/delete_schedule.py | 12 ++++---- schedules/describe_schedule.py | 12 ++++---- schedules/list_schedule.py | 12 ++++---- schedules/pause_schedule.py | 12 ++++---- schedules/run_worker.py | 12 ++++---- schedules/start_schedule.py | 12 ++++---- schedules/trigger_schedule.py | 12 ++++---- schedules/update_schedule.py | 12 ++++---- sentry/starter.py | 15 +++------- sentry/worker.py | 17 ++++------- sleep_for_days/starter.py | 13 +++------ sleep_for_days/worker.py | 11 ++++---- trio_async/starter.py | 11 ++++---- trio_async/worker.py | 11 ++++---- updatable_timer/starter.py | 13 +++------ updatable_timer/wake_up_time_updater.py | 13 +++------ updatable_timer/worker.py | 11 +++----- util.py | 7 +++-- worker_specific_task_queues/starter.py | 11 ++++---- worker_specific_task_queues/worker.py | 11 ++++---- 108 files changed, 705 insertions(+), 783 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 8ffa1fb6..b6a9a4e9 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -1,13 +1,14 @@ import asyncio import random import string -from pathlib import Path from temporalio import activity from temporalio.client import Client from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + task_queue = "say-hello-task-queue" workflow_name = "say-hello-workflow" activity_name = "say-hello-activity" @@ -20,11 +21,10 @@ async def say_hello_activity(name: str) -> str: async def main(): # Create client to localhost on default namespace - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run activity worker diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index 2305abcf..4bdbdd39 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -6,11 +6,13 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ( ProcessBatchWorkflow, ProcessBatchWorkflowInput, ) +from util import get_temporal_config_path async def main(): @@ -19,11 +21,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Create unique workflow ID with timestamp diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index 850d90e5..62c4c3f7 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -6,11 +6,13 @@ from temporalio import worker from temporalio.client import Client +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ProcessBatchWorkflow from batch_sliding_window.record_loader_activity import RecordLoader from batch_sliding_window.record_processor_workflow import RecordProcessorWorkflow from batch_sliding_window.sliding_window_workflow import SlidingWindowWorkflow +from util import get_temporal_config_path async def main(): @@ -19,11 +21,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Create RecordLoader activity with sample data diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index 9385fdce..7c88ca35 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -3,19 +3,20 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import BasicBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 04380cf0..7d199cd2 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -2,16 +2,18 @@ import sys from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import BasicBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt: str) -> str: # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Start the workflow diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index e279dec0..03d272e2 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -2,16 +2,18 @@ import sys from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index 9e1787d4..03a59c9f 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -1,16 +1,18 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 32ad137d..0f368eaf 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -3,19 +3,20 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import EntityBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 4e5f48bc..7d4c4148 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -2,16 +2,18 @@ import sys from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import BedrockParams, EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index 80b6a205..cbbc750d 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -1,16 +1,18 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index 489d4e45..4a104fe9 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -3,19 +3,20 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import SignalQueryBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 3a3f627f..8a98df61 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -2,16 +2,18 @@ import sys from temporalio.client import Client +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt): # Create client connected to server at the given address - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index 0cb97711..ce82c8ed 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -10,21 +10,22 @@ ScheduleSpec, WorkflowFailureError, ) +from temporalio.envconfig import ClientConfig from cloud_export_to_parquet.workflows import ( ProtoToParquet, ProtoToParquetWorkflowInput, ) +from util import get_temporal_config_path async def main() -> None: """Main function to run temporal workflow.""" # Create client connected to server at the given address - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # TODO: update s3_bucket and namespace to the actual usecase wf_input = ProtoToParquetWorkflowInput( diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index 4a8fd174..ee0c7cb2 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -2,6 +2,7 @@ from concurrent.futures import ThreadPoolExecutor from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -13,16 +14,16 @@ get_object_keys, ) from cloud_export_to_parquet.workflows import ProtoToParquet +from util import get_temporal_config_path async def main() -> None: """Main worker function.""" # Create client connected to server at the given address - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run the worker diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 491a6c4c..f3ff97af 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -1,11 +1,11 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from context_propagation import interceptor, shared, workflows +from util import get_temporal_config_path async def main(): @@ -14,23 +14,16 @@ async def main(): # Set the user ID shared.user_id.set("some-user") - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Use our interceptor - config["interceptors"] = [interceptor.ContextPropagationInterceptor()] - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use our interceptor + interceptors=[interceptor.ContextPropagationInterceptor()], + ) # Start workflow, send signal, wait for completion, issue query handle = await client.start_workflow( diff --git a/context_propagation/worker.py b/context_propagation/worker.py index c7f7fb43..158a99dc 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -1,12 +1,12 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -14,23 +14,16 @@ async def main(): logging.basicConfig(level=logging.INFO) - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Use our interceptor - config["interceptors"] = [interceptor.ContextPropagationInterceptor()] - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use our interceptor + interceptors=[interceptor.ContextPropagationInterceptor()], + ) # Run a worker for the workflow async with Worker( diff --git a/custom_converter/starter.py b/custom_converter/starter.py index a3618cd3..364b3c68 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -10,24 +9,21 @@ greeting_data_converter, ) from custom_converter.workflow import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Without this we get: - # TypeError: Object of type GreetingInput is not JSON serializable - config["data_converter"] = greeting_data_converter - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Without this we get: + # TypeError: Object of type GreetingInput is not JSON serializable + data_converter=greeting_data_converter, + ) # Run workflow result = await client.execute_workflow( diff --git a/custom_converter/worker.py b/custom_converter/worker.py index 17291541..a22a4dea 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -7,26 +6,23 @@ from custom_converter.shared import greeting_data_converter from custom_converter.workflow import GreetingWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Without this, when trying to run a workflow, we get: - # KeyError: 'Unknown payload encoding my-greeting-encoding - config["data_converter"] = greeting_data_converter - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Without this, when trying to run a workflow, we get: + # KeyError: 'Unknown payload encoding my-greeting-encoding + data_converter=greeting_data_converter, + ) # Run a worker for the workflow async with Worker( diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index bb33026f..e288d054 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -1,17 +1,18 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from custom_decorator.worker import WaitForCancelWorkflow +from util import get_temporal_config_path async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Start the workflow diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index 4c09d231..6119d259 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -4,9 +4,11 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater +from util import get_temporal_config_path # Here we use our automatic heartbeater decorator. If this wasn't present, our @@ -51,11 +53,10 @@ def cancel_activity(self) -> None: async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/custom_metric/starter.py b/custom_metric/starter.py index ded3a626..76abc5cf 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -2,16 +2,19 @@ import uuid from temporalio.client import Client +from temporalio.envconfig import ClientConfig from custom_metric.workflow import StartTwoActivitiesWorkflow +from util import get_temporal_config_path async def main(): - - client = await Client.connect( - "localhost:7233", + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) ) + client = await Client.connect(**config) + await client.start_workflow( StartTwoActivitiesWorkflow.run, id="execute-activity-workflow-" + str(uuid.uuid4()), diff --git a/custom_metric/worker.py b/custom_metric/worker.py index 9ffad207..003da668 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -3,6 +3,7 @@ from temporalio import activity from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import ( ActivityInboundInterceptor, @@ -13,6 +14,7 @@ from custom_metric.activity import print_and_sleep from custom_metric.workflow import StartTwoActivitiesWorkflow +from util import get_temporal_config_path class SimpleWorkerInterceptor(Interceptor): @@ -48,8 +50,11 @@ async def main(): runtime = Runtime( telemetry=TelemetryConfig(metrics=PrometheusConfig(bind_address="0.0.0.0:9090")) ) + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) client = await Client.connect( - "localhost:7233", + **config, runtime=runtime, ) worker = Worker( diff --git a/dsl/starter.py b/dsl/starter.py index a8b13216..924f137f 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -2,7 +2,6 @@ import logging import sys import uuid -from pathlib import Path import dacite import yaml @@ -10,6 +9,7 @@ from temporalio.envconfig import ClientConfig from dsl.workflow import DSLInput, DSLWorkflow +from util import get_temporal_config_path async def main(dsl_yaml: str) -> None: @@ -18,11 +18,10 @@ async def main(dsl_yaml: str) -> None: dsl_input = dacite.from_dict(DSLInput, yaml.safe_load(dsl_yaml)) # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run workflow diff --git a/dsl/worker.py b/dsl/worker.py index d24fa132..4d3085c5 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,17 +7,17 @@ from dsl.activities import DSLActivities from dsl.workflow import DSLWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the activities and workflow diff --git a/encryption/starter.py b/encryption/starter.py index 5797a6ce..f0fae71b 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -12,15 +12,18 @@ async def main(): # Load configuration - config = ClientConfig.load_client_connect_config(config_file=str(get_temporal_config_path())) - config["target_host"] = "localhost:7233" - # Use the default converter, but change the codec - config["data_converter"] = dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) ) - + # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use the default converter, but change the codec + data_converter=dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() + ), + ) # Run workflow result = await client.execute_workflow( diff --git a/encryption/worker.py b/encryption/worker.py index efd8e242..4cfa064d 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -1,6 +1,5 @@ import asyncio import dataclasses -from pathlib import Path import temporalio.converter from temporalio import workflow @@ -9,6 +8,7 @@ from temporalio.worker import Worker from encryption.codec import EncryptionCodec +from util import get_temporal_config_path @workflow.defn(name="Workflow") @@ -22,22 +22,18 @@ async def run(self, name: str) -> str: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Use the default converter, but change the codec - config["data_converter"] = dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) ) - + # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use the default converter, but change the codec + data_converter=dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() + ), + ) # Run a worker for the workflow async with Worker( diff --git a/gevent_async/starter.py b/gevent_async/starter.py index ba85155d..12f06053 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -7,9 +7,11 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from gevent_async import workflow from gevent_async.executor import GeventExecutor +from util import get_temporal_config_path def main(): @@ -24,11 +26,10 @@ def main(): async def async_main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run workflow diff --git a/gevent_async/worker.py b/gevent_async/worker.py index f0d558b8..1ef59c0d 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -9,10 +9,12 @@ import gevent from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from gevent_async import activity, workflow from gevent_async.executor import GeventExecutor +from util import get_temporal_config_path def main(): @@ -39,11 +41,10 @@ async def async_main(): ) # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Create an executor for use by Temporal. This cannot be the outer one diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 14b53ab5..8e046951 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -46,9 +46,10 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Load configuration - config = ClientConfig.load_client_connect_config(config_file=str(get_temporal_config_path())) - config["target_host"] = "localhost:7233" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + # Start client client = await Client.connect(**config) diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index 39b2de75..675543e4 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -4,8 +4,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -42,11 +45,10 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index 0f266a0f..b2c3f670 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -7,8 +7,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # Activities that will be called by the workflow @@ -80,16 +83,10 @@ async def run(self, shopping_list: ShoppingList) -> str: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index b80f1662..834ab249 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -6,8 +6,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -41,11 +44,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index e4d8060a..cc253349 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -3,8 +3,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + class MyDatabaseClient: async def run_database_update(self) -> None: @@ -32,11 +35,10 @@ async def run(self) -> None: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Create our database client that can then be used in the activity diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index 2e7dc5c8..57c3f261 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -8,8 +8,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import SharedStateManager, Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -43,11 +46,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index 49a20233..23d633c1 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -6,8 +6,11 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -45,11 +48,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index c3f72e3d..29c2b47a 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -4,8 +4,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -68,11 +71,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 1de78827..60a50631 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -7,9 +7,12 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError +from temporalio.envconfig import ClientConfig from temporalio.exceptions import CancelledError from temporalio.worker import Worker +from util import get_temporal_config_path + @activity.defn def never_complete_activity() -> NoReturn: @@ -50,16 +53,10 @@ async def run(self) -> None: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 0b856fae..7454b94d 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -11,8 +11,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # --- Begin logging set‑up ---------------------------------------------------------- logging.basicConfig( stream=sys.stdout, @@ -50,15 +53,10 @@ async def run(self): async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( client, diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 61251365..486b82cb 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -3,8 +3,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -31,16 +34,10 @@ async def run(self, name: str) -> str: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index 97cfab62..95a68151 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -3,8 +3,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class LoopingWorkflow: @@ -22,11 +25,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_cron.py b/hello/hello_cron.py index e5b3e5f9..7120d1de 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -5,8 +5,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -33,11 +36,10 @@ async def run(self, name: str) -> None: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_exception.py b/hello/hello_exception.py index ba4203d5..5afc7bf6 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -8,9 +8,12 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError from temporalio.common import RetryPolicy +from temporalio.envconfig import ClientConfig from temporalio.exceptions import FailureError from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -39,11 +42,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 21a080c8..52572fc5 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -5,8 +5,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: @@ -32,11 +35,10 @@ async def run(self, name: str) -> str: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index 1bb80f88..3520689c 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -5,8 +5,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @activity.defn def say_hello_activity(name: str) -> str: @@ -41,11 +44,10 @@ async def run(self) -> List[str]: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_patch.py b/hello/hello_patch.py index ca39bb47..e836111b 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -6,8 +6,11 @@ from temporalio import activity, exceptions, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -101,11 +104,10 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Set workflow_class to the proper class based on version diff --git a/hello/hello_query.py b/hello/hello_query.py index 9d06e9a1..730e3ea0 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -2,8 +2,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -26,16 +29,10 @@ def greeting(self) -> str: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index efb91c1f..7904e55e 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -2,8 +2,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -16,11 +19,10 @@ async def run(self) -> None: async def main(): # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello/hello_signal.py b/hello/hello_signal.py index cbf8ffc0..2fdca213 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -3,8 +3,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -40,16 +43,10 @@ def exit(self) -> None: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/hello/hello_update.py b/hello/hello_update.py index 2ab6aadf..9f8e61a2 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -2,8 +2,11 @@ from temporalio import workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -22,15 +25,10 @@ async def update_workflow_status(self) -> str: async def main(): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) # Run a worker for the workflow diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 34b790eb..5446b98d 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -9,6 +8,7 @@ from hello_nexus.caller.workflows import CallerWorkflow from hello_nexus.service import MyOutput +from util import get_temporal_config_path NAMESPACE = "hello-nexus-basic-caller-namespace" TASK_QUEUE = "hello-nexus-basic-caller-task-queue" @@ -18,15 +18,10 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[MyOutput, MyOutput]: if not client: - # Get repo root - 2 levels deep from root - - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + # Override the namespace from config file. config["namespace"] = NAMESPACE client = await Client.connect(**config) diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index cb6736d3..9034c979 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -9,6 +8,7 @@ from hello_nexus.handler.service_handler import MyNexusServiceHandler from hello_nexus.handler.workflows import WorkflowStartedByNexusOperation +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -20,15 +20,10 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - # Get repo root - 2 levels deep from root - - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + # Override the namespace from the config file. config["namespace"] = NAMESPACE client = await Client.connect(**config) diff --git a/langchain/starter.py b/langchain/starter.py index a9ef33f6..8795c44c 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -1,5 +1,4 @@ from contextlib import asynccontextmanager -from pathlib import Path from typing import List from uuid import uuid4 @@ -11,21 +10,19 @@ from temporalio.envconfig import ClientConfig from workflow import LangChainWorkflow, TranslateWorkflowParams +from util import get_temporal_config_path + @asynccontextmanager async def lifespan(app: FastAPI): - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - config["interceptors"] = [LangChainContextPropagationInterceptor()] - - app.state.temporal_client = await Client.connect(**config) + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + + client = await Client.connect( + **config, + interceptors=[LangChainContextPropagationInterceptor()], + ) yield diff --git a/langchain/worker.py b/langchain/worker.py index 54f0beb7..181b19a0 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -3,18 +3,20 @@ from activities import translate_phrase from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow +from util import get_temporal_config_path + interrupt_event = asyncio.Event() async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( client, diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index ca58bf63..8deb29ac 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from typing import Optional from temporalio.client import Client, WorkflowUpdateStage @@ -13,19 +12,15 @@ Language, SetLanguageInput, ) +from util import get_temporal_config_path async def main(client: Optional[Client] = None): if not client: - # Get repo root - 2 levels deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) wf_handle = await client.start_workflow( GreetingWorkflow.run, diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index fda7fded..8aa6eb10 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -9,6 +8,7 @@ from message_passing.introduction import TASK_QUEUE from message_passing.introduction.activities import call_greeting_service from message_passing.introduction.workflows import GreetingWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -16,13 +16,10 @@ async def main(): logging.basicConfig(level=logging.INFO) - # Get repo root - 2 levels deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 5f47e5c9..2ee49f28 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -2,7 +2,6 @@ import asyncio import logging import uuid -from pathlib import Path from typing import Optional from temporalio import common @@ -15,6 +14,7 @@ ClusterManagerInput, ClusterManagerWorkflow, ) +from util import get_temporal_config_path async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] = None): @@ -56,11 +56,10 @@ async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] async def main(should_test_continue_as_new: bool): # Connect to Temporal - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) print("Starting cluster") diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index d225dc9a..fad90aaa 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -13,16 +12,16 @@ start_cluster, unassign_nodes_for_job, ) +from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) async with Worker( diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index 63c10ba8..323f9bd0 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional, Tuple from temporalio import common @@ -18,6 +17,7 @@ ShoppingCartItem, ShoppingCartWorkflow, ) +from util import get_temporal_config_path async def handle_add_item_request( @@ -63,15 +63,12 @@ async def handle_add_item_request( async def main(): print("🛒") session_id = f"session-{uuid.uuid4()}" - # Get repo root - 3 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - client = await Client.connect(**config) - subtotal_1, _ = await handle_add_item_request( - session_id, "sku-123", 1, client + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) ) + + client = await Client.connect(**config) + subtotal_1, _ = await handle_add_item_request(session_id, "sku-123", 1, client) subtotal_2, wf_handle = await handle_add_item_request( session_id, "sku-456", 1, client ) diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index a25f5962..0952aa0e 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows from message_passing.update_with_start.lazy_initialization.activities import get_price +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -15,13 +15,10 @@ async def main(): logging.basicConfig(level=logging.INFO) - # Get repo root - 3 levels deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent.parent.parent - - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 4299b611..9a8f48b9 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig @@ -11,15 +10,14 @@ WorkflowInput, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow +from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): - # Get repo root - we know message_passing/waiting_for_handlers/ is two levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersWorkflow.run, diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index b4032876..82dee079 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -11,6 +10,7 @@ activity_executed_by_update_handler, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -18,13 +18,10 @@ async def main(): logging.basicConfig(level=logging.INFO) - # Get repo root - 2 levels deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index 5c3d73ae..ba9bfdc4 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig @@ -13,18 +12,14 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) +from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): - # Get repo root - 2 levels deep from root - - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersAndCompensationWorkflow.run, diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 3f666f63..05579de5 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -15,20 +14,17 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) +from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): logging.basicConfig(level=logging.INFO) + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - # Get repo root - 2 levels deep from root - - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 5d4a43b4..6cc187d6 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -1,34 +1,27 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor from temporalio.envconfig import ClientConfig from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry +from util import get_temporal_config_path async def main(): runtime = init_runtime_with_telemetry() - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Use OpenTelemetry interceptor - config["interceptors"] = [TracingInterceptor()] - config["runtime"] = runtime - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use OpenTelemetry interceptor + interceptors=[TracingInterceptor()], + runtime=runtime, + ) # Run workflow result = await client.execute_workflow( diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 7a0e2731..59fb9e28 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -1,6 +1,5 @@ import asyncio from datetime import timedelta -from pathlib import Path from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter @@ -14,6 +13,8 @@ from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -52,24 +53,17 @@ def init_runtime_with_telemetry() -> Runtime: async def main(): runtime = init_runtime_with_telemetry() - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Use OpenTelemetry interceptor - config["interceptors"] = [TracingInterceptor()] - config["runtime"] = runtime - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use OpenTelemetry interceptor + interceptors=[TracingInterceptor()], + runtime=runtime, + ) # Run a worker for the workflow async with Worker( diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 4690edb8..0197ac32 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -1,18 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, ) +from util import get_temporal_config_path async def main() -> None: - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) user_input = input("Enter a max number: ") diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index e38bc36d..1c183170 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -1,28 +1,22 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - - repo_root = Path(__file__).resolve().parent.parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - config["plugins"] = [ - OpenAIAgentsPlugin(), - ] - - client = await Client.connect(**config) + client = await Client.connect( + **config, + plugins=[OpenAIAgentsPlugin()], + ) # Use the URL from the original example image_url = ( diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index e7d6a35c..16c819b2 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -1,6 +1,5 @@ import asyncio import json -from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin @@ -9,21 +8,21 @@ from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, ) +from util import get_temporal_config_path async def main(): - # Get repo root - we know openai_agents/handoffs/ is two levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - config["plugins"] = [ - OpenAIAgentsPlugin(), - ] - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + # Create client connected to server at the given address - client = await Client.connect(**config) + client = await Client.connect( + **config, + plugins=[ + OpenAIAgentsPlugin(), + ], + ) # Execute a workflow result = await client.execute_workflow( diff --git a/patching/starter.py b/patching/starter.py index bf004650..49f8141a 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -1,6 +1,5 @@ import argparse import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ # Since it's just used for typing purposes, it doesn't matter which one we # import from patching.workflow_1_initial import MyWorkflow +from util import get_temporal_config_path async def main(): @@ -19,11 +19,10 @@ async def main(): raise RuntimeError("Either --start-workflow or --query-workflow is required") # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) if args.start_workflow: diff --git a/patching/worker.py b/patching/worker.py index 23c061ac..e3447048 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -2,9 +2,11 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -30,11 +32,10 @@ async def main(): raise RuntimeError("Unrecognized workflow") # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 0e1a024a..65935155 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -1,16 +1,17 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from polling.frequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index af7c0076..ced52262 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -1,18 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.frequent.activities import compose_greeting from polling.frequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index 3386f800..6a9857a2 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -1,16 +1,17 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from polling.infrequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index da9b32aa..b835a3fe 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -1,18 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.infrequent.activities import compose_greeting from polling.infrequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index 61bf9589..ac40e2e8 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -1,16 +1,17 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from polling.periodic_sequence.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 6a500445..3b996b9a 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -1,18 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.periodic_sequence.activities import compose_greeting from polling.periodic_sequence.workflows import ChildWorkflow, GreetingWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 2 levels deep from root - repo_root = Path(__file__).resolve().parent.parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( diff --git a/prometheus/starter.py b/prometheus/starter.py index 447bfd4b..40ac9578 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,10 +1,10 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -12,22 +12,15 @@ async def main(): runtime = init_runtime_with_prometheus(9001) - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - config["runtime"] = runtime - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + runtime=runtime, + ) # Run workflow result = await client.execute_workflow( diff --git a/prometheus/worker.py b/prometheus/worker.py index 981a6af9..0d3c36ab 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -1,6 +1,5 @@ import asyncio from datetime import timedelta -from pathlib import Path from temporalio import activity, workflow from temporalio.client import Client @@ -8,6 +7,8 @@ from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: @@ -40,22 +41,15 @@ def init_runtime_with_prometheus(port: int) -> Runtime: async def main(): runtime = init_runtime_with_prometheus(9000) - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - config["runtime"] = runtime - # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + runtime=runtime, + ) # Run a worker for the workflow async with Worker( diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 6a618275..1f14e719 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -2,34 +2,28 @@ import logging from datetime import datetime from ipaddress import IPv4Address -from pathlib import Path from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter from temporalio.envconfig import ClientConfig from pydantic_converter.worker import MyPydanticModel, MyWorkflow +from util import get_temporal_config_path async def main(): logging.basicConfig(level=logging.INFO) - - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - config["data_converter"] = pydantic_data_converter - - client = await Client.connect(**config) + + client = await Client.connect( + **config, + data_converter=pydantic_data_converter, + ) # Run workflow result = await client.execute_workflow( diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index 78a45561..2b18f2b9 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -2,7 +2,6 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address -from pathlib import Path from typing import List from temporalio import activity, workflow @@ -10,6 +9,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # Always pass through external modules to the sandbox that you know are safe for # workflow use with workflow.unsafe.imports_passed_through(): @@ -43,23 +44,17 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: async def main(): logging.basicConfig(level=logging.INFO) - - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - config["data_converter"] = pydantic_data_converter - - client = await Client.connect(**config) + + client = await Client.connect( + **config, + data_converter=pydantic_data_converter, + ) # Run a worker for the workflow async with Worker( diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 0a17ce25..4ebba775 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -2,34 +2,28 @@ import logging from datetime import datetime from ipaddress import IPv4Address -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow +from util import get_temporal_config_path async def main(): logging.basicConfig(level=logging.INFO) - - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - config["data_converter"] = pydantic_data_converter - - client = await Client.connect(**config) + + client = await Client.connect( + **config, + data_converter=pydantic_data_converter, + ) # Run workflow result = await client.execute_workflow( diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 92779dfe..9cfc06fb 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -3,7 +3,6 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address -from pathlib import Path from typing import List from temporalio import activity, workflow @@ -22,6 +21,8 @@ from pydantic_converter_v1.converter import pydantic_data_converter +from util import get_temporal_config_path + class MyPydanticModel(BaseModel): some_ip: IPv4Address @@ -72,23 +73,16 @@ def new_sandbox_runner() -> SandboxedWorkflowRunner: async def main(): logging.basicConfig(level=logging.INFO) - - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" # Connect client using the Pydantic converter - config["data_converter"] = pydantic_data_converter - - client = await Client.connect(**config) + + client = await Client.connect( + **config, + data_converter=pydantic_data_converter, + ) # Run a worker for the workflow async with Worker( diff --git a/replay/replayer.py b/replay/replayer.py index 5c95fbde..7716c617 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -1,18 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity +from util import get_temporal_config_path async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Fetch the histories of the workflows to be replayed diff --git a/replay/starter.py b/replay/starter.py index 59c5edb7..3315df33 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -1,17 +1,18 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from replay.worker import JustActivity, JustTimer, TimerThenActivity +from util import get_temporal_config_path async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a few workflows diff --git a/replay/worker.py b/replay/worker.py index 1cd65fcc..d9de987f 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -5,8 +5,11 @@ from temporalio import activity, workflow from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -71,11 +74,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/resource_pool/starter.py b/resource_pool/starter.py index d0262710..e7d85c88 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -3,6 +3,7 @@ from temporalio.client import Client, WorkflowFailureError, WorkflowHandle from temporalio.common import WorkflowIDConflictPolicy +from temporalio.envconfig import ClientConfig from resource_pool.pool_client.resource_pool_workflow import ( ResourcePoolWorkflow, @@ -13,15 +14,15 @@ ResourceUserWorkflowInput, ) from resource_pool.shared import RESOURCE_POOL_WORKFLOW_ID +from util import get_temporal_config_path async def main() -> None: # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Initialize the resource pool diff --git a/resource_pool/worker.py b/resource_pool/worker.py index fe578c67..40a114db 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -2,21 +2,22 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow from resource_pool.resource_user_workflow import ResourceUserWorkflow, use_resource +from util import get_temporal_config_path async def main() -> None: logging.basicConfig(level=logging.INFO) # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker for the workflow diff --git a/schedules/backfill_schedule.py b/schedules/backfill_schedule.py index 521b9edf..445c700e 100644 --- a/schedules/backfill_schedule.py +++ b/schedules/backfill_schedule.py @@ -2,14 +2,16 @@ from datetime import datetime, timedelta from temporalio.client import Client, ScheduleBackfill, ScheduleOverlapPolicy +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/delete_schedule.py b/schedules/delete_schedule.py index 5b7ac521..a32e48ee 100644 --- a/schedules/delete_schedule.py +++ b/schedules/delete_schedule.py @@ -1,14 +1,16 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/describe_schedule.py b/schedules/describe_schedule.py index deaff38a..2030bfe9 100644 --- a/schedules/describe_schedule.py +++ b/schedules/describe_schedule.py @@ -1,14 +1,16 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/list_schedule.py b/schedules/list_schedule.py index adbf73fe..65c6a9db 100644 --- a/schedules/list_schedule.py +++ b/schedules/list_schedule.py @@ -1,14 +1,16 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main() -> None: - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) async for schedule in await client.list_schedules(): diff --git a/schedules/pause_schedule.py b/schedules/pause_schedule.py index 4067a211..5ecf751f 100644 --- a/schedules/pause_schedule.py +++ b/schedules/pause_schedule.py @@ -1,14 +1,16 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/run_worker.py b/schedules/run_worker.py index affacc8f..e67a7325 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -1,17 +1,19 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from your_activities import your_activity from your_workflows import YourSchedulesWorkflow +from util import get_temporal_config_path + async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( client, diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 42eb3cba..6ac0ee9a 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -9,15 +9,17 @@ ScheduleSpec, ScheduleState, ) +from temporalio.envconfig import ClientConfig from your_workflows import YourSchedulesWorkflow +from util import get_temporal_config_path + async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) await client.create_schedule( "workflow-schedule-id", diff --git a/schedules/trigger_schedule.py b/schedules/trigger_schedule.py index 8219a4d5..a9f72adf 100644 --- a/schedules/trigger_schedule.py +++ b/schedules/trigger_schedule.py @@ -1,14 +1,16 @@ import asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/update_schedule.py b/schedules/update_schedule.py index b0f45560..5bf4cd15 100644 --- a/schedules/update_schedule.py +++ b/schedules/update_schedule.py @@ -6,14 +6,16 @@ ScheduleUpdate, ScheduleUpdateInput, ) +from temporalio.envconfig import ClientConfig + +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/sentry/starter.py b/sentry/starter.py index c904e409..bb162f46 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,24 +1,17 @@ import asyncio -import os -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Connect client client = await Client.connect(**config) diff --git a/sentry/worker.py b/sentry/worker.py index f2dbca03..dcbd5988 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -5,6 +5,7 @@ from sentry_sdk.integrations.asyncio import AsyncioIntegration from sentry_sdk.types import Event, Hint from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -16,6 +17,7 @@ from sentry.workflow import SentryExampleWorkflow interrupt_event = asyncio.Event() +from util import get_temporal_config_path def before_send(event: Event, hint: Hint) -> Event | None: @@ -51,19 +53,10 @@ async def main(): # Initialize the Sentry SDK initialise_sentry() - # Get repo root - 1 level deep from root - - - repo_root = Path(__file__).resolve().parent.parent - - - config_file = repo_root / "temporal.toml" - + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" - # Start client client = await Client.connect(**config) diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index 189d743c..bc717f81 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -8,19 +7,15 @@ from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): if not client: - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) wf_handle = await client.start_workflow( SleepForDaysWorkflow.run, diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index de4a001b..0f2896a0 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -2,19 +2,20 @@ import logging from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from sleep_for_days import TASK_QUEUE from sleep_for_days.activities import send_email from sleep_for_days.workflows import SleepForDaysWorkflow +from util import get_temporal_config_path async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) worker = Worker( diff --git a/trio_async/starter.py b/trio_async/starter.py index 34c689bb..7f21e677 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -2,8 +2,10 @@ import trio_asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from trio_async import workflows +from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives @@ -11,11 +13,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Execute the workflow diff --git a/trio_async/worker.py b/trio_async/worker.py index 77efd160..55c18c17 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -5,9 +5,11 @@ import trio_asyncio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from trio_async import activities, workflows +from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives @@ -15,11 +17,10 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Temporal runs threaded activities and workflow tasks via run_in_executor. diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 90312c9a..73f6d47a 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -1,7 +1,6 @@ import asyncio import logging from datetime import datetime, timedelta -from pathlib import Path from typing import Optional from temporalio import exceptions @@ -10,21 +9,17 @@ from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - # Get repo root - 1 level deep from root - - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) try: handle = await client.start_workflow( diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 3c6a83bb..f0002501 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -1,28 +1,23 @@ import asyncio import logging from datetime import datetime, timedelta -from pathlib import Path from typing import Optional from temporalio.client import Client from temporalio.envconfig import ClientConfig from updatable_timer.workflow import Workflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - - - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow") # signal workflow about the wake up time change diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 14252588..44544330 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -15,13 +15,10 @@ async def main(): logging.basicConfig(level=logging.INFO) - # Get repo root - 1 level deep from root + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) - repo_root = Path(__file__).resolve().parent.parent - - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" client = await Client.connect(**config) async with Worker( client, diff --git a/util.py b/util.py index 5d107072..b15a68d0 100644 --- a/util.py +++ b/util.py @@ -3,13 +3,14 @@ """ from pathlib import Path + def get_temporal_config_path() -> Path: """ Get the path to the temporal.toml configuration file. - + This assumes the temporal.toml file is in the root of the samples-python repository. - + Returns: Path to temporal.toml """ - return Path(__file__).resolve().parent / "temporal.toml" \ No newline at end of file + return Path(__file__).resolve().parent / "temporal.toml" diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index 052c4bfb..0b56ccdf 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -2,17 +2,18 @@ from uuid import uuid4 from temporalio.client import Client +from temporalio.envconfig import ClientConfig +from util import get_temporal_config_path from worker_specific_task_queues.tasks import FileProcessing async def main(): # Connect client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Start 10 concurrent workflows diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index fe5bd5a1..ee64ce34 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -6,8 +6,10 @@ from temporalio import activity from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path from worker_specific_task_queues import tasks interrupt_event = asyncio.Event() @@ -31,11 +33,10 @@ async def select_task_queue() -> str: return task_queue # Start client - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) # Run a worker to distribute the workflows From 145aaf4f05099163c15d84ac58160d7a70ea7508 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Wed, 13 Aug 2025 11:18:07 -0400 Subject: [PATCH 03/14] update to direct profile mutation --- activity_worker/activity_worker.py | 12 ++++-------- batch_sliding_window/starter.py | 11 ++++------- batch_sliding_window/worker.py | 11 ++++------- bedrock/basic/run_worker.py | 10 ++++------ bedrock/basic/send_message.py | 12 ++++-------- bedrock/entity/end_chat.py | 12 ++++-------- bedrock/entity/get_history.py | 11 ++++------- bedrock/entity/run_worker.py | 10 ++++------ bedrock/entity/send_message.py | 12 ++++-------- bedrock/signals_and_queries/get_history.py | 11 ++++------- bedrock/signals_and_queries/run_worker.py | 10 ++++------ bedrock/signals_and_queries/send_message.py | 12 ++++-------- cloud_export_to_parquet/create_schedule.py | 10 ++++------ cloud_export_to_parquet/run_worker.py | 11 ++++------- context_propagation/starter.py | 10 ++++------ context_propagation/worker.py | 10 ++++------ custom_converter/starter.py | 10 ++++------ custom_converter/worker.py | 10 ++++------ custom_decorator/starter.py | 11 ++++------- custom_decorator/worker.py | 11 ++++------- custom_metric/starter.py | 11 ++++------- custom_metric/worker.py | 10 ++++------ dsl/starter.py | 11 ++++------- dsl/worker.py | 11 ++++------- encryption/starter.py | 10 ++++------ encryption/worker.py | 10 ++++------ gevent_async/starter.py | 11 ++++------- gevent_async/worker.py | 11 ++++------- hello/hello_activity.py | 11 ++++------- hello/hello_activity_async.py | 12 ++++-------- hello/hello_activity_choice.py | 12 ++++-------- hello/hello_activity_heartbeat.py | 12 ++++-------- hello/hello_activity_method.py | 12 ++++-------- hello/hello_activity_multiprocess.py | 12 ++++-------- hello/hello_activity_retry.py | 12 ++++-------- hello/hello_async_activity_completion.py | 12 ++++-------- hello/hello_cancellation.py | 12 ++++-------- hello/hello_change_log_level.py | 11 ++++------- hello/hello_child_workflow.py | 12 ++++-------- hello/hello_continue_as_new.py | 12 ++++-------- hello/hello_cron.py | 12 ++++-------- hello/hello_exception.py | 12 ++++-------- hello/hello_local_activity.py | 12 ++++-------- hello/hello_parallel_activity.py | 12 ++++-------- hello/hello_patch.py | 12 ++++-------- hello/hello_query.py | 12 ++++-------- hello/hello_search_attributes.py | 12 ++++-------- hello/hello_signal.py | 12 ++++-------- hello/hello_update.py | 12 ++++-------- hello_nexus/caller/app.py | 10 ++++------ hello_nexus/handler/worker.py | 10 ++++------ langchain/starter.py | 11 ++++------- langchain/worker.py | 11 ++++------- message_passing/introduction/starter.py | 10 ++++------ message_passing/introduction/worker.py | 11 ++++------- message_passing/safe_message_handlers/starter.py | 11 ++++------- message_passing/safe_message_handlers/worker.py | 11 ++++------- .../lazy_initialization/starter.py | 11 +++++------ .../lazy_initialization/worker.py | 11 ++++------- message_passing/waiting_for_handlers/starter.py | 10 ++++------ message_passing/waiting_for_handlers/worker.py | 11 ++++------- .../starter.py | 10 ++++------ .../worker.py | 11 ++++------- open_telemetry/starter.py | 10 ++++------ open_telemetry/worker.py | 11 ++++------- .../basic/run_agent_lifecycle_workflow.py | 11 ++++------- openai_agents/basic/run_remote_image_workflow.py | 10 ++++------ .../handoffs/run_message_filter_workflow.py | 10 ++++------ patching/starter.py | 11 ++++------- patching/worker.py | 11 ++++------- polling/frequent/run_frequent.py | 10 ++++------ polling/frequent/run_worker.py | 11 ++++------- polling/infrequent/run_infrequent.py | 10 ++++------ polling/infrequent/run_worker.py | 11 ++++------- polling/periodic_sequence/run_periodic.py | 10 ++++------ polling/periodic_sequence/run_worker.py | 11 ++++------- prometheus/starter.py | 10 ++++------ prometheus/worker.py | 11 ++++------- pydantic_converter/starter.py | 10 ++++------ pydantic_converter/worker.py | 11 ++++------- pydantic_converter_v1/starter.py | 10 ++++------ pydantic_converter_v1/worker.py | 11 ++++------- replay/replayer.py | 11 ++++------- replay/starter.py | 11 ++++------- replay/worker.py | 12 ++++-------- resource_pool/starter.py | 11 ++++------- resource_pool/worker.py | 11 ++++------- schedules/backfill_schedule.py | 11 ++++------- schedules/delete_schedule.py | 11 ++++------- schedules/describe_schedule.py | 11 ++++------- schedules/list_schedule.py | 12 ++++-------- schedules/pause_schedule.py | 11 ++++------- schedules/run_worker.py | 11 ++++------- schedules/start_schedule.py | 11 ++++------- schedules/trigger_schedule.py | 11 ++++------- schedules/update_schedule.py | 15 ++++++++------- sentry/starter.py | 11 ++++------- sentry/worker.py | 12 ++++-------- sleep_for_days/starter.py | 11 ++++------- sleep_for_days/worker.py | 11 ++++------- trio_async/starter.py | 11 ++++------- trio_async/worker.py | 11 ++++------- updatable_timer/starter.py | 11 ++++------- updatable_timer/wake_up_time_updater.py | 10 ++++------ updatable_timer/worker.py | 10 ++++------ worker_specific_task_queues/starter.py | 11 ++++------- worker_specific_task_queues/worker.py | 11 ++++------- 107 files changed, 433 insertions(+), 748 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index b6a9a4e9..5e4f274b 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -4,11 +4,9 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - task_queue = "say-hello-task-queue" workflow_name = "say-hello-workflow" activity_name = "say-hello-activity" @@ -21,11 +19,9 @@ async def say_hello_activity(name: str) -> str: async def main(): # Create client to localhost on default namespace - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run activity worker async with Worker(client, task_queue=task_queue, activities=[say_hello_activity]): diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index 4bdbdd39..d6554b14 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -6,13 +6,12 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from batch_sliding_window.batch_workflow import ( ProcessBatchWorkflow, ProcessBatchWorkflowInput, ) -from util import get_temporal_config_path async def main(): @@ -21,11 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Create unique workflow ID with timestamp timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index 62c4c3f7..3a5c1a06 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -6,13 +6,12 @@ from temporalio import worker from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from batch_sliding_window.batch_workflow import ProcessBatchWorkflow from batch_sliding_window.record_loader_activity import RecordLoader from batch_sliding_window.record_processor_workflow import RecordProcessorWorkflow from batch_sliding_window.sliding_window_workflow import SlidingWindowWorkflow -from util import get_temporal_config_path async def main(): @@ -21,11 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Create RecordLoader activity with sample data record_loader = RecordLoader(record_count=90) diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index 7c88ca35..ad423f23 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -3,21 +3,19 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import BasicBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 7d199cd2..84d9ba9e 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -2,19 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import BasicBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt: str) -> str: # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Start the workflow workflow_id = "basic-bedrock-workflow" diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 03d272e2..413c54ac 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -2,19 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index 03a59c9f..e207cf01 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -1,19 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" handle = client.get_workflow_handle(workflow_id) diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 0f368eaf..3456ad77 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -3,21 +3,19 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import EntityBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 7d4c4148..64b1c7a3 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -2,19 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import BedrockParams, EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index cbbc750d..6984344d 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -1,19 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import SignalQueryBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" handle = client.get_workflow_handle(workflow_id) diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index 4a104fe9..dd7ce317 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -3,21 +3,19 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import SignalQueryBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) activities = BedrockActivities() # Run the worker diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 8a98df61..8ed12b67 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -2,19 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import SignalQueryBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt): # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) workflow_id = "bedrock-workflow-with-signals" inactivity_timeout_minutes = 1 diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index ce82c8ed..b843eb09 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -10,23 +10,21 @@ ScheduleSpec, WorkflowFailureError, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from cloud_export_to_parquet.workflows import ( ProtoToParquet, ProtoToParquetWorkflowInput, ) -from util import get_temporal_config_path async def main() -> None: """Main function to run temporal workflow.""" # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) # TODO: update s3_bucket and namespace to the actual usecase wf_input = ProtoToParquetWorkflowInput( num_delay_hour=2, diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index ee0c7cb2..2a6e413f 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -14,17 +14,14 @@ get_object_keys, ) from cloud_export_to_parquet.workflows import ProtoToParquet -from util import get_temporal_config_path async def main() -> None: """Main worker function.""" # Create client connected to server at the given address - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run the worker worker: Worker = Worker( diff --git a/context_propagation/starter.py b/context_propagation/starter.py index f3ff97af..d2c6c349 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -2,10 +2,9 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from context_propagation import interceptor, shared, workflows -from util import get_temporal_config_path async def main(): @@ -14,13 +13,12 @@ async def main(): # Set the user ID shared.user_id.set("some-user") - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/context_propagation/worker.py b/context_propagation/worker.py index 158a99dc..125281c5 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -2,11 +2,10 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -14,13 +13,12 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 364b3c68..5463aabb 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_converter.shared import ( GreetingInput, @@ -9,17 +9,15 @@ greeting_data_converter, ) from custom_converter.workflow import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Without this we get: # TypeError: Object of type GreetingInput is not JSON serializable data_converter=greeting_data_converter, diff --git a/custom_converter/worker.py b/custom_converter/worker.py index a22a4dea..84c87f02 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,24 +1,22 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from custom_converter.shared import greeting_data_converter from custom_converter.workflow import GreetingWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Without this, when trying to run a workflow, we get: # KeyError: 'Unknown payload encoding my-greeting-encoding data_converter=greeting_data_converter, diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index e288d054..1b443b9f 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -1,19 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_decorator.worker import WaitForCancelWorkflow -from util import get_temporal_config_path async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Start the workflow handle = await client.start_workflow( diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index 6119d259..5cd5dc0a 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -4,11 +4,10 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater -from util import get_temporal_config_path # Here we use our automatic heartbeater decorator. If this wasn't present, our @@ -53,11 +52,9 @@ def cancel_activity(self) -> None: async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/custom_metric/starter.py b/custom_metric/starter.py index 76abc5cf..86a4608f 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -2,18 +2,15 @@ import uuid from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_metric.workflow import StartTwoActivitiesWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) await client.start_workflow( StartTwoActivitiesWorkflow.run, diff --git a/custom_metric/worker.py b/custom_metric/worker.py index 003da668..a9504708 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -3,7 +3,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import ( ActivityInboundInterceptor, @@ -14,7 +14,6 @@ from custom_metric.activity import print_and_sleep from custom_metric.workflow import StartTwoActivitiesWorkflow -from util import get_temporal_config_path class SimpleWorkerInterceptor(Interceptor): @@ -50,11 +49,10 @@ async def main(): runtime = Runtime( telemetry=TelemetryConfig(metrics=PrometheusConfig(bind_address="0.0.0.0:9090")) ) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) worker = Worker( diff --git a/dsl/starter.py b/dsl/starter.py index 924f137f..132be4d4 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -6,10 +6,9 @@ import dacite import yaml from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from dsl.workflow import DSLInput, DSLWorkflow -from util import get_temporal_config_path async def main(dsl_yaml: str) -> None: @@ -18,11 +17,9 @@ async def main(dsl_yaml: str) -> None: dsl_input = dacite.from_dict(DSLInput, yaml.safe_load(dsl_yaml)) # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run workflow result = await client.execute_workflow( diff --git a/dsl/worker.py b/dsl/worker.py index 4d3085c5..6bd39f8e 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -2,23 +2,20 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from dsl.activities import DSLActivities from dsl.workflow import DSLWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the activities and workflow activities = DSLActivities() diff --git a/encryption/starter.py b/encryption/starter.py index f0fae71b..39a30cd2 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -3,22 +3,20 @@ import temporalio.converter from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow -from util import get_temporal_config_path async def main(): # Load configuration - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/encryption/worker.py b/encryption/worker.py index 4cfa064d..ff8aeed6 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -4,11 +4,10 @@ import temporalio.converter from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from encryption.codec import EncryptionCodec -from util import get_temporal_config_path @workflow.defn(name="Workflow") @@ -22,13 +21,12 @@ async def run(self, name: str) -> str: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 12f06053..72f7b08e 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -7,11 +7,10 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from gevent_async import workflow from gevent_async.executor import GeventExecutor -from util import get_temporal_config_path def main(): @@ -26,11 +25,9 @@ def main(): async def async_main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run workflow result = await client.execute_workflow( diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 1ef59c0d..5707e910 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -9,12 +9,11 @@ import gevent from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from gevent_async import activity, workflow from gevent_async.executor import GeventExecutor -from util import get_temporal_config_path def main(): @@ -41,11 +40,9 @@ async def async_main(): ) # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Create an executor for use by Temporal. This cannot be the outer one # running this async main. The max_workers here needs to have enough room to diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 8e046951..ea25b706 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -46,12 +44,11 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Load configuration - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index 675543e4..b19ff632 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -4,11 +4,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -45,11 +43,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index b2c3f670..dc03b5d4 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -7,11 +7,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # Activities that will be called by the workflow @@ -83,12 +81,10 @@ async def run(self, shopping_list: ShoppingList) -> str: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 834ab249..43dcc0ec 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -44,11 +42,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index cc253349..4eef957a 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -3,11 +3,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - class MyDatabaseClient: async def run_database_update(self) -> None: @@ -35,11 +33,9 @@ async def run(self) -> None: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Create our database client that can then be used in the activity db_client = MyDatabaseClient() diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index 57c3f261..754a7d8f 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -8,11 +8,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import SharedStateManager, Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -46,11 +44,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index 23d633c1..6a208815 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -48,11 +46,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 29c2b47a..9a43b67b 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -4,11 +4,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -71,11 +69,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow composer = GreetingComposer(client) diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 60a50631..1975d9c1 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -7,12 +7,10 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import CancelledError from temporalio.worker import Worker -from util import get_temporal_config_path - @activity.defn def never_complete_activity() -> NoReturn: @@ -53,12 +51,10 @@ async def run(self) -> None: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 7454b94d..15514816 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -11,11 +11,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # --- Begin logging set‑up ---------------------------------------------------------- logging.basicConfig( stream=sys.stdout, @@ -53,11 +51,10 @@ async def run(self): async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) async with Worker( client, task_queue="hello-change-log-level-task-queue", diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 486b82cb..9577a5da 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -34,12 +32,10 @@ async def run(self, name: str) -> str: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index 95a68151..bc422b6b 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class LoopingWorkflow: @@ -25,11 +23,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_cron.py b/hello/hello_cron.py index 7120d1de..862db998 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -36,11 +34,9 @@ async def run(self, name: str) -> None: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_exception.py b/hello/hello_exception.py index 5afc7bf6..56ca5ccf 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -8,12 +8,10 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import FailureError from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -42,11 +40,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 52572fc5..b5b3f64b 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -35,11 +33,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index 3520689c..134e6a47 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @activity.defn def say_hello_activity(name: str) -> str: @@ -44,11 +42,9 @@ async def run(self) -> List[str]: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_patch.py b/hello/hello_patch.py index e836111b..cba7d7ad 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -6,11 +6,9 @@ from temporalio import activity, exceptions, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -104,11 +102,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Set workflow_class to the proper class based on version workflow_class = "" diff --git a/hello/hello_query.py b/hello/hello_query.py index 730e3ea0..2b150f80 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -29,12 +27,10 @@ def greeting(self) -> str: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index 7904e55e..c44cfb3e 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -19,11 +17,9 @@ async def run(self) -> None: async def main(): # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_signal.py b/hello/hello_signal.py index 2fdca213..381f03ce 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -43,12 +41,10 @@ def exit(self) -> None: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_update.py b/hello/hello_update.py index 9f8e61a2..0e09f12a 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -25,11 +23,9 @@ async def update_workflow_status(self) -> str: async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 5446b98d..cbb5b65e 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -3,12 +3,11 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from hello_nexus.caller.workflows import CallerWorkflow from hello_nexus.service import MyOutput -from util import get_temporal_config_path NAMESPACE = "hello-nexus-basic-caller-namespace" TASK_QUEUE = "hello-nexus-basic-caller-task-queue" @@ -18,12 +17,11 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[MyOutput, MyOutput]: if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Override the namespace from config file. config["namespace"] = NAMESPACE - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index 9034c979..34b38015 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -3,12 +3,11 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from hello_nexus.handler.service_handler import MyNexusServiceHandler from hello_nexus.handler.workflows import WorkflowStartedByNexusOperation -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -20,12 +19,11 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Override the namespace from the config file. config["namespace"] = NAMESPACE - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Start the worker, passing the Nexus service handler instance, in addition to the # workflow classes that are started by your nexus operations, and any activities diff --git a/langchain/starter.py b/langchain/starter.py index 8795c44c..ca21b1c7 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -7,20 +7,17 @@ from fastapi import FastAPI, HTTPException from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflow import LangChainWorkflow, TranslateWorkflowParams -from util import get_temporal_config_path - @asynccontextmanager async def lifespan(app: FastAPI): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" client = await Client.connect( - **config, + **config.to_client_connect_config(), interceptors=[LangChainContextPropagationInterceptor()], ) yield diff --git a/langchain/worker.py b/langchain/worker.py index 181b19a0..a47ab1fa 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -3,21 +3,18 @@ from activities import translate_phrase from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow -from util import get_temporal_config_path - interrupt_event = asyncio.Event() async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) worker = Worker( client, task_queue="langchain-task-queue", diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index 8deb29ac..fb53f4b8 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -2,7 +2,7 @@ from typing import Optional from temporalio.client import Client, WorkflowUpdateStage -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.introduction import TASK_QUEUE from message_passing.introduction.workflows import ( @@ -12,16 +12,14 @@ Language, SetLanguageInput, ) -from util import get_temporal_config_path async def main(client: Optional[Client] = None): if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) wf_handle = await client.start_workflow( GreetingWorkflow.run, id="greeting-workflow-1234", diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 8aa6eb10..73c4cc31 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -2,13 +2,12 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.introduction import TASK_QUEUE from message_passing.introduction.activities import call_greeting_service from message_passing.introduction.workflows import GreetingWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -16,11 +15,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 2ee49f28..42921af8 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -6,7 +6,7 @@ from temporalio import common from temporalio.client import Client, WorkflowHandle -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.safe_message_handlers.workflow import ( ClusterManagerAssignNodesToJobInput, @@ -14,7 +14,6 @@ ClusterManagerInput, ClusterManagerWorkflow, ) -from util import get_temporal_config_path async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] = None): @@ -56,11 +55,9 @@ async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] async def main(should_test_continue_as_new: bool): # Connect to Temporal - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) print("Starting cluster") cluster_manager_handle = await client.start_workflow( diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index fad90aaa..5d621fdf 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.safe_message_handlers.workflow import ( @@ -12,17 +12,14 @@ start_cluster, unassign_nodes_for_job, ) -from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index 323f9bd0..61c55da9 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -9,7 +9,7 @@ WorkflowHandle, WorkflowUpdateFailedError, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import ApplicationError from message_passing.update_with_start.lazy_initialization import TASK_QUEUE @@ -17,7 +17,6 @@ ShoppingCartItem, ShoppingCartWorkflow, ) -from util import get_temporal_config_path async def handle_add_item_request( @@ -63,11 +62,11 @@ async def handle_add_item_request( async def main(): print("🛒") session_id = f"session-{uuid.uuid4()}" - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) + subtotal_1, _ = await handle_add_item_request(session_id, "sku-123", 1, client) subtotal_2, wf_handle = await handle_add_item_request( session_id, "sku-456", 1, client diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index 0952aa0e..a49068bc 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows from message_passing.update_with_start.lazy_initialization.activities import get_price -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -15,11 +14,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 9a8f48b9..9e2a4bbc 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.waiting_for_handlers import ( TASK_QUEUE, @@ -10,15 +10,13 @@ WorkflowInput, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow -from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + cl = await Client.connect(**config.to_client_connect_config()) - cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersWorkflow.run, WorkflowInput(exit_type=exit_type), diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 82dee079..4aeedbea 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.waiting_for_handlers import TASK_QUEUE @@ -10,7 +10,6 @@ activity_executed_by_update_handler, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -18,11 +17,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index ba9bfdc4..585648e2 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.waiting_for_handlers_and_compensation import ( TASK_QUEUE, @@ -12,15 +12,13 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) -from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + cl = await Client.connect(**config.to_client_connect_config()) - cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersAndCompensationWorkflow.run, WorkflowInput(exit_type=exit_type), diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 05579de5..c0415f55 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.waiting_for_handlers_and_compensation import TASK_QUEUE @@ -14,18 +14,15 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) -from util import get_temporal_config_path interrupt_event = asyncio.Event() async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async with Worker( client, diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 6cc187d6..5981f940 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -2,22 +2,20 @@ from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry -from util import get_temporal_config_path async def main(): runtime = init_runtime_with_telemetry() - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 59fb9e28..9fd3bd91 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -9,12 +9,10 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -53,13 +51,12 @@ def init_runtime_with_telemetry() -> Runtime: async def main(): runtime = init_runtime_with_telemetry() - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 0197ac32..49e744b8 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, ) -from util import get_temporal_config_path async def main() -> None: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) user_input = input("Enter a max number: ") max_number = int(user_input) diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index 1c183170..528867bc 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -2,19 +2,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" client = await Client.connect( - **config, + **config.to_client_connect_config(), plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 16c819b2..cb378870 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -3,22 +3,20 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, ) -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Create client connected to server at the given address client = await Client.connect( - **config, + **config.to_client_connect_config(), plugins=[ OpenAIAgentsPlugin(), ], diff --git a/patching/starter.py b/patching/starter.py index 49f8141a..3deb991a 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -2,12 +2,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile # Since it's just used for typing purposes, it doesn't matter which one we # import from patching.workflow_1_initial import MyWorkflow -from util import get_temporal_config_path async def main(): @@ -19,11 +18,9 @@ async def main(): raise RuntimeError("Either --start-workflow or --query-workflow is required") # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) if args.start_workflow: handle = await client.start_workflow( diff --git a/patching/worker.py b/patching/worker.py index e3447048..15b067fb 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -2,11 +2,10 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -32,11 +31,9 @@ async def main(): raise RuntimeError("Unrecognized workflow") # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 65935155..05570a41 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -1,18 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.frequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index ced52262..bb620631 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.frequent.activities import compose_greeting from polling.frequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) worker = Worker( client, diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index 6a9857a2..adb7481d 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -1,18 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.infrequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index b835a3fe..c864f663 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.infrequent.activities import compose_greeting from polling.infrequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) worker = Worker( client, diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index ac40e2e8..6903fcd8 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -1,18 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.periodic_sequence.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, "World", diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 3b996b9a..0b3f7833 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.periodic_sequence.activities import compose_greeting from polling.periodic_sequence.workflows import ChildWorkflow, GreetingWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) worker = Worker( client, diff --git a/prometheus/starter.py b/prometheus/starter.py index 40ac9578..f2a2023c 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -12,13 +11,12 @@ async def main(): runtime = init_runtime_with_prometheus(9001) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) diff --git a/prometheus/worker.py b/prometheus/worker.py index 0d3c36ab..ac349493 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -3,12 +3,10 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -41,13 +39,12 @@ def init_runtime_with_prometheus(port: int) -> Runtime: async def main(): runtime = init_runtime_with_prometheus(9000) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 1f14e719..2452f879 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -5,23 +5,21 @@ from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from pydantic_converter.worker import MyPydanticModel, MyWorkflow -from util import get_temporal_config_path async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index 2b18f2b9..a2b1e84c 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # Always pass through external modules to the sandbox that you know are safe for # workflow use with workflow.unsafe.imports_passed_through(): @@ -45,14 +43,13 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 4ebba775..598f2d7e 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -4,24 +4,22 @@ from ipaddress import IPv4Address from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow -from util import get_temporal_config_path async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 9cfc06fb..f06539aa 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -21,8 +21,6 @@ from pydantic_converter_v1.converter import pydantic_data_converter -from util import get_temporal_config_path - class MyPydanticModel(BaseModel): some_ip: IPv4Address @@ -73,14 +71,13 @@ def new_sandbox_runner() -> SandboxedWorkflowRunner: async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/replay/replayer.py b/replay/replayer.py index 7716c617..f8f61314 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity -from util import get_temporal_config_path async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Fetch the histories of the workflows to be replayed workflows = client.list_workflows('WorkflowId="replayer-workflow-id"') diff --git a/replay/starter.py b/replay/starter.py index 3315df33..2a803f2d 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -1,19 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from replay.worker import JustActivity, JustTimer, TimerThenActivity -from util import get_temporal_config_path async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a few workflows # Importantly, normally we would *not* advise re-using the same workflow ID for all of these, diff --git a/replay/worker.py b/replay/worker.py index d9de987f..f97ab012 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -74,11 +72,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/resource_pool/starter.py b/resource_pool/starter.py index e7d85c88..ae2cfb5b 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -3,7 +3,7 @@ from temporalio.client import Client, WorkflowFailureError, WorkflowHandle from temporalio.common import WorkflowIDConflictPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from resource_pool.pool_client.resource_pool_workflow import ( ResourcePoolWorkflow, @@ -14,16 +14,13 @@ ResourceUserWorkflowInput, ) from resource_pool.shared import RESOURCE_POOL_WORKFLOW_ID -from util import get_temporal_config_path async def main() -> None: # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Initialize the resource pool resource_pool_handle = await client.start_workflow( diff --git a/resource_pool/worker.py b/resource_pool/worker.py index 40a114db..09e77895 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -2,23 +2,20 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow from resource_pool.resource_user_workflow import ResourceUserWorkflow, use_resource -from util import get_temporal_config_path async def main() -> None: logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow worker = Worker( diff --git a/schedules/backfill_schedule.py b/schedules/backfill_schedule.py index 445c700e..d9130e56 100644 --- a/schedules/backfill_schedule.py +++ b/schedules/backfill_schedule.py @@ -2,17 +2,14 @@ from datetime import datetime, timedelta from temporalio.client import Client, ScheduleBackfill, ScheduleOverlapPolicy -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/delete_schedule.py b/schedules/delete_schedule.py index a32e48ee..9331dab7 100644 --- a/schedules/delete_schedule.py +++ b/schedules/delete_schedule.py @@ -1,17 +1,14 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/describe_schedule.py b/schedules/describe_schedule.py index 2030bfe9..31068c7b 100644 --- a/schedules/describe_schedule.py +++ b/schedules/describe_schedule.py @@ -1,17 +1,14 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/list_schedule.py b/schedules/list_schedule.py index 65c6a9db..c52142fc 100644 --- a/schedules/list_schedule.py +++ b/schedules/list_schedule.py @@ -1,17 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main() -> None: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) async for schedule in await client.list_schedules(): print(f"List Schedule Info: {schedule.info}.") diff --git a/schedules/pause_schedule.py b/schedules/pause_schedule.py index 5ecf751f..e4122f7f 100644 --- a/schedules/pause_schedule.py +++ b/schedules/pause_schedule.py @@ -1,17 +1,14 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/run_worker.py b/schedules/run_worker.py index e67a7325..94028135 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -1,20 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from your_activities import your_activity from your_workflows import YourSchedulesWorkflow -from util import get_temporal_config_path - async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) worker = Worker( client, task_queue="schedules-task-queue", diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 6ac0ee9a..749bd383 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -9,18 +9,15 @@ ScheduleSpec, ScheduleState, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from your_workflows import YourSchedulesWorkflow -from util import get_temporal_config_path - async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) await client.create_schedule( "workflow-schedule-id", Schedule( diff --git a/schedules/trigger_schedule.py b/schedules/trigger_schedule.py index a9f72adf..f1646736 100644 --- a/schedules/trigger_schedule.py +++ b/schedules/trigger_schedule.py @@ -1,17 +1,14 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/schedules/update_schedule.py b/schedules/update_schedule.py index 5bf4cd15..3ea0df37 100644 --- a/schedules/update_schedule.py +++ b/schedules/update_schedule.py @@ -6,17 +6,18 @@ ScheduleUpdate, ScheduleUpdateInput, ) -from temporalio.envconfig import ClientConfig - -from util import get_temporal_config_path +from temporalio.envconfig import ClientConfigProfile async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) + # config_dict = ClientConfigProfile.load().to_dict() + # config_dict["address"] = "localhost:7233" + # config = ClientConfigProfile.from_dict(config_dict) + # client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", ) diff --git a/sentry/starter.py b/sentry/starter.py index bb162f46..c7c67013 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,19 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Connect client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run workflow try: diff --git a/sentry/worker.py b/sentry/worker.py index dcbd5988..2ab89471 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -5,7 +5,7 @@ from sentry_sdk.integrations.asyncio import AsyncioIntegration from sentry_sdk.types import Event, Hint from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -17,8 +17,6 @@ from sentry.workflow import SentryExampleWorkflow interrupt_event = asyncio.Event() -from util import get_temporal_config_path - def before_send(event: Event, hint: Hint) -> Event | None: # Filter out __ShutdownRequested events raised by the worker's internals @@ -53,12 +51,10 @@ async def main(): # Initialize the Sentry SDK initialise_sentry() - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index bc717f81..d4293bcf 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -3,20 +3,17 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) wf_handle = await client.start_workflow( SleepForDaysWorkflow.run, id=f"sleep-for-days-workflow-id-{uuid.uuid4()}", diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 0f2896a0..9595eaf2 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -2,21 +2,18 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from sleep_for_days import TASK_QUEUE from sleep_for_days.activities import send_email from sleep_for_days.workflows import SleepForDaysWorkflow -from util import get_temporal_config_path async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) worker = Worker( client, diff --git a/trio_async/starter.py b/trio_async/starter.py index 7f21e677..1feda76a 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -2,10 +2,9 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from trio_async import workflows -from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives @@ -13,11 +12,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Execute the workflow result = await client.execute_workflow( diff --git a/trio_async/worker.py b/trio_async/worker.py index 55c18c17..6b0b67b4 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -5,11 +5,10 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from trio_async import activities, workflows -from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives @@ -17,11 +16,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Temporal runs threaded activities and workflow tasks via run_in_executor. # Due to how trio_asyncio works, you can only do run_in_executor with their diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 73f6d47a..59ebd575 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -5,22 +5,19 @@ from temporalio import exceptions from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) try: handle = await client.start_workflow( Workflow.run, diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index f0002501..4165a45f 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -4,21 +4,19 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from updatable_timer.workflow import Workflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow") # signal workflow about the wake up time change await handle.signal( diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 44544330..c215e211 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -15,11 +14,10 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) async with Worker( client, task_queue=TASK_QUEUE, diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index 0b56ccdf..d2491918 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -2,19 +2,16 @@ from uuid import uuid4 from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile -from util import get_temporal_config_path from worker_specific_task_queues.tasks import FileProcessing async def main(): # Connect client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Start 10 concurrent workflows futures = [] diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index ee64ce34..5f8b52d8 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -6,10 +6,9 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path from worker_specific_task_queues import tasks interrupt_event = asyncio.Event() @@ -33,11 +32,9 @@ async def select_task_queue() -> str: return task_queue # Start client - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) - - client = await Client.connect(**config) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) # Run a worker to distribute the workflows run_futures = [] From 96b1f7a4894d7ca68f0f492a556e50f7c1bb1a74 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Wed, 13 Aug 2025 12:04:28 -0400 Subject: [PATCH 04/14] mutate config as dict --- activity_worker/activity_worker.py | 5 +++-- batch_sliding_window/starter.py | 5 +++-- batch_sliding_window/worker.py | 5 +++-- bedrock/basic/run_worker.py | 5 +++-- bedrock/basic/send_message.py | 5 +++-- bedrock/entity/end_chat.py | 5 +++-- bedrock/entity/get_history.py | 5 +++-- bedrock/entity/run_worker.py | 5 +++-- bedrock/entity/send_message.py | 5 +++-- bedrock/signals_and_queries/get_history.py | 5 +++-- bedrock/signals_and_queries/run_worker.py | 5 +++-- bedrock/signals_and_queries/send_message.py | 5 +++-- cloud_export_to_parquet/create_schedule.py | 5 +++-- cloud_export_to_parquet/run_worker.py | 5 +++-- context_propagation/starter.py | 5 +++-- context_propagation/worker.py | 5 +++-- custom_converter/starter.py | 5 +++-- custom_converter/worker.py | 5 +++-- custom_decorator/starter.py | 5 +++-- custom_decorator/worker.py | 5 +++-- custom_metric/starter.py | 5 +++-- custom_metric/worker.py | 5 +++-- dsl/starter.py | 5 +++-- dsl/worker.py | 5 +++-- encryption/starter.py | 5 +++-- encryption/worker.py | 5 +++-- gevent_async/starter.py | 5 +++-- gevent_async/worker.py | 5 +++-- hello/hello_activity.py | 5 +++-- hello/hello_activity_async.py | 5 +++-- hello/hello_activity_choice.py | 5 +++-- hello/hello_activity_heartbeat.py | 5 +++-- hello/hello_activity_method.py | 5 +++-- hello/hello_activity_multiprocess.py | 5 +++-- hello/hello_activity_retry.py | 5 +++-- hello/hello_async_activity_completion.py | 5 +++-- hello/hello_cancellation.py | 5 +++-- hello/hello_change_log_level.py | 5 +++-- hello/hello_child_workflow.py | 5 +++-- hello/hello_continue_as_new.py | 5 +++-- hello/hello_cron.py | 5 +++-- hello/hello_exception.py | 5 +++-- hello/hello_local_activity.py | 5 +++-- hello/hello_parallel_activity.py | 5 +++-- hello/hello_patch.py | 5 +++-- hello/hello_query.py | 5 +++-- hello/hello_search_attributes.py | 5 +++-- hello/hello_signal.py | 5 +++-- hello/hello_update.py | 5 +++-- hello_nexus/caller/app.py | 7 ++++--- hello_nexus/handler/worker.py | 9 +++++---- langchain/starter.py | 5 +++-- langchain/worker.py | 5 +++-- message_passing/introduction/starter.py | 5 +++-- message_passing/introduction/worker.py | 5 +++-- message_passing/safe_message_handlers/starter.py | 5 +++-- message_passing/safe_message_handlers/worker.py | 5 +++-- .../update_with_start/lazy_initialization/starter.py | 5 +++-- .../update_with_start/lazy_initialization/worker.py | 5 +++-- message_passing/waiting_for_handlers/starter.py | 7 ++++--- message_passing/waiting_for_handlers/worker.py | 5 +++-- .../waiting_for_handlers_and_compensation/starter.py | 7 ++++--- .../waiting_for_handlers_and_compensation/worker.py | 5 +++-- open_telemetry/starter.py | 5 +++-- open_telemetry/worker.py | 5 +++-- openai_agents/basic/run_agent_lifecycle_workflow.py | 5 +++-- openai_agents/basic/run_remote_image_workflow.py | 5 +++-- openai_agents/handoffs/run_message_filter_workflow.py | 5 +++-- patching/starter.py | 5 +++-- patching/worker.py | 5 +++-- polling/frequent/run_frequent.py | 5 +++-- polling/frequent/run_worker.py | 5 +++-- polling/infrequent/run_infrequent.py | 5 +++-- polling/infrequent/run_worker.py | 5 +++-- polling/periodic_sequence/run_periodic.py | 5 +++-- polling/periodic_sequence/run_worker.py | 5 +++-- prometheus/starter.py | 5 +++-- prometheus/worker.py | 5 +++-- pydantic_converter/starter.py | 5 +++-- pydantic_converter/worker.py | 5 +++-- pydantic_converter_v1/starter.py | 5 +++-- pydantic_converter_v1/worker.py | 5 +++-- replay/replayer.py | 5 +++-- replay/starter.py | 5 +++-- replay/worker.py | 5 +++-- resource_pool/starter.py | 5 +++-- resource_pool/worker.py | 5 +++-- schedules/backfill_schedule.py | 5 +++-- schedules/delete_schedule.py | 5 +++-- schedules/describe_schedule.py | 5 +++-- schedules/list_schedule.py | 5 +++-- schedules/pause_schedule.py | 5 +++-- schedules/run_worker.py | 5 +++-- schedules/start_schedule.py | 5 +++-- schedules/trigger_schedule.py | 5 +++-- schedules/update_schedule.py | 9 +++------ sentry/starter.py | 5 +++-- sentry/worker.py | 5 +++-- sleep_for_days/starter.py | 5 +++-- sleep_for_days/worker.py | 5 +++-- trio_async/starter.py | 5 +++-- trio_async/worker.py | 5 +++-- updatable_timer/starter.py | 5 +++-- updatable_timer/wake_up_time_updater.py | 5 +++-- updatable_timer/worker.py | 5 +++-- worker_specific_task_queues/starter.py | 5 +++-- worker_specific_task_queues/worker.py | 5 +++-- 107 files changed, 326 insertions(+), 223 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 5e4f274b..20f578b5 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -19,8 +19,9 @@ async def say_hello_activity(name: str) -> str: async def main(): # Create client to localhost on default namespace - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run activity worker diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index d6554b14..f3eccfa4 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -20,8 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Create unique workflow ID with timestamp diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index 3a5c1a06..5579c3f4 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -20,8 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Create RecordLoader activity with sample data diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index ad423f23..08de652b 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -12,8 +12,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) activities = BedrockActivities() diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 84d9ba9e..31d783a5 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -8,8 +8,9 @@ async def main(prompt: str) -> str: # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Start the workflow diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 413c54ac..80a093ac 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -8,8 +8,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index e207cf01..786c1429 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -7,8 +7,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 3456ad77..8af05356 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -12,8 +12,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) activities = BedrockActivities() diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 64b1c7a3..231eff70 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -8,8 +8,9 @@ async def main(prompt): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index 6984344d..ce6988b6 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -7,8 +7,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) workflow_id = "bedrock-workflow-with-signals" diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index dd7ce317..89b59608 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -12,8 +12,9 @@ async def main(): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) activities = BedrockActivities() diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 8ed12b67..b7f00d00 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -8,8 +8,9 @@ async def main(prompt): # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) workflow_id = "bedrock-workflow-with-signals" diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index b843eb09..2d440e54 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -21,8 +21,9 @@ async def main() -> None: """Main function to run temporal workflow.""" # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # TODO: update s3_bucket and namespace to the actual usecase diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index 2a6e413f..72a66da4 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -19,8 +19,9 @@ async def main() -> None: """Main worker function.""" # Create client connected to server at the given address - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run the worker diff --git a/context_propagation/starter.py b/context_propagation/starter.py index d2c6c349..ece77752 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -13,8 +13,9 @@ async def main(): # Set the user ID shared.user_id.set("some-user") - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/context_propagation/worker.py b/context_propagation/worker.py index 125281c5..ad990376 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -13,8 +13,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 5463aabb..5b33be13 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -12,8 +12,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/custom_converter/worker.py b/custom_converter/worker.py index 84c87f02..fcd81942 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -11,8 +11,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index 1b443b9f..fb366aa6 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -8,8 +8,9 @@ async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Start the workflow diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index 5cd5dc0a..b551c236 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -52,8 +52,9 @@ def cancel_activity(self) -> None: async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/custom_metric/starter.py b/custom_metric/starter.py index 86a4608f..7a7dd8fb 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -8,8 +8,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) await client.start_workflow( diff --git a/custom_metric/worker.py b/custom_metric/worker.py index a9504708..0135c661 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -49,8 +49,9 @@ async def main(): runtime = Runtime( telemetry=TelemetryConfig(metrics=PrometheusConfig(bind_address="0.0.0.0:9090")) ) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect( **config.to_client_connect_config(), runtime=runtime, diff --git a/dsl/starter.py b/dsl/starter.py index 132be4d4..015d332f 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -17,8 +17,9 @@ async def main(dsl_yaml: str) -> None: dsl_input = dacite.from_dict(DSLInput, yaml.safe_load(dsl_yaml)) # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run workflow diff --git a/dsl/worker.py b/dsl/worker.py index 6bd39f8e..b454022b 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -13,8 +13,9 @@ async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the activities and workflow diff --git a/encryption/starter.py b/encryption/starter.py index 39a30cd2..40f3f1ad 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -11,8 +11,9 @@ async def main(): # Load configuration - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/encryption/worker.py b/encryption/worker.py index ff8aeed6..f128c8c0 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -21,8 +21,9 @@ async def run(self, name: str) -> str: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 72f7b08e..ef8da622 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -25,8 +25,9 @@ def main(): async def async_main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run workflow diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 5707e910..eb6050d3 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -40,8 +40,9 @@ async def async_main(): ) # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Create an executor for use by Temporal. This cannot be the outer one diff --git a/hello/hello_activity.py b/hello/hello_activity.py index ea25b706..19529690 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -44,8 +44,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Load configuration - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index b19ff632..208e1023 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -43,8 +43,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index dc03b5d4..5a1e4536 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -81,8 +81,9 @@ async def run(self, shopping_list: ShoppingList) -> str: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 43dcc0ec..60828933 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -42,8 +42,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index 4eef957a..a441d542 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -33,8 +33,9 @@ async def run(self) -> None: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Create our database client that can then be used in the activity diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index 754a7d8f..e2c329b4 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -44,8 +44,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index 6a208815..98f06b2e 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -46,8 +46,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 9a43b67b..97786bae 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -69,8 +69,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 1975d9c1..ab30c00d 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -51,8 +51,9 @@ async def run(self) -> None: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 15514816..226333a1 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -51,8 +51,9 @@ async def run(self): async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 9577a5da..3f841321 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -32,8 +32,9 @@ async def run(self, name: str) -> str: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index bc422b6b..f63ce829 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -23,8 +23,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_cron.py b/hello/hello_cron.py index 862db998..ec0c9c1e 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -34,8 +34,9 @@ async def run(self, name: str) -> None: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_exception.py b/hello/hello_exception.py index 56ca5ccf..b1bcc556 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -40,8 +40,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index b5b3f64b..3d0a51a7 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -33,8 +33,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index 134e6a47..bfd19404 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -42,8 +42,9 @@ async def run(self) -> List[str]: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_patch.py b/hello/hello_patch.py index cba7d7ad..2db20b83 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -102,8 +102,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Set workflow_class to the proper class based on version diff --git a/hello/hello_query.py b/hello/hello_query.py index 2b150f80..3b2888ab 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -27,8 +27,9 @@ def greeting(self) -> str: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index c44cfb3e..c4330055 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -17,8 +17,9 @@ async def run(self) -> None: async def main(): # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello/hello_signal.py b/hello/hello_signal.py index 381f03ce..c11e3f68 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -41,8 +41,9 @@ def exit(self) -> None: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/hello/hello_update.py b/hello/hello_update.py index 0e09f12a..e40ee437 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -23,8 +23,9 @@ async def update_workflow_status(self) -> str: async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index cbb5b65e..f0bfbcd8 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -17,10 +17,11 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[MyOutput, MyOutput]: if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() # Override the namespace from config file. - config["namespace"] = NAMESPACE + config_dict.setdefault("address", "localhost:7233") + config_dict["namespace"] = NAMESPACE + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index 34b38015..f9040989 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -19,10 +19,11 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" - # Override the namespace from the config file. - config["namespace"] = NAMESPACE + config_dict = ClientConfigProfile.load().to_dict() + # Override the address and namespace from the config file. + config_dict.setdefault("address", "localhost:7233") + config_dict["namespace"] = NAMESPACE + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Start the worker, passing the Nexus service handler instance, in addition to the diff --git a/langchain/starter.py b/langchain/starter.py index ca21b1c7..d7139979 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -13,8 +13,9 @@ @asynccontextmanager async def lifespan(app: FastAPI): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect( **config.to_client_connect_config(), diff --git a/langchain/worker.py b/langchain/worker.py index a47ab1fa..088cbf7b 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -11,8 +11,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index fb53f4b8..3f1135c0 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -16,8 +16,9 @@ async def main(client: Optional[Client] = None): if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) wf_handle = await client.start_workflow( diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 73c4cc31..380dc45d 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -15,8 +15,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 42921af8..9ebd95c6 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -55,8 +55,9 @@ async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] async def main(should_test_continue_as_new: bool): # Connect to Temporal - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) print("Starting cluster") diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index 5d621fdf..a7bb2d69 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -17,8 +17,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index 61c55da9..cb2c5be2 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -63,8 +63,9 @@ async def main(): print("🛒") session_id = f"session-{uuid.uuid4()}" - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) subtotal_1, _ = await handle_add_item_request(session_id, "sku-123", 1, client) diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index a49068bc..f4612166 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -14,8 +14,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 9e2a4bbc..0d799226 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -13,9 +13,10 @@ async def starter(exit_type: WorkflowExitType): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" - cl = await Client.connect(**config.to_client_connect_config()) + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) + cl = await client.Client.connect(**config.to_client_connect_config()) wf_handle = await cl.start_workflow( WaitingForHandlersWorkflow.run, diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 4aeedbea..6bf239ad 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -17,8 +17,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index 585648e2..e4ecde1f 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -15,9 +15,10 @@ async def starter(exit_type: WorkflowExitType): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" - cl = await Client.connect(**config.to_client_connect_config()) + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) + cl = await client.Client.connect(**config.to_client_connect_config()) wf_handle = await cl.start_workflow( WaitingForHandlersAndCompensationWorkflow.run, diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index c0415f55..9d90c114 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -20,8 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 5981f940..3218b0e3 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -10,8 +10,9 @@ async def main(): runtime = init_runtime_with_telemetry() - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 9fd3bd91..dca39cf0 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -51,8 +51,9 @@ def init_runtime_with_telemetry() -> Runtime: async def main(): runtime = init_runtime_with_telemetry() - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 49e744b8..c158b352 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -9,8 +9,9 @@ async def main() -> None: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) user_input = input("Enter a max number: ") diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index 528867bc..265b0b68 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -8,8 +8,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect( **config.to_client_connect_config(), diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index cb378870..21c7695f 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -11,8 +11,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Create client connected to server at the given address client = await Client.connect( diff --git a/patching/starter.py b/patching/starter.py index 3deb991a..7ddcd1f6 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -18,8 +18,9 @@ async def main(): raise RuntimeError("Either --start-workflow or --query-workflow is required") # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) if args.start_workflow: diff --git a/patching/worker.py b/patching/worker.py index 15b067fb..6dcf2e7c 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -31,8 +31,9 @@ async def main(): raise RuntimeError("Unrecognized workflow") # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 05570a41..fddc83e6 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -7,8 +7,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) result = await client.execute_workflow( diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index bb620631..55fb5310 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -9,8 +9,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index adb7481d..af7b5548 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -7,8 +7,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) result = await client.execute_workflow( diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index c864f663..eec9ede0 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -9,8 +9,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index 6903fcd8..1e4acb37 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -7,8 +7,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) result = await client.execute_workflow( diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 0b3f7833..999a9d23 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -9,8 +9,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/prometheus/starter.py b/prometheus/starter.py index f2a2023c..7e0a4d78 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -11,8 +11,9 @@ async def main(): runtime = init_runtime_with_prometheus(9001) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/prometheus/worker.py b/prometheus/worker.py index ac349493..a749b644 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -39,8 +39,9 @@ def init_runtime_with_prometheus(port: int) -> Runtime: async def main(): runtime = init_runtime_with_prometheus(9000) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect( diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 2452f879..ecbba38e 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -13,8 +13,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client using the Pydantic converter diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index a2b1e84c..7cd1d963 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -43,8 +43,9 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client using the Pydantic converter diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 598f2d7e..bde38238 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -13,8 +13,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client using the Pydantic converter diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index f06539aa..ab649d4f 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -71,8 +71,9 @@ def new_sandbox_runner() -> SandboxedWorkflowRunner: async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client using the Pydantic converter diff --git a/replay/replayer.py b/replay/replayer.py index f8f61314..8b205c5b 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -9,8 +9,9 @@ async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Fetch the histories of the workflows to be replayed diff --git a/replay/starter.py b/replay/starter.py index 2a803f2d..0a492360 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -8,8 +8,9 @@ async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a few workflows diff --git a/replay/worker.py b/replay/worker.py index f97ab012..51acd3dd 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -72,8 +72,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/resource_pool/starter.py b/resource_pool/starter.py index ae2cfb5b..47aca46c 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -18,8 +18,9 @@ async def main() -> None: # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Initialize the resource pool diff --git a/resource_pool/worker.py b/resource_pool/worker.py index 09e77895..1e4ef5ca 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -13,8 +13,9 @@ async def main() -> None: logging.basicConfig(level=logging.INFO) # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow diff --git a/schedules/backfill_schedule.py b/schedules/backfill_schedule.py index d9130e56..4fb6db6a 100644 --- a/schedules/backfill_schedule.py +++ b/schedules/backfill_schedule.py @@ -6,8 +6,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( diff --git a/schedules/delete_schedule.py b/schedules/delete_schedule.py index 9331dab7..268db7df 100644 --- a/schedules/delete_schedule.py +++ b/schedules/delete_schedule.py @@ -5,8 +5,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( diff --git a/schedules/describe_schedule.py b/schedules/describe_schedule.py index 31068c7b..c4a910cd 100644 --- a/schedules/describe_schedule.py +++ b/schedules/describe_schedule.py @@ -5,8 +5,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( diff --git a/schedules/list_schedule.py b/schedules/list_schedule.py index c52142fc..57791115 100644 --- a/schedules/list_schedule.py +++ b/schedules/list_schedule.py @@ -5,8 +5,9 @@ async def main() -> None: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async for schedule in await client.list_schedules(): diff --git a/schedules/pause_schedule.py b/schedules/pause_schedule.py index e4122f7f..b1c21970 100644 --- a/schedules/pause_schedule.py +++ b/schedules/pause_schedule.py @@ -5,8 +5,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( diff --git a/schedules/run_worker.py b/schedules/run_worker.py index 94028135..a8c02608 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -8,8 +8,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 749bd383..65c60f08 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -14,8 +14,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) await client.create_schedule( diff --git a/schedules/trigger_schedule.py b/schedules/trigger_schedule.py index f1646736..6a283e87 100644 --- a/schedules/trigger_schedule.py +++ b/schedules/trigger_schedule.py @@ -5,8 +5,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( diff --git a/schedules/update_schedule.py b/schedules/update_schedule.py index 3ea0df37..408d0194 100644 --- a/schedules/update_schedule.py +++ b/schedules/update_schedule.py @@ -10,13 +10,10 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) - # config_dict = ClientConfigProfile.load().to_dict() - # config_dict["address"] = "localhost:7233" - # config = ClientConfigProfile.from_dict(config_dict) - # client = await Client.connect(**config.to_client_connect_config()) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/sentry/starter.py b/sentry/starter.py index c7c67013..f3fee2d1 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -7,8 +7,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Connect client client = await Client.connect(**config.to_client_connect_config()) diff --git a/sentry/worker.py b/sentry/worker.py index 2ab89471..a1a5e474 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -51,8 +51,9 @@ async def main(): # Initialize the Sentry SDK initialise_sentry() - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) # Start client client = await Client.connect(**config.to_client_connect_config()) diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index d4293bcf..e567244f 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -11,8 +11,9 @@ async def main(client: Optional[Client] = None): if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) wf_handle = await client.start_workflow( SleepForDaysWorkflow.run, diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 9595eaf2..2ccb32b5 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -11,8 +11,9 @@ async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) worker = Worker( diff --git a/trio_async/starter.py b/trio_async/starter.py index 1feda76a..85d87b00 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -12,8 +12,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Execute the workflow diff --git a/trio_async/worker.py b/trio_async/worker.py index 6b0b67b4..17134558 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -16,8 +16,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Temporal runs threaded activities and workflow tasks via run_in_executor. diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 59ebd575..d9f11c12 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -15,8 +15,9 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) try: handle = await client.start_workflow( diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 4165a45f..0378d2e4 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -13,8 +13,9 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow") diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index c215e211..67472425 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -14,8 +14,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) async with Worker( diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index d2491918..58f6ee81 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -9,8 +9,9 @@ async def main(): # Connect client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Start 10 concurrent workflows diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index 5f8b52d8..30f6416a 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -32,8 +32,9 @@ async def select_task_queue() -> str: return task_queue # Start client - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" + config_dict = ClientConfigProfile.load().to_dict() + config_dict.setdefault("address", "localhost:7233") + config = ClientConfigProfile.from_dict(config_dict) client = await Client.connect(**config.to_client_connect_config()) # Run a worker to distribute the workflows From bd30c00ab536ad959cd0d45c1aa86877983cf70c Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Thu, 28 Aug 2025 11:09:11 -0400 Subject: [PATCH 05/14] update client config usage --- activity_worker/activity_worker.py | 9 ++++----- batch_sliding_window/starter.py | 9 ++++----- batch_sliding_window/worker.py | 9 ++++----- bedrock/basic/run_worker.py | 9 ++++----- bedrock/basic/send_message.py | 9 ++++----- bedrock/entity/end_chat.py | 9 ++++----- bedrock/entity/get_history.py | 9 ++++----- bedrock/entity/run_worker.py | 9 ++++----- bedrock/entity/send_message.py | 9 ++++----- bedrock/signals_and_queries/get_history.py | 9 ++++----- bedrock/signals_and_queries/run_worker.py | 9 ++++----- bedrock/signals_and_queries/send_message.py | 9 ++++----- cloud_export_to_parquet/create_schedule.py | 9 ++++----- cloud_export_to_parquet/run_worker.py | 9 ++++----- context_propagation/starter.py | 9 ++++----- context_propagation/worker.py | 9 ++++----- custom_converter/starter.py | 9 ++++----- custom_converter/worker.py | 9 ++++----- custom_decorator/starter.py | 9 ++++----- custom_decorator/worker.py | 9 ++++----- custom_metric/starter.py | 9 ++++----- custom_metric/worker.py | 9 ++++----- dsl/starter.py | 9 ++++----- dsl/worker.py | 9 ++++----- encryption/starter.py | 10 ++++------ encryption/worker.py | 10 ++++------ gevent_async/starter.py | 9 ++++----- gevent_async/worker.py | 9 ++++----- hello/hello_activity.py | 9 ++++----- hello/hello_activity_async.py | 9 ++++----- hello/hello_activity_choice.py | 10 +++++----- hello/hello_activity_heartbeat.py | 9 ++++----- hello/hello_activity_method.py | 9 ++++----- hello/hello_activity_multiprocess.py | 9 ++++----- hello/hello_activity_retry.py | 9 ++++----- hello/hello_async_activity_completion.py | 9 ++++----- hello/hello_cancellation.py | 10 +++++----- hello/hello_change_log_level.py | 9 ++++----- hello/hello_child_workflow.py | 10 +++++----- hello/hello_continue_as_new.py | 9 ++++----- hello/hello_cron.py | 9 ++++----- hello/hello_exception.py | 9 ++++----- hello/hello_local_activity.py | 9 ++++----- hello/hello_parallel_activity.py | 9 ++++----- hello/hello_patch.py | 9 ++++----- hello/hello_query.py | 10 +++++----- hello/hello_search_attributes.py | 9 ++++----- hello/hello_signal.py | 10 +++++----- hello/hello_update.py | 9 ++++----- hello_nexus/caller/app.py | 11 +++++------ hello_nexus/handler/worker.py | 11 +++++------ langchain/starter.py | 9 ++++----- langchain/worker.py | 9 ++++----- message_passing/introduction/starter.py | 9 ++++----- message_passing/introduction/worker.py | 9 ++++----- message_passing/safe_message_handlers/starter.py | 9 ++++----- message_passing/safe_message_handlers/worker.py | 9 ++++----- .../update_with_start/lazy_initialization/starter.py | 9 ++++----- .../update_with_start/lazy_initialization/worker.py | 9 ++++----- message_passing/waiting_for_handlers/starter.py | 9 ++++----- message_passing/waiting_for_handlers/worker.py | 9 ++++----- .../waiting_for_handlers_and_compensation/starter.py | 9 ++++----- .../waiting_for_handlers_and_compensation/worker.py | 9 ++++----- open_telemetry/starter.py | 10 ++++------ open_telemetry/worker.py | 9 ++++----- openai_agents/basic/run_agent_lifecycle_workflow.py | 9 ++++----- openai_agents/basic/run_remote_image_workflow.py | 9 ++++----- openai_agents/handoffs/run_message_filter_workflow.py | 9 ++++----- patching/starter.py | 9 ++++----- patching/worker.py | 9 ++++----- polling/frequent/run_frequent.py | 9 ++++----- polling/frequent/run_worker.py | 9 ++++----- polling/infrequent/run_infrequent.py | 9 ++++----- polling/infrequent/run_worker.py | 9 ++++----- polling/periodic_sequence/run_periodic.py | 9 ++++----- polling/periodic_sequence/run_worker.py | 9 ++++----- prometheus/starter.py | 9 ++++----- prometheus/worker.py | 9 ++++----- pydantic_converter/starter.py | 9 ++++----- pydantic_converter/worker.py | 10 ++++------ pydantic_converter_v1/starter.py | 9 ++++----- pydantic_converter_v1/worker.py | 9 ++++----- replay/replayer.py | 9 ++++----- replay/starter.py | 9 ++++----- replay/worker.py | 9 ++++----- resource_pool/starter.py | 9 ++++----- resource_pool/worker.py | 9 ++++----- schedules/backfill_schedule.py | 9 ++++----- schedules/delete_schedule.py | 9 ++++----- schedules/describe_schedule.py | 9 ++++----- schedules/list_schedule.py | 9 ++++----- schedules/pause_schedule.py | 9 ++++----- schedules/run_worker.py | 9 ++++----- schedules/start_schedule.py | 9 ++++----- schedules/trigger_schedule.py | 9 ++++----- schedules/update_schedule.py | 9 ++++----- sentry/starter.py | 10 +++++----- sentry/worker.py | 11 ++++++----- sleep_for_days/starter.py | 10 +++++----- sleep_for_days/worker.py | 9 ++++----- trio_async/starter.py | 9 ++++----- trio_async/worker.py | 9 ++++----- updatable_timer/starter.py | 9 ++++----- updatable_timer/wake_up_time_updater.py | 9 ++++----- updatable_timer/worker.py | 9 ++++----- worker_specific_task_queues/starter.py | 9 ++++----- worker_specific_task_queues/worker.py | 9 ++++----- 107 files changed, 439 insertions(+), 541 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 20f578b5..986b0ae9 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -4,7 +4,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker task_queue = "say-hello-task-queue" @@ -19,10 +19,9 @@ async def say_hello_activity(name: str) -> str: async def main(): # Create client to localhost on default namespace - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run activity worker async with Worker(client, task_queue=task_queue, activities=[say_hello_activity]): diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index f3eccfa4..7e3b1fb3 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -6,7 +6,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ( ProcessBatchWorkflow, @@ -20,10 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create unique workflow ID with timestamp timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index 5579c3f4..a72ed96c 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -6,7 +6,7 @@ from temporalio import worker from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ProcessBatchWorkflow from batch_sliding_window.record_loader_activity import RecordLoader @@ -20,10 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Create client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create RecordLoader activity with sample data record_loader = RecordLoader(record_count=90) diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index 08de652b..085b695c 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import BasicBedrockWorkflow @@ -12,10 +12,9 @@ async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 31d783a5..692a4927 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -2,16 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import BasicBedrockWorkflow async def main(prompt: str) -> str: # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Start the workflow workflow_id = "basic-bedrock-workflow" diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 80a093ac..19984202 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -2,16 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index 786c1429..ffcfa31e 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -1,16 +1,15 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 8af05356..ecc76c52 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import EntityBedrockWorkflow @@ -12,10 +12,9 @@ async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 231eff70..be7897f0 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -2,16 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import BedrockParams, EntityBedrockWorkflow async def main(prompt): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) workflow_id = "entity-bedrock-workflow" diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index ce6988b6..2bd6049f 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -1,16 +1,15 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index 89b59608..9d611588 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import SignalQueryBedrockWorkflow @@ -12,10 +12,9 @@ async def main(): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) activities = BedrockActivities() diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index b7f00d00..35a9df1c 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -2,16 +2,15 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow async def main(prompt): # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) workflow_id = "bedrock-workflow-with-signals" inactivity_timeout_minutes = 1 diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index 2d440e54..1f40a3ed 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -10,7 +10,7 @@ ScheduleSpec, WorkflowFailureError, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from cloud_export_to_parquet.workflows import ( ProtoToParquet, @@ -21,10 +21,9 @@ async def main() -> None: """Main function to run temporal workflow.""" # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # TODO: update s3_bucket and namespace to the actual usecase wf_input = ProtoToParquetWorkflowInput( diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index 72a66da4..6062abcd 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -19,10 +19,9 @@ async def main() -> None: """Main worker function.""" # Create client connected to server at the given address - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run the worker worker: Worker = Worker( diff --git a/context_propagation/starter.py b/context_propagation/starter.py index ece77752..4d141dc0 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from context_propagation import interceptor, shared, workflows @@ -13,13 +13,12 @@ async def main(): # Set the user ID shared.user_id.set("some-user") - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/context_propagation/worker.py b/context_propagation/worker.py index ad990376..70ffa368 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows @@ -13,13 +13,12 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 5b33be13..cc500ae4 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_converter.shared import ( GreetingInput, @@ -12,13 +12,12 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Without this we get: # TypeError: Object of type GreetingInput is not JSON serializable data_converter=greeting_data_converter, diff --git a/custom_converter/worker.py b/custom_converter/worker.py index fcd81942..17186aee 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_converter.shared import greeting_data_converter @@ -11,13 +11,12 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Without this, when trying to run a workflow, we get: # KeyError: 'Unknown payload encoding my-greeting-encoding data_converter=greeting_data_converter, diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index fb366aa6..aff675da 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -1,17 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_decorator.worker import WaitForCancelWorkflow async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Start the workflow handle = await client.start_workflow( diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index b551c236..0d25145b 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater @@ -52,10 +52,9 @@ def cancel_activity(self) -> None: async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/custom_metric/starter.py b/custom_metric/starter.py index 7a7dd8fb..aeb6d2b7 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -2,16 +2,15 @@ import uuid from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_metric.workflow import StartTwoActivitiesWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) await client.start_workflow( StartTwoActivitiesWorkflow.run, diff --git a/custom_metric/worker.py b/custom_metric/worker.py index 0135c661..6a3be69a 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -3,7 +3,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import ( ActivityInboundInterceptor, @@ -49,11 +49,10 @@ async def main(): runtime = Runtime( telemetry=TelemetryConfig(metrics=PrometheusConfig(bind_address="0.0.0.0:9090")) ) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) worker = Worker( diff --git a/dsl/starter.py b/dsl/starter.py index 015d332f..eb0f328d 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -6,7 +6,7 @@ import dacite import yaml from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from dsl.workflow import DSLInput, DSLWorkflow @@ -17,10 +17,9 @@ async def main(dsl_yaml: str) -> None: dsl_input = dacite.from_dict(DSLInput, yaml.safe_load(dsl_yaml)) # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/dsl/worker.py b/dsl/worker.py index b454022b..e52ec872 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from dsl.activities import DSLActivities @@ -13,10 +13,9 @@ async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the activities and workflow activities = DSLActivities() diff --git a/encryption/starter.py b/encryption/starter.py index 40f3f1ad..f2570936 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -3,7 +3,7 @@ import temporalio.converter from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow @@ -11,13 +11,11 @@ async def main(): # Load configuration - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/encryption/worker.py b/encryption/worker.py index f128c8c0..d3387c70 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -4,7 +4,7 @@ import temporalio.converter from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from encryption.codec import EncryptionCodec @@ -21,13 +21,11 @@ async def run(self, name: str) -> str: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/gevent_async/starter.py b/gevent_async/starter.py index ef8da622..010803e5 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -7,7 +7,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from gevent_async import workflow from gevent_async.executor import GeventExecutor @@ -25,10 +25,9 @@ def main(): async def async_main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/gevent_async/worker.py b/gevent_async/worker.py index eb6050d3..219908af 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -9,7 +9,7 @@ import gevent from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from gevent_async import activity, workflow @@ -40,10 +40,9 @@ async def async_main(): ) # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create an executor for use by Temporal. This cannot be the outer one # running this async main. The max_workers here needs to have enough room to diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 19529690..69226772 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -44,12 +44,11 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Load configuration - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index 208e1023..6c1e195a 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -43,10 +43,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index 5a1e4536..139d4006 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # Activities that will be called by the workflow @@ -81,11 +81,11 @@ async def run(self, shopping_list: ShoppingList) -> str: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 60828933..a7a8ffe9 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -42,10 +42,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index a441d542..0073ae45 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -3,7 +3,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -33,10 +33,9 @@ async def run(self) -> None: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create our database client that can then be used in the activity db_client = MyDatabaseClient() diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index e2c329b4..5751a210 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -8,7 +8,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import SharedStateManager, Worker @@ -44,10 +44,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index 98f06b2e..c5007dfb 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -46,10 +46,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 97786bae..21a003df 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -69,10 +69,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow composer = GreetingComposer(client) diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index ab30c00d..aaf0aa90 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import CancelledError from temporalio.worker import Worker @@ -51,11 +51,11 @@ async def run(self) -> None: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 226333a1..4b7697f4 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -11,7 +11,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # --- Begin logging set‑up ---------------------------------------------------------- @@ -51,10 +51,9 @@ async def run(self): async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 3f841321..6f99af5b 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -32,11 +32,11 @@ async def run(self, name: str) -> str: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index f63ce829..a4947019 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -23,10 +23,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_cron.py b/hello/hello_cron.py index ec0c9c1e..cf1bc4b1 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -34,10 +34,9 @@ async def run(self, name: str) -> None: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_exception.py b/hello/hello_exception.py index b1bcc556..a2d49633 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -8,7 +8,7 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import FailureError from temporalio.worker import Worker @@ -40,10 +40,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 3d0a51a7..a1dd08ed 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -33,10 +33,9 @@ async def run(self, name: str) -> str: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index bfd19404..680534ab 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -42,10 +42,9 @@ async def run(self) -> List[str]: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_patch.py b/hello/hello_patch.py index 2db20b83..a26e5474 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -6,7 +6,7 @@ from temporalio import activity, exceptions, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -102,10 +102,9 @@ async def main(): # logging.basicConfig(level=logging.INFO) # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Set workflow_class to the proper class based on version workflow_class = "" diff --git a/hello/hello_query.py b/hello/hello_query.py index 3b2888ab..7ed132d1 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -27,11 +27,11 @@ def greeting(self) -> str: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index c4330055..c858692a 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -17,10 +17,9 @@ async def run(self) -> None: async def main(): # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_signal.py b/hello/hello_signal.py index c11e3f68..ed7ce7b3 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -41,11 +41,11 @@ def exit(self) -> None: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_update.py b/hello/hello_update.py index e40ee437..4daa250a 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -23,10 +23,9 @@ async def update_workflow_status(self) -> str: async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index f0bfbcd8..639456fa 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.caller.workflows import CallerWorkflow @@ -17,12 +17,11 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[MyOutput, MyOutput]: if not client: - config_dict = ClientConfigProfile.load().to_dict() + config = ClientConfig.load_client_connect_config() # Override the namespace from config file. - config_dict.setdefault("address", "localhost:7233") - config_dict["namespace"] = NAMESPACE - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config.setdefault("target_host", "localhost:7233") + config.setdefault("namespace", NAMESPACE) + client = await Client.connect(**config) async with Worker( client, diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index f9040989..ded9c5ab 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.handler.service_handler import MyNexusServiceHandler @@ -19,12 +19,11 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config_dict = ClientConfigProfile.load().to_dict() + config = ClientConfig.load_client_connect_config() # Override the address and namespace from the config file. - config_dict.setdefault("address", "localhost:7233") - config_dict["namespace"] = NAMESPACE - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config.setdefault("target_host", "localhost:7233") + config.setdefault("namespace", NAMESPACE) + client = await Client.connect(**config) # Start the worker, passing the Nexus service handler instance, in addition to the # workflow classes that are started by your nexus operations, and any activities diff --git a/langchain/starter.py b/langchain/starter.py index d7139979..6d9e00c2 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -7,18 +7,17 @@ from fastapi import FastAPI, HTTPException from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflow import LangChainWorkflow, TranslateWorkflowParams @asynccontextmanager async def lifespan(app: FastAPI): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, interceptors=[LangChainContextPropagationInterceptor()], ) yield diff --git a/langchain/worker.py b/langchain/worker.py index 088cbf7b..b7fb7741 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -3,7 +3,7 @@ from activities import translate_phrase from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow @@ -11,10 +11,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index 3f1135c0..aa5b8967 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -2,7 +2,7 @@ from typing import Optional from temporalio.client import Client, WorkflowUpdateStage -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.introduction import TASK_QUEUE from message_passing.introduction.workflows import ( @@ -16,10 +16,9 @@ async def main(client: Optional[Client] = None): if not client: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) wf_handle = await client.start_workflow( GreetingWorkflow.run, diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 380dc45d..34974801 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.introduction import TASK_QUEUE @@ -15,10 +15,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 9ebd95c6..9bc5c661 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -6,7 +6,7 @@ from temporalio import common from temporalio.client import Client, WorkflowHandle -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.safe_message_handlers.workflow import ( ClusterManagerAssignNodesToJobInput, @@ -55,10 +55,9 @@ async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] async def main(should_test_continue_as_new: bool): # Connect to Temporal - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) print("Starting cluster") cluster_manager_handle = await client.start_workflow( diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index a7bb2d69..31e538d4 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.safe_message_handlers.workflow import ( @@ -17,10 +17,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index cb2c5be2..ec874939 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -9,7 +9,7 @@ WorkflowHandle, WorkflowUpdateFailedError, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import ApplicationError from message_passing.update_with_start.lazy_initialization import TASK_QUEUE @@ -63,10 +63,9 @@ async def main(): print("🛒") session_id = f"session-{uuid.uuid4()}" - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) subtotal_1, _ = await handle_add_item_request(session_id, "sku-123", 1, client) subtotal_2, wf_handle = await handle_add_item_request( diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index f4612166..1cc4f6ff 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows @@ -14,10 +14,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 0d799226..76829e0b 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers import ( TASK_QUEUE, @@ -13,10 +13,9 @@ async def starter(exit_type: WorkflowExitType): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - cl = await client.Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersWorkflow.run, diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 6bf239ad..e32a2dcb 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers import TASK_QUEUE @@ -17,10 +17,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index e4ecde1f..fbc5ae04 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers_and_compensation import ( TASK_QUEUE, @@ -15,10 +15,9 @@ async def starter(exit_type: WorkflowExitType): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - cl = await client.Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + cl = await client.Client.connect(**config) wf_handle = await cl.start_workflow( WaitingForHandlersAndCompensationWorkflow.run, diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 9d90c114..2a27769d 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers_and_compensation import TASK_QUEUE @@ -20,10 +20,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 3218b0e3..9e8650b0 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -2,7 +2,7 @@ from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry @@ -10,13 +10,11 @@ async def main(): runtime = init_runtime_with_telemetry() - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index dca39cf0..631bd008 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -9,7 +9,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -51,13 +51,12 @@ def init_runtime_with_telemetry() -> Runtime: async def main(): runtime = init_runtime_with_telemetry() - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index c158b352..2cd16c60 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, @@ -9,10 +9,9 @@ async def main() -> None: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) user_input = input("Enter a max number: ") max_number = int(user_input) diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index 265b0b68..f2175f7f 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -2,18 +2,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 21c7695f..c2b2ba3d 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -3,7 +3,7 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, @@ -11,13 +11,12 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Create client connected to server at the given address client = await Client.connect( - **config.to_client_connect_config(), + **config, plugins=[ OpenAIAgentsPlugin(), ], diff --git a/patching/starter.py b/patching/starter.py index 7ddcd1f6..f1b92f32 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -2,7 +2,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig # Since it's just used for typing purposes, it doesn't matter which one we # import @@ -18,10 +18,9 @@ async def main(): raise RuntimeError("Either --start-workflow or --query-workflow is required") # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) if args.start_workflow: handle = await client.start_workflow( diff --git a/patching/worker.py b/patching/worker.py index 6dcf2e7c..417c8ef9 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -2,7 +2,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity @@ -31,10 +31,9 @@ async def main(): raise RuntimeError("Unrecognized workflow") # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index fddc83e6..42048092 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -1,16 +1,15 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.frequent.workflows import GreetingWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index 55fb5310..cf5ccb78 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.frequent.activities import compose_greeting @@ -9,10 +9,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index af7b5548..8a0ea871 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -1,16 +1,15 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.infrequent.workflows import GreetingWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index eec9ede0..f52a8082 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.infrequent.activities import compose_greeting @@ -9,10 +9,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index 1e4acb37..393fb8be 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -1,16 +1,15 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.periodic_sequence.workflows import GreetingWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 999a9d23..9689ef2f 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.periodic_sequence.activities import compose_greeting @@ -9,10 +9,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/prometheus/starter.py b/prometheus/starter.py index 7e0a4d78..571aee07 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus @@ -11,13 +11,12 @@ async def main(): runtime = init_runtime_with_prometheus(9001) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) diff --git a/prometheus/worker.py b/prometheus/worker.py index a749b644..b41b75c5 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -3,7 +3,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -39,13 +39,12 @@ def init_runtime_with_prometheus(port: int) -> Runtime: async def main(): runtime = init_runtime_with_prometheus(9000) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index ecbba38e..47766be6 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -5,7 +5,7 @@ from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from pydantic_converter.worker import MyPydanticModel, MyWorkflow @@ -13,14 +13,13 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index 7cd1d963..8acc1125 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # Always pass through external modules to the sandbox that you know are safe for @@ -43,14 +43,12 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client using the Pydantic converter - client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index bde38238..33b0ad28 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -4,7 +4,7 @@ from ipaddress import IPv4Address from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow @@ -13,14 +13,13 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index ab649d4f..5ff65e1e 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -71,14 +71,13 @@ def new_sandbox_runner() -> SandboxedWorkflowRunner: async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/replay/replayer.py b/replay/replayer.py index 8b205c5b..4787b33b 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity @@ -9,10 +9,9 @@ async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Fetch the histories of the workflows to be replayed workflows = client.list_workflows('WorkflowId="replayer-workflow-id"') diff --git a/replay/starter.py b/replay/starter.py index 0a492360..228e50c3 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -1,17 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from replay.worker import JustActivity, JustTimer, TimerThenActivity async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a few workflows # Importantly, normally we would *not* advise re-using the same workflow ID for all of these, diff --git a/replay/worker.py b/replay/worker.py index 51acd3dd..4ac57da2 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -72,10 +72,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/resource_pool/starter.py b/resource_pool/starter.py index 47aca46c..2a50357a 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -3,7 +3,7 @@ from temporalio.client import Client, WorkflowFailureError, WorkflowHandle from temporalio.common import WorkflowIDConflictPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from resource_pool.pool_client.resource_pool_workflow import ( ResourcePoolWorkflow, @@ -18,10 +18,9 @@ async def main() -> None: # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Initialize the resource pool resource_pool_handle = await client.start_workflow( diff --git a/resource_pool/worker.py b/resource_pool/worker.py index 1e4ef5ca..253e5f8e 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow @@ -13,10 +13,9 @@ async def main() -> None: logging.basicConfig(level=logging.INFO) # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker for the workflow worker = Worker( diff --git a/schedules/backfill_schedule.py b/schedules/backfill_schedule.py index 4fb6db6a..708ad07f 100644 --- a/schedules/backfill_schedule.py +++ b/schedules/backfill_schedule.py @@ -2,14 +2,13 @@ from datetime import datetime, timedelta from temporalio.client import Client, ScheduleBackfill, ScheduleOverlapPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/delete_schedule.py b/schedules/delete_schedule.py index 268db7df..d7b64394 100644 --- a/schedules/delete_schedule.py +++ b/schedules/delete_schedule.py @@ -1,14 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/describe_schedule.py b/schedules/describe_schedule.py index c4a910cd..0db3fba5 100644 --- a/schedules/describe_schedule.py +++ b/schedules/describe_schedule.py @@ -1,14 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/list_schedule.py b/schedules/list_schedule.py index 57791115..15c0fd6a 100644 --- a/schedules/list_schedule.py +++ b/schedules/list_schedule.py @@ -1,14 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main() -> None: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async for schedule in await client.list_schedules(): print(f"List Schedule Info: {schedule.info}.") diff --git a/schedules/pause_schedule.py b/schedules/pause_schedule.py index b1c21970..79a9ca03 100644 --- a/schedules/pause_schedule.py +++ b/schedules/pause_schedule.py @@ -1,14 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/run_worker.py b/schedules/run_worker.py index a8c02608..00d14aaa 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -1,17 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from your_activities import your_activity from your_workflows import YourSchedulesWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 65c60f08..ead6202b 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -9,15 +9,14 @@ ScheduleSpec, ScheduleState, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from your_workflows import YourSchedulesWorkflow async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) await client.create_schedule( "workflow-schedule-id", diff --git a/schedules/trigger_schedule.py b/schedules/trigger_schedule.py index 6a283e87..30939d32 100644 --- a/schedules/trigger_schedule.py +++ b/schedules/trigger_schedule.py @@ -1,14 +1,13 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/schedules/update_schedule.py b/schedules/update_schedule.py index 408d0194..709eeda3 100644 --- a/schedules/update_schedule.py +++ b/schedules/update_schedule.py @@ -6,14 +6,13 @@ ScheduleUpdate, ScheduleUpdateInput, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_schedule_handle( "workflow-schedule-id", diff --git a/sentry/starter.py b/sentry/starter.py index f3fee2d1..aa3f6271 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,17 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Connect client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run workflow try: diff --git a/sentry/worker.py b/sentry/worker.py index a1a5e474..1bcd153e 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -5,7 +5,7 @@ from sentry_sdk.integrations.asyncio import AsyncioIntegration from sentry_sdk.types import Event, Hint from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -18,6 +18,7 @@ interrupt_event = asyncio.Event() + def before_send(event: Event, hint: Hint) -> Event | None: # Filter out __ShutdownRequested events raised by the worker's internals if str(hint.get("exc_info", [None])[0].__name__) == "_ShutdownRequested": @@ -51,11 +52,11 @@ async def main(): # Initialize the Sentry SDK initialise_sentry() - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index e567244f..98dc083d 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow @@ -11,10 +11,10 @@ async def main(client: Optional[Client] = None): if not client: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) + wf_handle = await client.start_workflow( SleepForDaysWorkflow.run, id=f"sleep-for-days-workflow-id-{uuid.uuid4()}", diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 2ccb32b5..59799607 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from sleep_for_days import TASK_QUEUE @@ -11,10 +11,9 @@ async def main(): - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) worker = Worker( client, diff --git a/trio_async/starter.py b/trio_async/starter.py index 85d87b00..6535ca98 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -2,7 +2,7 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from trio_async import workflows @@ -12,10 +12,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Execute the workflow result = await client.execute_workflow( diff --git a/trio_async/worker.py b/trio_async/worker.py index 17134558..f1c2a30b 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -5,7 +5,7 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from trio_async import activities, workflows @@ -16,10 +16,9 @@ async def main(): logging.basicConfig(level=logging.INFO) # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Temporal runs threaded activities and workflow tasks via run_in_executor. # Due to how trio_asyncio works, you can only do run_in_executor with their diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index d9f11c12..8ce0f4f9 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -5,7 +5,7 @@ from temporalio import exceptions from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow @@ -15,10 +15,9 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) try: handle = await client.start_workflow( Workflow.run, diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 0378d2e4..43d24838 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -4,7 +4,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from updatable_timer.workflow import Workflow @@ -13,10 +13,9 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) if not client: - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) handle = client.get_workflow_handle(workflow_id="updatable-timer-workflow") # signal workflow about the wake up time change diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 67472425..8bb3d47a 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from updatable_timer import TASK_QUEUE @@ -14,10 +14,9 @@ async def main(): logging.basicConfig(level=logging.INFO) - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) async with Worker( client, diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index 58f6ee81..61009436 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -2,17 +2,16 @@ from uuid import uuid4 from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from worker_specific_task_queues.tasks import FileProcessing async def main(): # Connect client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Start 10 concurrent workflows futures = [] diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index 30f6416a..95824cfd 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -6,7 +6,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from worker_specific_task_queues import tasks @@ -32,10 +32,9 @@ async def select_task_queue() -> str: return task_queue # Start client - config_dict = ClientConfigProfile.load().to_dict() - config_dict.setdefault("address", "localhost:7233") - config = ClientConfigProfile.from_dict(config_dict) - client = await Client.connect(**config.to_client_connect_config()) + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Run a worker to distribute the workflows run_futures = [] From f995017477c210a45419e808b88bb6187d02d381 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Thu, 11 Sep 2025 10:38:41 -0700 Subject: [PATCH 06/14] Update temporalio dependency (includes optional profile commit) --- uv.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv.lock b/uv.lock index 73424b77..8ceea584 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.10" resolution-markers = [ "python_full_version >= '3.13'", From d372138f4eb620baa9a9f05ec967784212c75694 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Fri, 26 Sep 2025 03:10:29 -0400 Subject: [PATCH 07/14] remove unused toml & util --- temporal.toml | 4 ---- util.py | 16 ---------------- 2 files changed, 20 deletions(-) delete mode 100644 temporal.toml delete mode 100644 util.py diff --git a/temporal.toml b/temporal.toml deleted file mode 100644 index df78a1ab..00000000 --- a/temporal.toml +++ /dev/null @@ -1,4 +0,0 @@ -# Default profile for local development -[profile.default] -address = "localhost:7233" -namespace = "default" \ No newline at end of file diff --git a/util.py b/util.py deleted file mode 100644 index b15a68d0..00000000 --- a/util.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Utility module -""" -from pathlib import Path - - -def get_temporal_config_path() -> Path: - """ - Get the path to the temporal.toml configuration file. - - This assumes the temporal.toml file is in the root of the samples-python repository. - - Returns: - Path to temporal.toml - """ - return Path(__file__).resolve().parent / "temporal.toml" From 161eb17f949e08cf17dbb4008bafd132be925658 Mon Sep 17 00:00:00 2001 From: tconley1428 Date: Tue, 23 Sep 2025 16:30:30 -0700 Subject: [PATCH 08/14] Update SDK version to 1.18 (#247) * Update SDK version to 1.18 * Update openai breaking change --- uv.lock | 272 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 136 insertions(+), 136 deletions(-) diff --git a/uv.lock b/uv.lock index 8ceea584..7ec7d623 100644 --- a/uv.lock +++ b/uv.lock @@ -12,7 +12,7 @@ resolution-markers = [ [[package]] name = "aiohappyeyeballs" version = "2.6.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/26/30/f84a107a9c4331c14b2b586036f40965c128aa4fee4dda5d3d51cb14ad54/aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558", size = 22760, upload-time = "2025-03-12T01:42:48.764Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/0f/15/5bf3b99495fb160b63f95972b81750f18f7f4e02ad051373b669d17d44f2/aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8", size = 15265, upload-time = "2025-03-12T01:42:47.083Z" }, @@ -21,7 +21,7 @@ wheels = [ [[package]] name = "aiohttp" version = "3.12.14" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "aiohappyeyeballs" }, { name = "aiosignal" }, @@ -107,7 +107,7 @@ wheels = [ [[package]] name = "aiosignal" version = "1.4.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "frozenlist" }, { name = "typing-extensions", marker = "python_full_version < '3.13'" }, @@ -120,7 +120,7 @@ wheels = [ [[package]] name = "annotated-types" version = "0.7.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, @@ -129,7 +129,7 @@ wheels = [ [[package]] name = "anyio" version = "4.9.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "idna" }, @@ -144,7 +144,7 @@ wheels = [ [[package]] name = "async-timeout" version = "4.0.3" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/87/d6/21b30a550dafea84b1b8eee21b5e23fa16d010ae006011221f33dcd8d7f8/async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f", size = 8345, upload-time = "2023-08-10T16:35:56.907Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/a7/fa/e01228c2938de91d47b307831c62ab9e4001e747789d0b05baf779a6488c/async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028", size = 5721, upload-time = "2023-08-10T16:35:55.203Z" }, @@ -153,7 +153,7 @@ wheels = [ [[package]] name = "attrs" version = "25.3.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/5a/b0/1367933a8532ee6ff8d63537de4f1177af4bff9f3e829baf7331f595bb24/attrs-25.3.0.tar.gz", hash = "sha256:75d7cefc7fb576747b2c81b4442d4d4a1ce0900973527c011d1030fd3bf4af1b", size = 812032, upload-time = "2025-03-13T11:10:22.779Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/77/06/bb80f5f86020c4551da315d78b3ab75e8228f89f0162f2c3a819e407941a/attrs-25.3.0-py3-none-any.whl", hash = "sha256:427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3", size = 63815, upload-time = "2025-03-13T11:10:21.14Z" }, @@ -162,7 +162,7 @@ wheels = [ [[package]] name = "black" version = "22.12.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "click" }, { name = "mypy-extensions" }, @@ -182,7 +182,7 @@ wheels = [ [[package]] name = "boto3" version = "1.39.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "botocore" }, { name = "jmespath" }, @@ -196,7 +196,7 @@ wheels = [ [[package]] name = "botocore" version = "1.39.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "jmespath" }, { name = "python-dateutil" }, @@ -210,7 +210,7 @@ wheels = [ [[package]] name = "certifi" version = "2025.7.9" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/de/8a/c729b6b60c66a38f590c4e774decc4b2ec7b0576be8f1aa984a53ffa812a/certifi-2025.7.9.tar.gz", hash = "sha256:c1d2ec05395148ee10cf672ffc28cd37ea0ab0d99f9cc74c43e588cbd111b079", size = 160386, upload-time = "2025-07-09T02:13:58.874Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/66/f3/80a3f974c8b535d394ff960a11ac20368e06b736da395b551a49ce950cce/certifi-2025.7.9-py3-none-any.whl", hash = "sha256:d842783a14f8fdd646895ac26f719a061408834473cfc10203f6a575beb15d39", size = 159230, upload-time = "2025-07-09T02:13:57.007Z" }, @@ -219,7 +219,7 @@ wheels = [ [[package]] name = "cffi" version = "1.17.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pycparser" }, ] @@ -276,7 +276,7 @@ wheels = [ [[package]] name = "charset-normalizer" version = "3.4.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/e4/33/89c2ced2b67d1c2a61c19c6751aa8902d46ce3dacb23600a283619f5a12d/charset_normalizer-3.4.2.tar.gz", hash = "sha256:5baececa9ecba31eff645232d59845c07aa030f0c81ee70184a90d35099a0e63", size = 126367, upload-time = "2025-05-02T08:34:42.01Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/95/28/9901804da60055b406e1a1c5ba7aac1276fb77f1dde635aabfc7fd84b8ab/charset_normalizer-3.4.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7c48ed483eb946e6c04ccbe02c6b4d1d48e51944b6db70f697e089c193404941", size = 201818, upload-time = "2025-05-02T08:31:46.725Z" }, @@ -337,7 +337,7 @@ wheels = [ [[package]] name = "click" version = "8.2.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] @@ -349,7 +349,7 @@ wheels = [ [[package]] name = "colorama" version = "0.4.6" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, @@ -358,7 +358,7 @@ wheels = [ [[package]] name = "cryptography" version = "38.0.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "cffi" }, ] @@ -381,7 +381,7 @@ wheels = [ [[package]] name = "dacite" version = "1.9.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/55/a0/7ca79796e799a3e782045d29bf052b5cde7439a2bbb17f15ff44f7aacc63/dacite-1.9.2.tar.gz", hash = "sha256:6ccc3b299727c7aa17582f0021f6ae14d5de47c7227932c47fec4cdfefd26f09", size = 22420, upload-time = "2025-02-05T09:27:29.757Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/94/35/386550fd60316d1e37eccdda609b074113298f23cef5bddb2049823fe666/dacite-1.9.2-py3-none-any.whl", hash = "sha256:053f7c3f5128ca2e9aceb66892b1a3c8936d02c686e707bee96e19deef4bc4a0", size = 16600, upload-time = "2025-02-05T09:27:24.345Z" }, @@ -390,7 +390,7 @@ wheels = [ [[package]] name = "dataclasses-json" version = "0.6.7" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "marshmallow" }, { name = "typing-inspect" }, @@ -403,7 +403,7 @@ wheels = [ [[package]] name = "distro" version = "1.9.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, @@ -412,7 +412,7 @@ wheels = [ [[package]] name = "exceptiongroup" version = "1.3.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] @@ -424,7 +424,7 @@ wheels = [ [[package]] name = "fastapi" version = "0.116.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pydantic" }, { name = "starlette" }, @@ -438,7 +438,7 @@ wheels = [ [[package]] name = "filelock" version = "3.18.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/0a/10/c23352565a6544bdc5353e0b15fc1c563352101f30e24bf500207a54df9a/filelock-3.18.0.tar.gz", hash = "sha256:adbc88eabb99d2fec8c9c1b229b171f18afa655400173ddc653d5d01501fb9f2", size = 18075, upload-time = "2025-03-14T07:11:40.47Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/4d/36/2a115987e2d8c300a974597416d9de88f2444426de9571f4b59b2cca3acc/filelock-3.18.0-py3-none-any.whl", hash = "sha256:c401f4f8377c4464e6db25fff06205fd89bdd83b65eb0488ed1b160f780e21de", size = 16215, upload-time = "2025-03-14T07:11:39.145Z" }, @@ -447,7 +447,7 @@ wheels = [ [[package]] name = "frozenlist" version = "1.7.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/79/b1/b64018016eeb087db503b038296fd782586432b9c077fc5c7839e9cb6ef6/frozenlist-1.7.0.tar.gz", hash = "sha256:2e310d81923c2437ea8670467121cc3e9b0f76d3043cc1d2331d56c7fb7a3a8f", size = 45078, upload-time = "2025-06-09T23:02:35.538Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/af/36/0da0a49409f6b47cc2d060dc8c9040b897b5902a8a4e37d9bc1deb11f680/frozenlist-1.7.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cc4df77d638aa2ed703b878dd093725b72a824c3c546c076e8fdf276f78ee84a", size = 81304, upload-time = "2025-06-09T22:59:46.226Z" }, @@ -541,7 +541,7 @@ wheels = [ [[package]] name = "fsspec" version = "2025.7.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/8b/02/0835e6ab9cfc03916fe3f78c0956cfcdb6ff2669ffa6651065d5ebf7fc98/fsspec-2025.7.0.tar.gz", hash = "sha256:786120687ffa54b8283d942929540d8bc5ccfa820deb555a2b5d0ed2b737bf58", size = 304432, upload-time = "2025-07-15T16:05:21.19Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/2f/e0/014d5d9d7a4564cf1c40b5039bc882db69fd881111e03ab3657ac0b218e2/fsspec-2025.7.0-py3-none-any.whl", hash = "sha256:8b012e39f63c7d5f10474de957f3ab793b47b45ae7d39f2fb735f8bbe25c0e21", size = 199597, upload-time = "2025-07-15T16:05:19.529Z" }, @@ -550,7 +550,7 @@ wheels = [ [[package]] name = "gevent" version = "25.4.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "cffi", marker = "platform_python_implementation == 'CPython' and sys_platform == 'win32'" }, { name = "greenlet", marker = "platform_python_implementation == 'CPython'" }, @@ -598,7 +598,7 @@ wheels = [ [[package]] name = "googleapis-common-protos" version = "1.70.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "protobuf" }, ] @@ -610,7 +610,7 @@ wheels = [ [[package]] name = "greenlet" version = "3.2.3" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/c9/92/bb85bd6e80148a4d2e0c59f7c0c2891029f8fd510183afc7d8d2feeed9b6/greenlet-3.2.3.tar.gz", hash = "sha256:8b0dd8ae4c0d6f5e54ee55ba935eeb3d735a9b58a8a1e5b5cbab64e01a39f365", size = 185752, upload-time = "2025-06-05T16:16:09.955Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/92/db/b4c12cff13ebac2786f4f217f06588bccd8b53d260453404ef22b121fc3a/greenlet-3.2.3-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:1afd685acd5597349ee6d7a88a8bec83ce13c106ac78c196ee9dde7c04fe87be", size = 268977, upload-time = "2025-06-05T16:10:24.001Z" }, @@ -661,7 +661,7 @@ wheels = [ [[package]] name = "griffe" version = "1.7.3" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "colorama" }, ] @@ -673,7 +673,7 @@ wheels = [ [[package]] name = "grpcio" version = "1.73.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/79/e8/b43b851537da2e2f03fa8be1aef207e5cbfb1a2e014fbb6b40d24c177cd3/grpcio-1.73.1.tar.gz", hash = "sha256:7fce2cd1c0c1116cf3850564ebfc3264fba75d3c74a7414373f1238ea365ef87", size = 12730355, upload-time = "2025-06-26T01:53:24.622Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/8f/51/a5748ab2773d893d099b92653039672f7e26dd35741020972b84d604066f/grpcio-1.73.1-cp310-cp310-linux_armv7l.whl", hash = "sha256:2d70f4ddd0a823436c2624640570ed6097e40935c9194482475fe8e3d9754d55", size = 5365087, upload-time = "2025-06-26T01:51:44.541Z" }, @@ -721,7 +721,7 @@ wheels = [ [[package]] name = "h11" version = "0.16.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, @@ -730,7 +730,7 @@ wheels = [ [[package]] name = "hf-xet" version = "1.1.5" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/ed/d4/7685999e85945ed0d7f0762b686ae7015035390de1161dcea9d5276c134c/hf_xet-1.1.5.tar.gz", hash = "sha256:69ebbcfd9ec44fdc2af73441619eeb06b94ee34511bbcf57cd423820090f5694", size = 495969, upload-time = "2025-06-20T21:48:38.007Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/00/89/a1119eebe2836cb25758e7661d6410d3eae982e2b5e974bcc4d250be9012/hf_xet-1.1.5-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:f52c2fa3635b8c37c7764d8796dfa72706cc4eded19d638331161e82b0792e23", size = 2687929, upload-time = "2025-06-20T21:48:32.284Z" }, @@ -745,7 +745,7 @@ wheels = [ [[package]] name = "httpcore" version = "1.0.9" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "certifi" }, { name = "h11" }, @@ -758,7 +758,7 @@ wheels = [ [[package]] name = "httptools" version = "0.6.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a7/9a/ce5e1f7e131522e6d3426e8e7a490b3a01f39a6696602e1c4f33f9e94277/httptools-0.6.4.tar.gz", hash = "sha256:4e93eee4add6493b59a5c514da98c939b244fce4a0d8879cd3f466562f4b7d5c", size = 240639, upload-time = "2024-10-16T19:45:08.902Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/3b/6f/972f8eb0ea7d98a1c6be436e2142d51ad2a64ee18e02b0e7ff1f62171ab1/httptools-0.6.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3c73ce323711a6ffb0d247dcd5a550b8babf0f757e86a52558fe5b86d6fefcc0", size = 198780, upload-time = "2024-10-16T19:44:06.882Z" }, @@ -794,7 +794,7 @@ wheels = [ [[package]] name = "httpx" version = "0.28.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "anyio" }, { name = "certifi" }, @@ -809,7 +809,7 @@ wheels = [ [[package]] name = "httpx-sse" version = "0.4.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/6e/fa/66bd985dd0b7c109a3bcb89272ee0bfb7e2b4d06309ad7b38ff866734b2a/httpx_sse-0.4.1.tar.gz", hash = "sha256:8f44d34414bc7b21bf3602713005c5df4917884f76072479b21f68befa4ea26e", size = 12998, upload-time = "2025-06-24T13:21:05.71Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/25/0a/6269e3473b09aed2dab8aa1a600c70f31f00ae1349bee30658f7e358a159/httpx_sse-0.4.1-py3-none-any.whl", hash = "sha256:cba42174344c3a5b06f255ce65b350880f962d99ead85e776f23c6618a377a37", size = 8054, upload-time = "2025-06-24T13:21:04.772Z" }, @@ -818,7 +818,7 @@ wheels = [ [[package]] name = "huggingface-hub" version = "0.34.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "filelock" }, { name = "fsspec" }, @@ -837,7 +837,7 @@ wheels = [ [[package]] name = "idna" version = "3.10" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f1/70/7703c29685631f5a7590aa73f1f1d3fa9a380e654b86af429e0934a32f7d/idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9", size = 190490, upload-time = "2024-09-15T18:07:39.745Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442, upload-time = "2024-09-15T18:07:37.964Z" }, @@ -846,7 +846,7 @@ wheels = [ [[package]] name = "importlib-metadata" version = "8.7.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "zipp" }, ] @@ -858,7 +858,7 @@ wheels = [ [[package]] name = "iniconfig" version = "2.1.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793, upload-time = "2025-03-19T20:09:59.721Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" }, @@ -867,7 +867,7 @@ wheels = [ [[package]] name = "isort" version = "5.13.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/87/f9/c1eb8635a24e87ade2efce21e3ce8cd6b8630bb685ddc9cdaca1349b2eb5/isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109", size = 175303, upload-time = "2023-12-13T20:37:26.124Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d1/b3/8def84f539e7d2289a02f0524b944b15d7c75dab7628bedf1c4f0992029c/isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6", size = 92310, upload-time = "2023-12-13T20:37:23.244Z" }, @@ -876,7 +876,7 @@ wheels = [ [[package]] name = "jinja2" version = "3.1.6" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "markupsafe" }, ] @@ -888,7 +888,7 @@ wheels = [ [[package]] name = "jiter" version = "0.10.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/ee/9d/ae7ddb4b8ab3fb1b51faf4deb36cb48a4fbbd7cb36bad6a5fca4741306f7/jiter-0.10.0.tar.gz", hash = "sha256:07a7142c38aacc85194391108dc91b5b57093c978a9932bd86a36862759d9500", size = 162759, upload-time = "2025-05-18T19:04:59.73Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/be/7e/4011b5c77bec97cb2b572f566220364e3e21b51c48c5bd9c4a9c26b41b67/jiter-0.10.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:cd2fb72b02478f06a900a5782de2ef47e0396b3e1f7d5aba30daeb1fce66f303", size = 317215, upload-time = "2025-05-18T19:03:04.303Z" }, @@ -960,7 +960,7 @@ wheels = [ [[package]] name = "jmespath" version = "1.0.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/00/2a/e867e8531cf3e36b41201936b7fa7ba7b5702dbef42922193f05c8976cd6/jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe", size = 25843, upload-time = "2022-06-17T18:00:12.224Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/31/b4/b9b800c45527aadd64d5b442f9b932b00648617eb5d63d2c7a6587b7cafc/jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980", size = 20256, upload-time = "2022-06-17T18:00:10.251Z" }, @@ -969,7 +969,7 @@ wheels = [ [[package]] name = "jsonpatch" version = "1.33" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "jsonpointer" }, ] @@ -981,7 +981,7 @@ wheels = [ [[package]] name = "jsonpointer" version = "3.0.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/6a/0a/eebeb1fa92507ea94016a2a790b93c2ae41a7e18778f85471dc54475ed25/jsonpointer-3.0.0.tar.gz", hash = "sha256:2b2d729f2091522d61c3b31f82e11870f60b68f43fbc705cb76bf4b832af59ef", size = 9114, upload-time = "2024-06-10T19:24:42.462Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/71/92/5e77f98553e9e75130c78900d000368476aed74276eb8ae8796f65f00918/jsonpointer-3.0.0-py2.py3-none-any.whl", hash = "sha256:13e088adc14fca8b6aa8177c044e12701e6ad4b28ff10e65f2267a90109c9942", size = 7595, upload-time = "2024-06-10T19:24:40.698Z" }, @@ -990,7 +990,7 @@ wheels = [ [[package]] name = "jsonschema" version = "4.24.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "attrs" }, { name = "jsonschema-specifications" }, @@ -1005,7 +1005,7 @@ wheels = [ [[package]] name = "jsonschema-specifications" version = "2025.4.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "referencing" }, ] @@ -1017,7 +1017,7 @@ wheels = [ [[package]] name = "langchain" version = "0.1.20" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "aiohttp" }, { name = "async-timeout", marker = "python_full_version < '3.11'" }, @@ -1041,7 +1041,7 @@ wheels = [ [[package]] name = "langchain-community" version = "0.0.38" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "aiohttp" }, { name = "dataclasses-json" }, @@ -1061,7 +1061,7 @@ wheels = [ [[package]] name = "langchain-core" version = "0.1.53" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "jsonpatch" }, { name = "langsmith" }, @@ -1078,7 +1078,7 @@ wheels = [ [[package]] name = "langchain-openai" version = "0.0.6" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "langchain-core" }, { name = "numpy" }, @@ -1093,7 +1093,7 @@ wheels = [ [[package]] name = "langchain-text-splitters" version = "0.0.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "langchain-core" }, ] @@ -1105,7 +1105,7 @@ wheels = [ [[package]] name = "langsmith" version = "0.1.147" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "httpx" }, { name = "orjson", marker = "platform_python_implementation != 'PyPy'" }, @@ -1121,7 +1121,7 @@ wheels = [ [[package]] name = "litellm" version = "1.74.8" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "aiohttp" }, { name = "click" }, @@ -1143,7 +1143,7 @@ wheels = [ [[package]] name = "markdown-it-py" version = "3.0.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "mdurl" }, ] @@ -1155,7 +1155,7 @@ wheels = [ [[package]] name = "markupsafe" version = "3.0.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/b2/97/5d42485e71dfc078108a86d6de8fa46db44a1a9295e89c5d6d4a06e23a62/markupsafe-3.0.2.tar.gz", hash = "sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0", size = 20537, upload-time = "2024-10-18T15:21:54.129Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/04/90/d08277ce111dd22f77149fd1a5d4653eeb3b3eaacbdfcbae5afb2600eebd/MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8", size = 14357, upload-time = "2024-10-18T15:20:51.44Z" }, @@ -1213,7 +1213,7 @@ wheels = [ [[package]] name = "marshmallow" version = "3.26.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "packaging" }, ] @@ -1225,7 +1225,7 @@ wheels = [ [[package]] name = "mcp" version = "1.11.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "anyio" }, { name = "httpx" }, @@ -1247,7 +1247,7 @@ wheels = [ [[package]] name = "mdurl" version = "0.1.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, @@ -1256,7 +1256,7 @@ wheels = [ [[package]] name = "multidict" version = "6.6.3" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] @@ -1358,7 +1358,7 @@ wheels = [ [[package]] name = "mypy" version = "1.16.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "mypy-extensions" }, { name = "pathspec" }, @@ -1397,7 +1397,7 @@ wheels = [ [[package]] name = "mypy-extensions" version = "1.1.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, @@ -1406,7 +1406,7 @@ wheels = [ [[package]] name = "nexus-rpc" version = "1.1.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "typing-extensions" }, ] @@ -1418,7 +1418,7 @@ wheels = [ [[package]] name = "nodeenv" version = "1.9.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, @@ -1427,7 +1427,7 @@ wheels = [ [[package]] name = "numpy" version = "1.26.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/65/6e/09db70a523a96d25e115e71cc56a6f9031e7b8cd166c1ac8438307c14058/numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010", size = 15786129, upload-time = "2024-02-06T00:26:44.495Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/a7/94/ace0fdea5241a27d13543ee117cbc65868e82213fb31a8eb7fe9ff23f313/numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0", size = 20631468, upload-time = "2024-02-05T23:48:01.194Z" }, @@ -1501,7 +1501,7 @@ litellm = [ [[package]] name = "opentelemetry-api" version = "1.35.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "importlib-metadata" }, { name = "typing-extensions" }, @@ -1514,7 +1514,7 @@ wheels = [ [[package]] name = "opentelemetry-exporter-otlp-proto-common" version = "1.35.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "opentelemetry-proto" }, ] @@ -1526,7 +1526,7 @@ wheels = [ [[package]] name = "opentelemetry-exporter-otlp-proto-grpc" version = "1.35.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "googleapis-common-protos" }, { name = "grpcio" }, @@ -1544,7 +1544,7 @@ wheels = [ [[package]] name = "opentelemetry-proto" version = "1.35.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "protobuf" }, ] @@ -1556,7 +1556,7 @@ wheels = [ [[package]] name = "opentelemetry-sdk" version = "1.35.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "opentelemetry-api" }, { name = "opentelemetry-semantic-conventions" }, @@ -1570,7 +1570,7 @@ wheels = [ [[package]] name = "opentelemetry-semantic-conventions" version = "0.56b0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "opentelemetry-api" }, { name = "typing-extensions" }, @@ -1583,7 +1583,7 @@ wheels = [ [[package]] name = "orjson" version = "3.10.18" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/81/0b/fea456a3ffe74e70ba30e01ec183a9b26bec4d497f61dcfce1b601059c60/orjson-3.10.18.tar.gz", hash = "sha256:e8da3947d92123eda795b68228cafe2724815621fe35e8e320a9e9593a4bcd53", size = 5422810, upload-time = "2025-04-29T23:30:08.423Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/27/16/2ceb9fb7bc2b11b1e4a3ea27794256e93dee2309ebe297fd131a778cd150/orjson-3.10.18-cp310-cp310-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:a45e5d68066b408e4bc383b6e4ef05e717c65219a9e1390abc6155a520cac402", size = 248927, upload-time = "2025-04-29T23:28:08.643Z" }, @@ -1649,7 +1649,7 @@ wheels = [ [[package]] name = "outcome" version = "1.3.0.post0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "attrs" }, ] @@ -1661,7 +1661,7 @@ wheels = [ [[package]] name = "packaging" version = "23.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/fb/2b/9b9c33ffed44ee921d0967086d653047286054117d584f1b1a7c22ceaf7b/packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5", size = 146714, upload-time = "2023-10-01T13:50:05.279Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7", size = 53011, upload-time = "2023-10-01T13:50:03.745Z" }, @@ -1670,7 +1670,7 @@ wheels = [ [[package]] name = "pandas" version = "2.3.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "numpy" }, { name = "python-dateutil" }, @@ -1718,7 +1718,7 @@ wheels = [ [[package]] name = "pastel" version = "0.2.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/76/f1/4594f5e0fcddb6953e5b8fe00da8c317b8b41b547e2b3ae2da7512943c62/pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d", size = 7555, upload-time = "2020-09-16T19:21:12.43Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/aa/18/a8444036c6dd65ba3624c63b734d3ba95ba63ace513078e1580590075d21/pastel-0.2.1-py2.py3-none-any.whl", hash = "sha256:4349225fcdf6c2bb34d483e523475de5bb04a5c10ef711263452cb37d7dd4364", size = 5955, upload-time = "2020-09-16T19:21:11.409Z" }, @@ -1727,7 +1727,7 @@ wheels = [ [[package]] name = "pathspec" version = "0.12.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/ca/bc/f35b8446f4531a7cb215605d100cd88b7ac6f44ab3fc94870c120ab3adbf/pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712", size = 51043, upload-time = "2023-12-10T22:30:45Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", size = 31191, upload-time = "2023-12-10T22:30:43.14Z" }, @@ -1736,7 +1736,7 @@ wheels = [ [[package]] name = "platformdirs" version = "4.3.8" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/fe/8b/3c73abc9c759ecd3f1f7ceff6685840859e8070c4d947c93fae71f6a0bf2/platformdirs-4.3.8.tar.gz", hash = "sha256:3d512d96e16bcb959a814c9f348431070822a6496326a4be0911c40b5a74c2bc", size = 21362, upload-time = "2025-05-07T22:47:42.121Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/fe/39/979e8e21520d4e47a0bbe349e2713c0aac6f3d853d0e5b34d76206c439aa/platformdirs-4.3.8-py3-none-any.whl", hash = "sha256:ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4", size = 18567, upload-time = "2025-05-07T22:47:40.376Z" }, @@ -1745,7 +1745,7 @@ wheels = [ [[package]] name = "pluggy" version = "1.6.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, @@ -1754,7 +1754,7 @@ wheels = [ [[package]] name = "poethepoet" version = "0.36.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pastel" }, { name = "pyyaml" }, @@ -1768,7 +1768,7 @@ wheels = [ [[package]] name = "propcache" version = "0.3.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a6/16/43264e4a779dd8588c21a70f0709665ee8f611211bdd2c87d952cfa7c776/propcache-0.3.2.tar.gz", hash = "sha256:20d7d62e4e7ef05f221e0db2856b979540686342e7dd9973b815599c7057e168", size = 44139, upload-time = "2025-06-09T22:56:06.081Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/ab/14/510deed325e262afeb8b360043c5d7c960da7d3ecd6d6f9496c9c56dc7f4/propcache-0.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:22d9962a358aedbb7a2e36187ff273adeaab9743373a272976d2e348d08c7770", size = 73178, upload-time = "2025-06-09T22:53:40.126Z" }, @@ -1857,7 +1857,7 @@ wheels = [ [[package]] name = "protobuf" version = "5.29.5" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/43/29/d09e70352e4e88c9c7a198d5645d7277811448d76c23b00345670f7c8a38/protobuf-5.29.5.tar.gz", hash = "sha256:bc1463bafd4b0929216c35f437a8e28731a2b7fe3d98bb77a600efced5a15c84", size = 425226, upload-time = "2025-05-28T23:51:59.82Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5f/11/6e40e9fc5bba02988a214c07cf324595789ca7820160bfd1f8be96e48539/protobuf-5.29.5-cp310-abi3-win32.whl", hash = "sha256:3f1c6468a2cfd102ff4703976138844f78ebd1fb45f49011afc5139e9e283079", size = 422963, upload-time = "2025-05-28T23:51:41.204Z" }, @@ -1871,7 +1871,7 @@ wheels = [ [[package]] name = "pyarrow" version = "20.0.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a2/ee/a7810cb9f3d6e9238e61d312076a9859bf3668fd21c69744de9532383912/pyarrow-20.0.0.tar.gz", hash = "sha256:febc4a913592573c8d5805091a6c2b5064c8bd6e002131f01061797d91c783c1", size = 1125187, upload-time = "2025-04-27T12:34:23.264Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5b/23/77094eb8ee0dbe88441689cb6afc40ac312a1e15d3a7acc0586999518222/pyarrow-20.0.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:c7dd06fd7d7b410ca5dc839cc9d485d2bc4ae5240851bcd45d85105cc90a47d7", size = 30832591, upload-time = "2025-04-27T12:27:27.89Z" }, @@ -1924,7 +1924,7 @@ wheels = [ [[package]] name = "pycparser" version = "2.22" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/1d/b2/31537cf4b1ca988837256c910a668b553fceb8f069bedc4b1c826024b52c/pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6", size = 172736, upload-time = "2024-03-30T13:22:22.564Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/13/a3/a812df4e2dd5696d1f351d58b8fe16a405b234ad2886a0dab9183fb78109/pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc", size = 117552, upload-time = "2024-03-30T13:22:20.476Z" }, @@ -1933,7 +1933,7 @@ wheels = [ [[package]] name = "pydantic" version = "2.11.7" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "annotated-types" }, { name = "pydantic-core" }, @@ -1948,7 +1948,7 @@ wheels = [ [[package]] name = "pydantic-core" version = "2.33.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "typing-extensions" }, ] @@ -2035,7 +2035,7 @@ wheels = [ [[package]] name = "pydantic-settings" version = "2.10.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pydantic" }, { name = "python-dotenv" }, @@ -2049,7 +2049,7 @@ wheels = [ [[package]] name = "pygments" version = "2.19.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, @@ -2058,7 +2058,7 @@ wheels = [ [[package]] name = "pyright" version = "1.1.403" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, @@ -2071,7 +2071,7 @@ wheels = [ [[package]] name = "pytest" version = "7.4.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, @@ -2088,7 +2088,7 @@ wheels = [ [[package]] name = "pytest-asyncio" version = "0.18.3" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pytest" }, ] @@ -2101,7 +2101,7 @@ wheels = [ [[package]] name = "pytest-pretty" version = "1.3.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "pytest" }, { name = "rich" }, @@ -2114,7 +2114,7 @@ wheels = [ [[package]] name = "python-dateutil" version = "2.9.0.post0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "six" }, ] @@ -2126,7 +2126,7 @@ wheels = [ [[package]] name = "python-dotenv" version = "1.1.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f6/b0/4bc07ccd3572a2f9df7e6782f52b0c6c90dcbb803ac4a167702d7d0dfe1e/python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab", size = 41978, upload-time = "2025-06-24T04:21:07.341Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5f/ed/539768cf28c661b5b068d66d96a2f155c4971a5d55684a514c1a0e0dec2f/python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc", size = 20556, upload-time = "2025-06-24T04:21:06.073Z" }, @@ -2135,7 +2135,7 @@ wheels = [ [[package]] name = "python-multipart" version = "0.0.20" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f3/87/f44d7c9f274c7ee665a29b885ec97089ec5dc034c7f3fafa03da9e39a09e/python_multipart-0.0.20.tar.gz", hash = "sha256:8dd0cab45b8e23064ae09147625994d090fa46f5b0d1e13af944c331a7fa9d13", size = 37158, upload-time = "2024-12-16T19:45:46.972Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/45/58/38b5afbc1a800eeea951b9285d3912613f2603bdf897a4ab0f4bd7f405fc/python_multipart-0.0.20-py3-none-any.whl", hash = "sha256:8a62d3a8335e06589fe01f2a3e178cdcc632f3fbe0d492ad9ee0ec35aab1f104", size = 24546, upload-time = "2024-12-16T19:45:44.423Z" }, @@ -2144,7 +2144,7 @@ wheels = [ [[package]] name = "pytz" version = "2025.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/f8/bf/abbd3cdfb8fbc7fb3d4d38d320f2441b1e7cbe29be4f23797b4a2b5d8aac/pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3", size = 320884, upload-time = "2025-03-25T02:25:00.538Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/81/c4/34e93fe5f5429d7570ec1fa436f1986fb1f00c3e0f43a589fe2bbcd22c3f/pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00", size = 509225, upload-time = "2025-03-25T02:24:58.468Z" }, @@ -2153,7 +2153,7 @@ wheels = [ [[package]] name = "pywin32" version = "310" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } wheels = [ { url = "https://files.pythonhosted.org/packages/95/da/a5f38fffbba2fb99aa4aa905480ac4b8e83ca486659ac8c95bce47fb5276/pywin32-310-cp310-cp310-win32.whl", hash = "sha256:6dd97011efc8bf51d6793a82292419eba2c71cf8e7250cfac03bba284454abc1", size = 8848240, upload-time = "2025-03-17T00:55:46.783Z" }, { url = "https://files.pythonhosted.org/packages/aa/fe/d873a773324fa565619ba555a82c9dabd677301720f3660a731a5d07e49a/pywin32-310-cp310-cp310-win_amd64.whl", hash = "sha256:c3e78706e4229b915a0821941a84e7ef420bf2b77e08c9dae3c76fd03fd2ae3d", size = 9601854, upload-time = "2025-03-17T00:55:48.783Z" }, @@ -2172,7 +2172,7 @@ wheels = [ [[package]] name = "pyyaml" version = "6.0.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/54/ed/79a089b6be93607fa5cdaedf301d7dfb23af5f25c398d5ead2525b063e17/pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e", size = 130631, upload-time = "2024-08-06T20:33:50.674Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/9b/95/a3fac87cb7158e231b5a6012e438c647e1a87f09f8e0d123acec8ab8bf71/PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086", size = 184199, upload-time = "2024-08-06T20:31:40.178Z" }, @@ -2216,7 +2216,7 @@ wheels = [ [[package]] name = "referencing" version = "0.36.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "attrs" }, { name = "rpds-py" }, @@ -2230,7 +2230,7 @@ wheels = [ [[package]] name = "regex" version = "2024.11.6" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/8e/5f/bd69653fbfb76cf8604468d3b4ec4c403197144c7bfe0e6a5fc9e02a07cb/regex-2024.11.6.tar.gz", hash = "sha256:7ab159b063c52a0333c884e4679f8d7a85112ee3078fe3d9004b2dd875585519", size = 399494, upload-time = "2024-11-06T20:12:31.635Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/95/3c/4651f6b130c6842a8f3df82461a8950f923925db8b6961063e82744bddcc/regex-2024.11.6-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ff590880083d60acc0433f9c3f713c51f7ac6ebb9adf889c79a261ecf541aa91", size = 482674, upload-time = "2024-11-06T20:08:57.575Z" }, @@ -2299,7 +2299,7 @@ wheels = [ [[package]] name = "requests" version = "2.32.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "certifi" }, { name = "charset-normalizer" }, @@ -2314,7 +2314,7 @@ wheels = [ [[package]] name = "requests-toolbelt" version = "1.0.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "requests" }, ] @@ -2326,7 +2326,7 @@ wheels = [ [[package]] name = "rich" version = "14.0.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "markdown-it-py" }, { name = "pygments" }, @@ -2340,7 +2340,7 @@ wheels = [ [[package]] name = "rpds-py" version = "0.26.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a5/aa/4456d84bbb54adc6a916fb10c9b374f78ac840337644e4a5eda229c81275/rpds_py-0.26.0.tar.gz", hash = "sha256:20dae58a859b0906f0685642e591056f1e787f3a8b39c8e8749a45dc7d26bdb0", size = 27385, upload-time = "2025-07-01T15:57:13.958Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b9/31/1459645f036c3dfeacef89e8e5825e430c77dde8489f3b99eaafcd4a60f5/rpds_py-0.26.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:4c70c70f9169692b36307a95f3d8c0a9fcd79f7b4a383aad5eaa0e9718b79b37", size = 372466, upload-time = "2025-07-01T15:53:40.55Z" }, @@ -2466,7 +2466,7 @@ wheels = [ [[package]] name = "s3transfer" version = "0.13.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "botocore" }, ] @@ -2478,7 +2478,7 @@ wheels = [ [[package]] name = "sentry-sdk" version = "2.34.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "certifi" }, { name = "urllib3" }, @@ -2491,7 +2491,7 @@ wheels = [ [[package]] name = "setuptools" version = "80.9.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/18/5d/3bf57dcd21979b887f014ea83c24ae194cfcd12b9e0fda66b957c69d1fca/setuptools-80.9.0.tar.gz", hash = "sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c", size = 1319958, upload-time = "2025-05-27T00:56:51.443Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl", hash = "sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922", size = 1201486, upload-time = "2025-05-27T00:56:49.664Z" }, @@ -2500,7 +2500,7 @@ wheels = [ [[package]] name = "six" version = "1.17.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, @@ -2509,7 +2509,7 @@ wheels = [ [[package]] name = "sniffio" version = "1.3.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, @@ -2518,7 +2518,7 @@ wheels = [ [[package]] name = "sortedcontainers" version = "2.4.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/e8/c4/ba2f8066cceb6f23394729afe52f3bf7adec04bf9ed2c820b39e19299111/sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88", size = 30594, upload-time = "2021-05-16T22:03:42.897Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0", size = 29575, upload-time = "2021-05-16T22:03:41.177Z" }, @@ -2527,7 +2527,7 @@ wheels = [ [[package]] name = "sqlalchemy" version = "2.0.41" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "greenlet", marker = "(python_full_version < '3.14' and platform_machine == 'AMD64') or (python_full_version < '3.14' and platform_machine == 'WIN32') or (python_full_version < '3.14' and platform_machine == 'aarch64') or (python_full_version < '3.14' and platform_machine == 'amd64') or (python_full_version < '3.14' and platform_machine == 'ppc64le') or (python_full_version < '3.14' and platform_machine == 'win32') or (python_full_version < '3.14' and platform_machine == 'x86_64')" }, { name = "typing-extensions" }, @@ -2572,7 +2572,7 @@ wheels = [ [[package]] name = "sse-starlette" version = "2.4.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "anyio" }, ] @@ -2584,7 +2584,7 @@ wheels = [ [[package]] name = "starlette" version = "0.47.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "anyio" }, { name = "typing-extensions", marker = "python_full_version < '3.13'" }, @@ -2760,7 +2760,7 @@ trio-async = [ [[package]] name = "tenacity" version = "8.5.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/a3/4d/6a19536c50b849338fcbe9290d562b52cbdcf30d8963d3588a68a4107df1/tenacity-8.5.0.tar.gz", hash = "sha256:8bc6c0c8a09b31e6cad13c47afbed1a567518250a9a171418582ed8d9c20ca78", size = 47309, upload-time = "2024-07-05T07:25:31.836Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d2/3f/8ba87d9e287b9d385a02a7114ddcef61b26f86411e121c9003eb509a1773/tenacity-8.5.0-py3-none-any.whl", hash = "sha256:b594c2a5945830c267ce6b79a166228323ed52718f30302c1359836112346687", size = 28165, upload-time = "2024-07-05T07:25:29.591Z" }, @@ -2769,7 +2769,7 @@ wheels = [ [[package]] name = "tiktoken" version = "0.9.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "regex" }, { name = "requests" }, @@ -2805,7 +2805,7 @@ wheels = [ [[package]] name = "tokenizers" version = "0.21.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "huggingface-hub" }, ] @@ -2830,7 +2830,7 @@ wheels = [ [[package]] name = "tomli" version = "2.2.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/18/87/302344fed471e44a87289cf4967697d07e532f2421fdaf868a303cbae4ff/tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff", size = 17175, upload-time = "2024-11-27T22:38:36.873Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/43/ca/75707e6efa2b37c77dadb324ae7d9571cb424e61ea73fad7c56c2d14527f/tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249", size = 131077, upload-time = "2024-11-27T22:37:54.956Z" }, @@ -2869,7 +2869,7 @@ wheels = [ [[package]] name = "tqdm" version = "4.67.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] @@ -2881,7 +2881,7 @@ wheels = [ [[package]] name = "trio" version = "0.28.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "attrs" }, { name = "cffi", marker = "implementation_name != 'pypy' and os_name == 'nt'" }, @@ -2899,7 +2899,7 @@ wheels = [ [[package]] name = "trio-asyncio" version = "0.15.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "greenlet" }, @@ -2915,7 +2915,7 @@ wheels = [ [[package]] name = "types-protobuf" version = "6.30.2.20250703" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/dc/54/d63ce1eee8e93c4d710bbe2c663ec68e3672cf4f2fca26eecd20981c0c5d/types_protobuf-6.30.2.20250703.tar.gz", hash = "sha256:609a974754bbb71fa178fc641f51050395e8e1849f49d0420a6281ed8d1ddf46", size = 62300, upload-time = "2025-07-03T03:14:05.74Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/7e/2b/5d0377c3d6e0f49d4847ad2c40629593fee4a5c9ec56eba26a15c708fbc0/types_protobuf-6.30.2.20250703-py3-none-any.whl", hash = "sha256:fa5aff9036e9ef432d703abbdd801b436a249b6802e4df5ef74513e272434e57", size = 76489, upload-time = "2025-07-03T03:14:04.453Z" }, @@ -2924,7 +2924,7 @@ wheels = [ [[package]] name = "types-pyyaml" version = "6.0.12.20250516" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/4e/22/59e2aeb48ceeee1f7cd4537db9568df80d62bdb44a7f9e743502ea8aab9c/types_pyyaml-6.0.12.20250516.tar.gz", hash = "sha256:9f21a70216fc0fa1b216a8176db5f9e0af6eb35d2f2932acb87689d03a5bf6ba", size = 17378, upload-time = "2025-05-16T03:08:04.897Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/99/5f/e0af6f7f6a260d9af67e1db4f54d732abad514252a7a378a6c4d17dd1036/types_pyyaml-6.0.12.20250516-py3-none-any.whl", hash = "sha256:8478208feaeb53a34cb5d970c56a7cd76b72659442e733e268a94dc72b2d0530", size = 20312, upload-time = "2025-05-16T03:08:04.019Z" }, @@ -2933,7 +2933,7 @@ wheels = [ [[package]] name = "types-requests" version = "2.32.4.20250611" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "urllib3" }, ] @@ -2945,7 +2945,7 @@ wheels = [ [[package]] name = "typing-extensions" version = "4.14.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/98/5a/da40306b885cc8c09109dc2e1abd358d5684b1425678151cdaed4731c822/typing_extensions-4.14.1.tar.gz", hash = "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36", size = 107673, upload-time = "2025-07-04T13:28:34.16Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b5/00/d631e67a838026495268c2f6884f3711a15a9a2a96cd244fdaea53b823fb/typing_extensions-4.14.1-py3-none-any.whl", hash = "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76", size = 43906, upload-time = "2025-07-04T13:28:32.743Z" }, @@ -2954,7 +2954,7 @@ wheels = [ [[package]] name = "typing-inspect" version = "0.9.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "mypy-extensions" }, { name = "typing-extensions" }, @@ -2967,7 +2967,7 @@ wheels = [ [[package]] name = "typing-inspection" version = "0.4.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "typing-extensions" }, ] @@ -2979,7 +2979,7 @@ wheels = [ [[package]] name = "tzdata" version = "2025.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/95/32/1a225d6164441be760d75c2c42e2780dc0873fe382da3e98a2e1e48361e5/tzdata-2025.2.tar.gz", hash = "sha256:b60a638fcc0daffadf82fe0f57e53d06bdec2f36c4df66280ae79bce6bd6f2b9", size = 196380, upload-time = "2025-03-23T13:54:43.652Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5c/23/c7abc0ca0a1526a0774eca151daeb8de62ec457e77262b66b359c3c7679e/tzdata-2025.2-py2.py3-none-any.whl", hash = "sha256:1a403fada01ff9221ca8044d701868fa132215d84beb92242d9acd2147f667a8", size = 347839, upload-time = "2025-03-23T13:54:41.845Z" }, @@ -2988,7 +2988,7 @@ wheels = [ [[package]] name = "urllib3" version = "2.5.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/15/22/9ee70a2574a4f4599c47dd506532914ce044817c7752a79b6a51286319bc/urllib3-2.5.0.tar.gz", hash = "sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760", size = 393185, upload-time = "2025-06-18T14:07:41.644Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl", hash = "sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc", size = 129795, upload-time = "2025-06-18T14:07:40.39Z" }, @@ -2997,7 +2997,7 @@ wheels = [ [[package]] name = "uvicorn" version = "0.24.0.post1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "click" }, { name = "h11" }, @@ -3022,7 +3022,7 @@ standard = [ [[package]] name = "uvloop" version = "0.21.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/af/c0/854216d09d33c543f12a44b393c402e89a920b1a0a7dc634c42de91b9cf6/uvloop-0.21.0.tar.gz", hash = "sha256:3bf12b0fda68447806a7ad847bfa591613177275d35b6724b1ee573faa3704e3", size = 2492741, upload-time = "2024-10-14T23:38:35.489Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/3d/76/44a55515e8c9505aa1420aebacf4dd82552e5e15691654894e90d0bd051a/uvloop-0.21.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ec7e6b09a6fdded42403182ab6b832b71f4edaf7f37a9a0e371a01db5f0cb45f", size = 1442019, upload-time = "2024-10-14T23:37:20.068Z" }, @@ -3054,7 +3054,7 @@ wheels = [ [[package]] name = "watchfiles" version = "1.1.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "anyio" }, ] @@ -3154,7 +3154,7 @@ wheels = [ [[package]] name = "websockets" version = "15.0.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/1e/da/6462a9f510c0c49837bbc9345aca92d767a56c1fb2939e1579df1e1cdcf7/websockets-15.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d63efaa0cd96cf0c5fe4d581521d9fa87744540d4bc999ae6e08595a1014b45b", size = 175423, upload-time = "2025-03-05T20:01:35.363Z" }, @@ -3213,7 +3213,7 @@ wheels = [ [[package]] name = "yarl" version = "1.20.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "idna" }, { name = "multidict" }, @@ -3312,7 +3312,7 @@ wheels = [ [[package]] name = "zipp" version = "3.23.0" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } sdist = { url = "https://files.pythonhosted.org/packages/e3/02/0f2892c661036d50ede074e376733dca2ae7c6eb617489437771209d4180/zipp-3.23.0.tar.gz", hash = "sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166", size = 25547, upload-time = "2025-06-08T17:06:39.4Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/2e/54/647ade08bf0db230bfea292f893923872fd20be6ac6f53b2b936ba839d75/zipp-3.23.0-py3-none-any.whl", hash = "sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e", size = 10276, upload-time = "2025-06-08T17:06:38.034Z" }, @@ -3321,7 +3321,7 @@ wheels = [ [[package]] name = "zope-event" version = "5.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "setuptools" }, ] @@ -3333,7 +3333,7 @@ wheels = [ [[package]] name = "zope-interface" version = "7.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.org/simple/" } dependencies = [ { name = "setuptools" }, ] From bd29c886683f26a577b260fc881193f4ca477f4a Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 11 Aug 2025 22:57:26 -0400 Subject: [PATCH 09/14] update samples to use environment configuration for client --- activity_worker/activity_worker.py | 1 + context_propagation/starter.py | 1 + context_propagation/worker.py | 1 + custom_converter/starter.py | 1 + custom_converter/worker.py | 1 + dsl/starter.py | 1 + dsl/worker.py | 1 + encryption/starter.py | 4 + encryption/worker.py | 4 + hello/hello_activity.py | 2 + hello_nexus/caller/app.py | 1 + hello_nexus/handler/worker.py | 1 + langchain/starter.py | 1 + message_passing/introduction/starter.py | 1 + message_passing/introduction/worker.py | 1 + .../safe_message_handlers/starter.py | 1 + .../safe_message_handlers/worker.py | 1 + .../lazy_initialization/starter.py | 1 + .../lazy_initialization/worker.py | 1 + .../waiting_for_handlers/starter.py | 1 + .../waiting_for_handlers/worker.py | 1 + .../starter.py | 1 + .../worker.py | 1 + open_telemetry/starter.py | 1 + open_telemetry/worker.py | 1 + .../basic/run_remote_image_workflow.py | 1 + .../handoffs/run_message_filter_workflow.py | 1 + patching/starter.py | 1 + prometheus/starter.py | 1 + prometheus/worker.py | 1 + pydantic_converter/starter.py | 1 + pydantic_converter/worker.py | 1 + pydantic_converter_v1/starter.py | 1 + pydantic_converter_v1/worker.py | 1 + sentry/starter.py | 2 + sleep_for_days/starter.py | 1 + temporal.toml | 4 + updatable_timer/starter.py | 1 + updatable_timer/wake_up_time_updater.py | 1 + updatable_timer/worker.py | 1 + util.py | 15 +++ worker_versioning/example.py | 121 ++++++++++++++++++ 42 files changed, 187 insertions(+) create mode 100644 temporal.toml create mode 100644 util.py create mode 100644 worker_versioning/example.py diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 986b0ae9..742226c1 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -1,6 +1,7 @@ import asyncio import random import string +from pathlib import Path from temporalio import activity from temporalio.client import Client diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 4d141dc0..125f791e 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/context_propagation/worker.py b/context_propagation/worker.py index 70ffa368..b4bd1955 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/custom_converter/starter.py b/custom_converter/starter.py index cc500ae4..abdb0809 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/custom_converter/worker.py b/custom_converter/worker.py index 17186aee..d130e930 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/dsl/starter.py b/dsl/starter.py index eb0f328d..a5b7de7e 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -2,6 +2,7 @@ import logging import sys import uuid +from pathlib import Path import dacite import yaml diff --git a/dsl/worker.py b/dsl/worker.py index e52ec872..7e620bf6 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/encryption/starter.py b/encryption/starter.py index f2570936..17c3b990 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -7,6 +7,7 @@ from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow +from util import get_temporal_config_path async def main(): @@ -21,6 +22,9 @@ async def main(): temporalio.converter.default(), payload_codec=EncryptionCodec() ), ) + + # Connect client + client = await Client.connect(**config) # Run workflow result = await client.execute_workflow( diff --git a/encryption/worker.py b/encryption/worker.py index d3387c70..929c6998 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -1,5 +1,6 @@ import asyncio import dataclasses +from pathlib import Path import temporalio.converter from temporalio import workflow @@ -31,6 +32,9 @@ async def main(): temporalio.converter.default(), payload_codec=EncryptionCodec() ), ) + + # Connect client + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 69226772..5df39861 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -8,6 +8,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 639456fa..69fa1d65 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -1,5 +1,6 @@ import asyncio import uuid +from pathlib import Path from typing import Optional from temporalio.client import Client diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index ded9c5ab..9cfb3c88 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from typing import Optional from temporalio.client import Client diff --git a/langchain/starter.py b/langchain/starter.py index 6d9e00c2..a5e571f6 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -1,4 +1,5 @@ from contextlib import asynccontextmanager +from pathlib import Path from typing import List from uuid import uuid4 diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index aa5b8967..3e00db78 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from typing import Optional from temporalio.client import Client, WorkflowUpdateStage diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 34974801..b78d7260 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 9bc5c661..b1020a88 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -2,6 +2,7 @@ import asyncio import logging import uuid +from pathlib import Path from typing import Optional from temporalio import common diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index 31e538d4..a2c7dbd5 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index ec874939..7befedf3 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -1,5 +1,6 @@ import asyncio import uuid +from pathlib import Path from typing import Optional, Tuple from temporalio import common diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index 1cc4f6ff..d06fd0f2 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 76829e0b..95ca95e0 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index e32a2dcb..2a882837 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index fbc5ae04..a7f11760 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 2a27769d..f0437587 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 9e8650b0..f99b3933 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 631bd008..b0ea3387 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -1,5 +1,6 @@ import asyncio from datetime import timedelta +from pathlib import Path from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index f2175f7f..b4574a5e 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index c2b2ba3d..4399a2a9 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -1,5 +1,6 @@ import asyncio import json +from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin diff --git a/patching/starter.py b/patching/starter.py index f1b92f32..d4c6b3b8 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -1,5 +1,6 @@ import argparse import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/prometheus/starter.py b/prometheus/starter.py index 571aee07..fef4934e 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,4 +1,5 @@ import asyncio +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/prometheus/worker.py b/prometheus/worker.py index b41b75c5..f996c812 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -1,5 +1,6 @@ import asyncio from datetime import timedelta +from pathlib import Path from temporalio import activity, workflow from temporalio.client import Client diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 47766be6..27530762 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -2,6 +2,7 @@ import logging from datetime import datetime from ipaddress import IPv4Address +from pathlib import Path from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index 8acc1125..2145093f 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -2,6 +2,7 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address +from pathlib import Path from typing import List from temporalio import activity, workflow diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 33b0ad28..b8ada872 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -2,6 +2,7 @@ import logging from datetime import datetime from ipaddress import IPv4Address +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 5ff65e1e..25c6c0a2 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -3,6 +3,7 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address +from pathlib import Path from typing import List from temporalio import activity, workflow diff --git a/sentry/starter.py b/sentry/starter.py index aa3f6271..5a7fa0fa 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,4 +1,6 @@ import asyncio +import os +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index 98dc083d..9970c941 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -1,5 +1,6 @@ import asyncio import uuid +from pathlib import Path from typing import Optional from temporalio.client import Client diff --git a/temporal.toml b/temporal.toml new file mode 100644 index 00000000..df78a1ab --- /dev/null +++ b/temporal.toml @@ -0,0 +1,4 @@ +# Default profile for local development +[profile.default] +address = "localhost:7233" +namespace = "default" \ No newline at end of file diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 8ce0f4f9..589e34e5 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -1,6 +1,7 @@ import asyncio import logging from datetime import datetime, timedelta +from pathlib import Path from typing import Optional from temporalio import exceptions diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 43d24838..3b22f83d 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -1,6 +1,7 @@ import asyncio import logging from datetime import datetime, timedelta +from pathlib import Path from typing import Optional from temporalio.client import Client diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 8bb3d47a..df34b4b0 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -1,5 +1,6 @@ import asyncio import logging +from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig diff --git a/util.py b/util.py new file mode 100644 index 00000000..5d107072 --- /dev/null +++ b/util.py @@ -0,0 +1,15 @@ +""" +Utility module +""" +from pathlib import Path + +def get_temporal_config_path() -> Path: + """ + Get the path to the temporal.toml configuration file. + + This assumes the temporal.toml file is in the root of the samples-python repository. + + Returns: + Path to temporal.toml + """ + return Path(__file__).resolve().parent / "temporal.toml" \ No newline at end of file diff --git a/worker_versioning/example.py b/worker_versioning/example.py new file mode 100644 index 00000000..77432eee --- /dev/null +++ b/worker_versioning/example.py @@ -0,0 +1,121 @@ +import asyncio +import uuid + +from temporalio.client import BuildIdOpAddNewCompatible, BuildIdOpAddNewDefault, Client +from temporalio.worker import Worker + +from worker_versioning.activities import greet, super_greet +from worker_versioning.workflow_v1 import MyWorkflow as MyWorkflowV1 +from worker_versioning.workflow_v1_1 import MyWorkflow as MyWorkflowV1_1 +from worker_versioning.workflow_v2 import MyWorkflow as MyWorkflowV2 + + +async def main(): + # Get repo root - 1 level deep from root + repo_root = Path(__file__).resolve().parent.parent + config_file = repo_root / "temporal.toml" + config = ClientConfig.load_client_connect_config(config_file=str(config_file)) + config["target_host"] = "localhost:7233" + client = await Client.connect(**config) + task_queue = f"worker-versioning-{uuid.uuid4()}" + + # Start a 1.0 worker + async with Worker( + client, + task_queue=task_queue, + workflows=[MyWorkflowV1], + activities=[greet, super_greet], + build_id="1.0", + use_worker_versioning=True, + ): + # Add 1.0 as the default version for the queue + await client.update_worker_build_id_compatibility( + task_queue, BuildIdOpAddNewDefault("1.0") + ) + + # Start a workflow which will run on the 1.0 worker + handle = await client.start_workflow( + MyWorkflowV1.run, + task_queue=task_queue, + id=f"worker-versioning-v1-{uuid.uuid4()}", + ) + # Signal the workflow to proceed + await handle.signal(MyWorkflowV1.proceeder, "go") + + # Give a chance for the worker to process the signal + # TODO Better? + await asyncio.sleep(1) + + # Add 1.1 as the default version for the queue, compatible with 1.0 + await client.update_worker_build_id_compatibility( + task_queue, BuildIdOpAddNewCompatible("1.1", "1.0") + ) + + # Stop the old worker, and start a 1.1 worker. We do this to speed along the example, since the + # 1.0 worker may continue to process tasks briefly after we make 1.1 the new default. + async with Worker( + client, + task_queue=task_queue, + workflows=[MyWorkflowV1_1], + activities=[greet, super_greet], + build_id="1.1", + use_worker_versioning=True, + ): + # Continue driving the workflow. Take note that the new version of the workflow run by the 1.1 + # worker is the one that takes over! You might see a workflow task timeout, if the 1.0 worker is + # processing a task as the version update happens. That's normal. + await handle.signal(MyWorkflowV1.proceeder, "go") + + # Add a new *incompatible* version to the task queue, which will become the new overall default for the queue. + await client.update_worker_build_id_compatibility( + task_queue, BuildIdOpAddNewDefault("2.0") + ) + + # Start a 2.0 worker + async with Worker( + client, + task_queue=task_queue, + workflows=[MyWorkflowV2], + activities=[greet, super_greet], + build_id="2.0", + use_worker_versioning=True, + ): + # Start a new workflow. Note that it will run on the new 2.0 version, without the client invocation changing + # at all! Note here we can use `MyWorkflowV1.run` because the signature of the workflow has not changed. + handle2 = await client.start_workflow( + MyWorkflowV1.run, + task_queue=task_queue, + id=f"worker-versioning-v2-{uuid.uuid4()}", + ) + + # Drive both workflows once more before concluding them. The first workflow will continue running on the 1.1 + # worker. + await handle.signal(MyWorkflowV1.proceeder, "go") + await handle2.signal(MyWorkflowV1.proceeder, "go") + await handle.signal(MyWorkflowV1.proceeder, "finish") + await handle2.signal(MyWorkflowV1.proceeder, "finish") + + # Wait for both workflows to complete + await handle.result() + await handle2.result() + + # Lastly we'll demonstrate how you can use the gRPC api to determine if certain build IDs are ready to be + # retired. There's more information in the documentation, but here's a quick example that shows us how to + # tell when the 1.0 worker can be retired: + + # There is a 5 minute buffer before we will consider IDs no longer reachable by new workflows, to + # account for replication in multi-cluster setups. Uncomment the following line to wait long enough to see + # the 1.0 worker become unreachable. + # await asyncio.sleep(60 * 5) + reachability = await client.get_worker_task_reachability( + build_ids=["2.0", "1.0", "1.1"] + ) + + if not reachability.build_id_reachability["1.0"].task_queue_reachability[ + task_queue + ]: + print("1.0 is ready to be retired!") + + +if __name__ == "__main__": + asyncio.run(main()) From b0b388111b9b0197ba9a03f48cd669bde46c4566 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 11 Aug 2025 23:54:03 -0400 Subject: [PATCH 10/14] linting fixes --- activity_worker/activity_worker.py | 3 ++- batch_sliding_window/starter.py | 1 + batch_sliding_window/worker.py | 1 + bedrock/basic/run_worker.py | 1 + bedrock/basic/send_message.py | 2 ++ bedrock/entity/end_chat.py | 2 ++ bedrock/entity/get_history.py | 2 ++ bedrock/entity/run_worker.py | 1 + bedrock/entity/send_message.py | 2 ++ bedrock/signals_and_queries/get_history.py | 2 ++ bedrock/signals_and_queries/run_worker.py | 1 + bedrock/signals_and_queries/send_message.py | 2 ++ cloud_export_to_parquet/create_schedule.py | 1 + cloud_export_to_parquet/run_worker.py | 1 + context_propagation/starter.py | 2 +- context_propagation/worker.py | 2 +- custom_converter/starter.py | 2 +- custom_converter/worker.py | 2 +- custom_decorator/starter.py | 1 + custom_decorator/worker.py | 1 + custom_metric/starter.py | 3 +++ custom_metric/worker.py | 1 + dsl/starter.py | 2 +- dsl/worker.py | 2 +- encryption/starter.py | 10 ++++++++-- encryption/worker.py | 12 +++++++++--- gevent_async/starter.py | 1 + gevent_async/worker.py | 1 + hello/hello_activity_async.py | 2 ++ hello/hello_activity_choice.py | 2 ++ hello/hello_activity_heartbeat.py | 2 ++ hello/hello_activity_method.py | 2 ++ hello/hello_activity_multiprocess.py | 2 ++ hello/hello_activity_retry.py | 2 ++ hello/hello_async_activity_completion.py | 2 ++ hello/hello_cancellation.py | 2 ++ hello/hello_change_log_level.py | 2 ++ hello/hello_child_workflow.py | 2 ++ hello/hello_continue_as_new.py | 2 ++ hello/hello_cron.py | 2 ++ hello/hello_exception.py | 2 ++ hello/hello_local_activity.py | 2 ++ hello/hello_parallel_activity.py | 2 ++ hello/hello_patch.py | 2 ++ hello/hello_query.py | 2 ++ hello/hello_search_attributes.py | 2 ++ hello/hello_signal.py | 2 ++ hello/hello_update.py | 2 ++ hello_nexus/caller/app.py | 2 +- hello_nexus/handler/worker.py | 2 +- langchain/starter.py | 3 ++- langchain/worker.py | 2 ++ message_passing/introduction/starter.py | 2 +- message_passing/introduction/worker.py | 2 +- message_passing/safe_message_handlers/starter.py | 2 +- message_passing/safe_message_handlers/worker.py | 2 +- .../update_with_start/lazy_initialization/starter.py | 2 +- .../update_with_start/lazy_initialization/worker.py | 2 +- message_passing/waiting_for_handlers/starter.py | 2 +- message_passing/waiting_for_handlers/worker.py | 2 +- .../waiting_for_handlers_and_compensation/starter.py | 2 +- .../waiting_for_handlers_and_compensation/worker.py | 2 +- open_telemetry/starter.py | 2 +- open_telemetry/worker.py | 3 ++- openai_agents/basic/run_agent_lifecycle_workflow.py | 1 + openai_agents/basic/run_remote_image_workflow.py | 2 +- .../handoffs/run_message_filter_workflow.py | 2 +- patching/starter.py | 2 +- patching/worker.py | 1 + polling/frequent/run_frequent.py | 1 + polling/frequent/run_worker.py | 1 + polling/infrequent/run_infrequent.py | 1 + polling/infrequent/run_worker.py | 1 + polling/periodic_sequence/run_periodic.py | 1 + polling/periodic_sequence/run_worker.py | 1 + prometheus/starter.py | 2 +- prometheus/worker.py | 3 ++- pydantic_converter/starter.py | 2 +- pydantic_converter/worker.py | 3 ++- pydantic_converter_v1/starter.py | 2 +- pydantic_converter_v1/worker.py | 3 ++- replay/replayer.py | 1 + replay/starter.py | 1 + replay/worker.py | 2 ++ resource_pool/starter.py | 1 + resource_pool/worker.py | 1 + schedules/run_worker.py | 2 ++ schedules/start_schedule.py | 2 ++ sentry/starter.py | 3 +-- sentry/worker.py | 1 + sleep_for_days/starter.py | 2 +- sleep_for_days/worker.py | 1 + trio_async/starter.py | 1 + trio_async/worker.py | 1 + updatable_timer/starter.py | 2 +- updatable_timer/wake_up_time_updater.py | 2 +- updatable_timer/worker.py | 2 +- util.py | 7 ++++--- worker_specific_task_queues/starter.py | 1 + worker_specific_task_queues/worker.py | 1 + worker_versioning/example.py | 11 ++++++----- 101 files changed, 162 insertions(+), 50 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 742226c1..82d9f347 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -1,13 +1,14 @@ import asyncio import random import string -from pathlib import Path from temporalio import activity from temporalio.client import Client from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + task_queue = "say-hello-task-queue" workflow_name = "say-hello-workflow" activity_name = "say-hello-activity" diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index 7e3b1fb3..0133f9ee 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -12,6 +12,7 @@ ProcessBatchWorkflow, ProcessBatchWorkflowInput, ) +from util import get_temporal_config_path async def main(): diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index a72ed96c..3fefa25f 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -12,6 +12,7 @@ from batch_sliding_window.record_loader_activity import RecordLoader from batch_sliding_window.record_processor_workflow import RecordProcessorWorkflow from batch_sliding_window.sliding_window_workflow import SlidingWindowWorkflow +from util import get_temporal_config_path async def main(): diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index 085b695c..fd69651f 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -8,6 +8,7 @@ from workflows import BasicBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 692a4927..a266284b 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from workflows import BasicBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt: str) -> str: # Create client connected to server at the given address diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 19984202..21f59abc 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index ffcfa31e..9b73484a 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -4,6 +4,8 @@ from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index ecc76c52..4a1b531f 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -8,6 +8,7 @@ from workflows import EntityBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index be7897f0..d21892e3 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from workflows import BedrockParams, EntityBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt): # Create client connected to server at the given address diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index 2bd6049f..8ac5f962 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -4,6 +4,8 @@ from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow +from util import get_temporal_config_path + async def main(): # Create client connected to server at the given address diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index 9d611588..1300efec 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -8,6 +8,7 @@ from workflows import SignalQueryBedrockWorkflow from bedrock.shared.activities import BedrockActivities +from util import get_temporal_config_path async def main(): diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 35a9df1c..e30fdc28 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow +from util import get_temporal_config_path + async def main(prompt): # Create client connected to server at the given address diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index 1f40a3ed..c3ffd0cc 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -16,6 +16,7 @@ ProtoToParquet, ProtoToParquetWorkflowInput, ) +from util import get_temporal_config_path async def main() -> None: diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index 6062abcd..7c8cc4f2 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -14,6 +14,7 @@ get_object_keys, ) from cloud_export_to_parquet.workflows import ProtoToParquet +from util import get_temporal_config_path async def main() -> None: diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 125f791e..2487eae0 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -1,11 +1,11 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from context_propagation import interceptor, shared, workflows +from util import get_temporal_config_path async def main(): diff --git a/context_propagation/worker.py b/context_propagation/worker.py index b4bd1955..e63d4a09 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -1,12 +1,12 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/custom_converter/starter.py b/custom_converter/starter.py index abdb0809..3bd62992 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -10,6 +9,7 @@ greeting_data_converter, ) from custom_converter.workflow import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/custom_converter/worker.py b/custom_converter/worker.py index d130e930..7f56cea2 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -7,6 +6,7 @@ from custom_converter.shared import greeting_data_converter from custom_converter.workflow import GreetingWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index aff675da..0ac8b190 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -4,6 +4,7 @@ from temporalio.envconfig import ClientConfig from custom_decorator.worker import WaitForCancelWorkflow +from util import get_temporal_config_path async def main(): diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index 0d25145b..fa2ec9aa 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -8,6 +8,7 @@ from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater +from util import get_temporal_config_path # Here we use our automatic heartbeater decorator. If this wasn't present, our diff --git a/custom_metric/starter.py b/custom_metric/starter.py index aeb6d2b7..85c9ea18 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -5,6 +5,7 @@ from temporalio.envconfig import ClientConfig from custom_metric.workflow import StartTwoActivitiesWorkflow +from util import get_temporal_config_path async def main(): @@ -12,6 +13,8 @@ async def main(): config.setdefault("target_host", "localhost:7233") client = await Client.connect(**config) + client = await Client.connect(**config) + await client.start_workflow( StartTwoActivitiesWorkflow.run, id="execute-activity-workflow-" + str(uuid.uuid4()), diff --git a/custom_metric/worker.py b/custom_metric/worker.py index 6a3be69a..2bf020fc 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -14,6 +14,7 @@ from custom_metric.activity import print_and_sleep from custom_metric.workflow import StartTwoActivitiesWorkflow +from util import get_temporal_config_path class SimpleWorkerInterceptor(Interceptor): diff --git a/dsl/starter.py b/dsl/starter.py index a5b7de7e..7c5fd0be 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -2,7 +2,6 @@ import logging import sys import uuid -from pathlib import Path import dacite import yaml @@ -10,6 +9,7 @@ from temporalio.envconfig import ClientConfig from dsl.workflow import DSLInput, DSLWorkflow +from util import get_temporal_config_path async def main(dsl_yaml: str) -> None: diff --git a/dsl/worker.py b/dsl/worker.py index 7e620bf6..6f1d1eaa 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ from dsl.activities import DSLActivities from dsl.workflow import DSLWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/encryption/starter.py b/encryption/starter.py index 17c3b990..ec43d421 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -22,9 +22,15 @@ async def main(): temporalio.converter.default(), payload_codec=EncryptionCodec() ), ) - + # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use the default converter, but change the codec + data_converter=dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() + ), + ) # Run workflow result = await client.execute_workflow( diff --git a/encryption/worker.py b/encryption/worker.py index 929c6998..4d642058 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -1,6 +1,5 @@ import asyncio import dataclasses -from pathlib import Path import temporalio.converter from temporalio import workflow @@ -9,6 +8,7 @@ from temporalio.worker import Worker from encryption.codec import EncryptionCodec +from util import get_temporal_config_path @workflow.defn(name="Workflow") @@ -32,9 +32,15 @@ async def main(): temporalio.converter.default(), payload_codec=EncryptionCodec() ), ) - + # Connect client - client = await Client.connect(**config) + client = await Client.connect( + **config, + # Use the default converter, but change the codec + data_converter=dataclasses.replace( + temporalio.converter.default(), payload_codec=EncryptionCodec() + ), + ) # Run a worker for the workflow async with Worker( diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 010803e5..50eabd4b 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -11,6 +11,7 @@ from gevent_async import workflow from gevent_async.executor import GeventExecutor +from util import get_temporal_config_path def main(): diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 219908af..4a9f8077 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -14,6 +14,7 @@ from gevent_async import activity, workflow from gevent_async.executor import GeventExecutor +from util import get_temporal_config_path def main(): diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index 6c1e195a..41fe114f 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -7,6 +7,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index 139d4006..6334314d 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -10,6 +10,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # Activities that will be called by the workflow diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index a7a8ffe9..0705ad02 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -9,6 +9,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index 0073ae45..5cc4ce32 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -6,6 +6,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + class MyDatabaseClient: async def run_database_update(self) -> None: diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index 5751a210..ad2a7c1d 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -11,6 +11,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import SharedStateManager, Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index c5007dfb..d3919f0f 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -9,6 +9,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 21a003df..e9a67c3f 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -7,6 +7,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index aaf0aa90..3b9baa42 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -11,6 +11,8 @@ from temporalio.exceptions import CancelledError from temporalio.worker import Worker +from util import get_temporal_config_path + @activity.defn def never_complete_activity() -> NoReturn: diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 4b7697f4..68133aed 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -14,6 +14,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # --- Begin logging set‑up ---------------------------------------------------------- logging.basicConfig( stream=sys.stdout, diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 6f99af5b..2198f117 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -6,6 +6,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index a4947019..f6ec9ca8 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -6,6 +6,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class LoopingWorkflow: diff --git a/hello/hello_cron.py b/hello/hello_cron.py index cf1bc4b1..a3376d30 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -8,6 +8,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_exception.py b/hello/hello_exception.py index a2d49633..2f35a7e1 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -12,6 +12,8 @@ from temporalio.exceptions import FailureError from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index a1dd08ed..6676f1b5 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -8,6 +8,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @dataclass class ComposeGreetingInput: diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index 680534ab..e7428ff7 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -8,6 +8,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @activity.defn def say_hello_activity(name: str) -> str: diff --git a/hello/hello_patch.py b/hello/hello_patch.py index a26e5474..102b54fe 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -9,6 +9,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/hello/hello_query.py b/hello/hello_query.py index 7ed132d1..65f0f02e 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index c858692a..70b8e2b1 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/hello/hello_signal.py b/hello/hello_signal.py index ed7ce7b3..5fd16e77 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -6,6 +6,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/hello/hello_update.py b/hello/hello_update.py index 4daa250a..2256eced 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -5,6 +5,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 69fa1d65..34e4d256 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -9,6 +8,7 @@ from hello_nexus.caller.workflows import CallerWorkflow from hello_nexus.service import MyOutput +from util import get_temporal_config_path NAMESPACE = "hello-nexus-basic-caller-namespace" TASK_QUEUE = "hello-nexus-basic-caller-task-queue" diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index 9cfb3c88..662ff445 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -9,6 +8,7 @@ from hello_nexus.handler.service_handler import MyNexusServiceHandler from hello_nexus.handler.workflows import WorkflowStartedByNexusOperation +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/langchain/starter.py b/langchain/starter.py index a5e571f6..b9a6f134 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -1,5 +1,4 @@ from contextlib import asynccontextmanager -from pathlib import Path from typing import List from uuid import uuid4 @@ -11,6 +10,8 @@ from temporalio.envconfig import ClientConfig from workflow import LangChainWorkflow, TranslateWorkflowParams +from util import get_temporal_config_path + @asynccontextmanager async def lifespan(app: FastAPI): diff --git a/langchain/worker.py b/langchain/worker.py index b7fb7741..5398c756 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -7,6 +7,8 @@ from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow +from util import get_temporal_config_path + interrupt_event = asyncio.Event() diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index 3e00db78..a3c7f13a 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from typing import Optional from temporalio.client import Client, WorkflowUpdateStage @@ -13,6 +12,7 @@ Language, SetLanguageInput, ) +from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index b78d7260..97dad264 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -9,6 +8,7 @@ from message_passing.introduction import TASK_QUEUE from message_passing.introduction.activities import call_greeting_service from message_passing.introduction.workflows import GreetingWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index b1020a88..f766589a 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -2,7 +2,6 @@ import asyncio import logging import uuid -from pathlib import Path from typing import Optional from temporalio import common @@ -15,6 +14,7 @@ ClusterManagerInput, ClusterManagerWorkflow, ) +from util import get_temporal_config_path async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] = None): diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index a2c7dbd5..24abcffd 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -13,6 +12,7 @@ start_cluster, unassign_nodes_for_job, ) +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index 7befedf3..b7357298 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional, Tuple from temporalio import common @@ -18,6 +17,7 @@ ShoppingCartItem, ShoppingCartWorkflow, ) +from util import get_temporal_config_path async def handle_add_item_request( diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index d06fd0f2..0a5ea896 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows from message_passing.update_with_start.lazy_initialization.activities import get_price +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 95ca95e0..aa2f1f47 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig @@ -11,6 +10,7 @@ WorkflowInput, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow +from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 2a882837..3711846a 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -11,6 +10,7 @@ activity_executed_by_update_handler, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index a7f11760..62def8d2 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,5 +1,4 @@ import asyncio -from pathlib import Path from temporalio import client, common from temporalio.envconfig import ClientConfig @@ -13,6 +12,7 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) +from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index f0437587..ccaba0f8 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -15,6 +14,7 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index f99b3933..3bd524ef 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -1,11 +1,11 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor from temporalio.envconfig import ClientConfig from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry +from util import get_temporal_config_path async def main(): diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index b0ea3387..4a618a0e 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -1,6 +1,5 @@ import asyncio from datetime import timedelta -from pathlib import Path from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter @@ -14,6 +13,8 @@ from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 2cd16c60..fb9eb358 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -6,6 +6,7 @@ from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, ) +from util import get_temporal_config_path async def main() -> None: diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index b4574a5e..5249adea 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -1,11 +1,11 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow +from util import get_temporal_config_path async def main(): diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 4399a2a9..9092df87 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -1,6 +1,5 @@ import asyncio import json -from pathlib import Path from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin @@ -9,6 +8,7 @@ from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, ) +from util import get_temporal_config_path async def main(): diff --git a/patching/starter.py b/patching/starter.py index d4c6b3b8..d14f2c1b 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -1,6 +1,5 @@ import argparse import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ # Since it's just used for typing purposes, it doesn't matter which one we # import from patching.workflow_1_initial import MyWorkflow +from util import get_temporal_config_path async def main(): diff --git a/patching/worker.py b/patching/worker.py index 417c8ef9..7b473cea 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -6,6 +6,7 @@ from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 42048092..30803ab0 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -4,6 +4,7 @@ from temporalio.envconfig import ClientConfig from polling.frequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index cf5ccb78..0ea08a16 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -6,6 +6,7 @@ from polling.frequent.activities import compose_greeting from polling.frequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index 8a0ea871..b546a790 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -4,6 +4,7 @@ from temporalio.envconfig import ClientConfig from polling.infrequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index f52a8082..4f955600 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -6,6 +6,7 @@ from polling.infrequent.activities import compose_greeting from polling.infrequent.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index 393fb8be..fddec690 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -4,6 +4,7 @@ from temporalio.envconfig import ClientConfig from polling.periodic_sequence.workflows import GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 9689ef2f..1a562270 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -6,6 +6,7 @@ from polling.periodic_sequence.activities import compose_greeting from polling.periodic_sequence.workflows import ChildWorkflow, GreetingWorkflow +from util import get_temporal_config_path async def main(): diff --git a/prometheus/starter.py b/prometheus/starter.py index fef4934e..05a5068c 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,10 +1,10 @@ import asyncio -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/prometheus/worker.py b/prometheus/worker.py index f996c812..73e1de27 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -1,6 +1,5 @@ import asyncio from datetime import timedelta -from pathlib import Path from temporalio import activity, workflow from temporalio.client import Client @@ -8,6 +7,8 @@ from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker +from util import get_temporal_config_path + @workflow.defn class GreetingWorkflow: diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index 27530762..cc0a80f8 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -2,13 +2,13 @@ import logging from datetime import datetime from ipaddress import IPv4Address -from pathlib import Path from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter from temporalio.envconfig import ClientConfig from pydantic_converter.worker import MyPydanticModel, MyWorkflow +from util import get_temporal_config_path async def main(): diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index 2145093f..cf701e27 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -2,7 +2,6 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address -from pathlib import Path from typing import List from temporalio import activity, workflow @@ -10,6 +9,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # Always pass through external modules to the sandbox that you know are safe for # workflow use with workflow.unsafe.imports_passed_through(): diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index b8ada872..1d404334 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -2,13 +2,13 @@ import logging from datetime import datetime from ipaddress import IPv4Address -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow +from util import get_temporal_config_path async def main(): diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 25c6c0a2..efb16adc 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -3,7 +3,6 @@ import logging from datetime import datetime, timedelta from ipaddress import IPv4Address -from pathlib import Path from typing import List from temporalio import activity, workflow @@ -22,6 +21,8 @@ from pydantic_converter_v1.converter import pydantic_data_converter +from util import get_temporal_config_path + class MyPydanticModel(BaseModel): some_ip: IPv4Address diff --git a/replay/replayer.py b/replay/replayer.py index 4787b33b..99aa4cbb 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -5,6 +5,7 @@ from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity +from util import get_temporal_config_path async def main(): diff --git a/replay/starter.py b/replay/starter.py index 228e50c3..d54fb021 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -4,6 +4,7 @@ from temporalio.envconfig import ClientConfig from replay.worker import JustActivity, JustTimer, TimerThenActivity +from util import get_temporal_config_path async def main(): diff --git a/replay/worker.py b/replay/worker.py index 4ac57da2..6bcef724 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -8,6 +8,8 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path + # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/resource_pool/starter.py b/resource_pool/starter.py index 2a50357a..fc487344 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -14,6 +14,7 @@ ResourceUserWorkflowInput, ) from resource_pool.shared import RESOURCE_POOL_WORKFLOW_ID +from util import get_temporal_config_path async def main() -> None: diff --git a/resource_pool/worker.py b/resource_pool/worker.py index 253e5f8e..7131a793 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -7,6 +7,7 @@ from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow from resource_pool.resource_user_workflow import ResourceUserWorkflow, use_resource +from util import get_temporal_config_path async def main() -> None: diff --git a/schedules/run_worker.py b/schedules/run_worker.py index 00d14aaa..3fdc15e9 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -6,6 +6,8 @@ from your_activities import your_activity from your_workflows import YourSchedulesWorkflow +from util import get_temporal_config_path + async def main(): config = ClientConfig.load_client_connect_config() diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index ead6202b..0f0ebd82 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -12,6 +12,8 @@ from temporalio.envconfig import ClientConfig from your_workflows import YourSchedulesWorkflow +from util import get_temporal_config_path + async def main(): config = ClientConfig.load_client_connect_config() diff --git a/sentry/starter.py b/sentry/starter.py index 5a7fa0fa..160e61ce 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,11 +1,10 @@ import asyncio -import os -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput +from util import get_temporal_config_path async def main(): diff --git a/sentry/worker.py b/sentry/worker.py index 1bcd153e..16330fac 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -17,6 +17,7 @@ from sentry.workflow import SentryExampleWorkflow interrupt_event = asyncio.Event() +from util import get_temporal_config_path def before_send(event: Event, hint: Hint) -> Event | None: diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index 9970c941..ad7cfbb9 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -1,6 +1,5 @@ import asyncio import uuid -from pathlib import Path from typing import Optional from temporalio.client import Client @@ -8,6 +7,7 @@ from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 59799607..72e9a467 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -8,6 +8,7 @@ from sleep_for_days import TASK_QUEUE from sleep_for_days.activities import send_email from sleep_for_days.workflows import SleepForDaysWorkflow +from util import get_temporal_config_path async def main(): diff --git a/trio_async/starter.py b/trio_async/starter.py index 6535ca98..0d2cbdd3 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -5,6 +5,7 @@ from temporalio.envconfig import ClientConfig from trio_async import workflows +from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives diff --git a/trio_async/worker.py b/trio_async/worker.py index f1c2a30b..1bf4660e 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -9,6 +9,7 @@ from temporalio.worker import Worker from trio_async import activities, workflows +from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index 589e34e5..a4185e4e 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -1,7 +1,6 @@ import asyncio import logging from datetime import datetime, timedelta -from pathlib import Path from typing import Optional from temporalio import exceptions @@ -10,6 +9,7 @@ from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 3b22f83d..216657f7 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -1,13 +1,13 @@ import asyncio import logging from datetime import datetime, timedelta -from pathlib import Path from typing import Optional from temporalio.client import Client from temporalio.envconfig import ClientConfig from updatable_timer.workflow import Workflow +from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index df34b4b0..35d05793 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -1,6 +1,5 @@ import asyncio import logging -from pathlib import Path from temporalio.client import Client from temporalio.envconfig import ClientConfig @@ -8,6 +7,7 @@ from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow +from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/util.py b/util.py index 5d107072..b15a68d0 100644 --- a/util.py +++ b/util.py @@ -3,13 +3,14 @@ """ from pathlib import Path + def get_temporal_config_path() -> Path: """ Get the path to the temporal.toml configuration file. - + This assumes the temporal.toml file is in the root of the samples-python repository. - + Returns: Path to temporal.toml """ - return Path(__file__).resolve().parent / "temporal.toml" \ No newline at end of file + return Path(__file__).resolve().parent / "temporal.toml" diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index 61009436..d876a81f 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -4,6 +4,7 @@ from temporalio.client import Client from temporalio.envconfig import ClientConfig +from util import get_temporal_config_path from worker_specific_task_queues.tasks import FileProcessing diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index 95824cfd..db80c230 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -9,6 +9,7 @@ from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path from worker_specific_task_queues import tasks interrupt_event = asyncio.Event() diff --git a/worker_versioning/example.py b/worker_versioning/example.py index 77432eee..4aa07278 100644 --- a/worker_versioning/example.py +++ b/worker_versioning/example.py @@ -2,8 +2,10 @@ import uuid from temporalio.client import BuildIdOpAddNewCompatible, BuildIdOpAddNewDefault, Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker +from util import get_temporal_config_path from worker_versioning.activities import greet, super_greet from worker_versioning.workflow_v1 import MyWorkflow as MyWorkflowV1 from worker_versioning.workflow_v1_1 import MyWorkflow as MyWorkflowV1_1 @@ -11,11 +13,10 @@ async def main(): - # Get repo root - 1 level deep from root - repo_root = Path(__file__).resolve().parent.parent - config_file = repo_root / "temporal.toml" - config = ClientConfig.load_client_connect_config(config_file=str(config_file)) - config["target_host"] = "localhost:7233" + config = ClientConfig.load_client_connect_config( + config_file=str(get_temporal_config_path()) + ) + client = await Client.connect(**config) task_queue = f"worker-versioning-{uuid.uuid4()}" From 591e4822d655d9cfce678ffbb3ba0855a36279e5 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Wed, 13 Aug 2025 11:18:07 -0400 Subject: [PATCH 11/14] update to direct profile mutation --- activity_worker/activity_worker.py | 4 +--- batch_sliding_window/starter.py | 3 +-- batch_sliding_window/worker.py | 3 +-- bedrock/basic/run_worker.py | 3 +-- bedrock/basic/send_message.py | 4 +--- bedrock/entity/end_chat.py | 4 +--- bedrock/entity/get_history.py | 4 +--- bedrock/entity/run_worker.py | 3 +-- bedrock/entity/send_message.py | 4 +--- bedrock/signals_and_queries/get_history.py | 4 +--- bedrock/signals_and_queries/run_worker.py | 3 +-- bedrock/signals_and_queries/send_message.py | 4 +--- cloud_export_to_parquet/create_schedule.py | 3 +-- cloud_export_to_parquet/run_worker.py | 3 +-- context_propagation/starter.py | 5 ++--- context_propagation/worker.py | 5 ++--- custom_converter/starter.py | 5 ++--- custom_converter/worker.py | 5 ++--- custom_decorator/starter.py | 3 +-- custom_decorator/worker.py | 3 +-- custom_metric/starter.py | 3 +-- custom_metric/worker.py | 5 ++--- dsl/starter.py | 3 +-- dsl/worker.py | 3 +-- encryption/starter.py | 5 ++--- encryption/worker.py | 5 ++--- gevent_async/starter.py | 3 +-- gevent_async/worker.py | 3 +-- hello/hello_activity.py | 6 ++---- hello/hello_activity_async.py | 4 +--- hello/hello_activity_choice.py | 6 ++---- hello/hello_activity_heartbeat.py | 4 +--- hello/hello_activity_method.py | 4 +--- hello/hello_activity_multiprocess.py | 4 +--- hello/hello_activity_retry.py | 4 +--- hello/hello_async_activity_completion.py | 4 +--- hello/hello_cancellation.py | 6 ++---- hello/hello_change_log_level.py | 4 +--- hello/hello_child_workflow.py | 6 ++---- hello/hello_continue_as_new.py | 4 +--- hello/hello_cron.py | 4 +--- hello/hello_exception.py | 4 +--- hello/hello_local_activity.py | 4 +--- hello/hello_parallel_activity.py | 4 +--- hello/hello_patch.py | 4 +--- hello/hello_query.py | 6 ++---- hello/hello_search_attributes.py | 4 +--- hello/hello_signal.py | 6 ++---- hello/hello_update.py | 4 +--- hello_nexus/caller/app.py | 3 +-- hello_nexus/handler/worker.py | 3 +-- langchain/starter.py | 6 ++---- langchain/worker.py | 4 +--- message_passing/introduction/starter.py | 3 +-- message_passing/introduction/worker.py | 3 +-- message_passing/safe_message_handlers/starter.py | 3 +-- message_passing/safe_message_handlers/worker.py | 3 +-- .../update_with_start/lazy_initialization/starter.py | 3 +-- .../update_with_start/lazy_initialization/worker.py | 3 +-- message_passing/waiting_for_handlers/starter.py | 3 +-- message_passing/waiting_for_handlers/worker.py | 3 +-- .../waiting_for_handlers_and_compensation/starter.py | 3 +-- .../waiting_for_handlers_and_compensation/worker.py | 3 +-- open_telemetry/starter.py | 5 ++--- open_telemetry/worker.py | 6 ++---- openai_agents/basic/run_agent_lifecycle_workflow.py | 3 +-- openai_agents/basic/run_remote_image_workflow.py | 5 ++--- openai_agents/handoffs/run_message_filter_workflow.py | 5 ++--- patching/starter.py | 3 +-- patching/worker.py | 3 +-- polling/frequent/run_frequent.py | 3 +-- polling/frequent/run_worker.py | 3 +-- polling/infrequent/run_infrequent.py | 3 +-- polling/infrequent/run_worker.py | 3 +-- polling/periodic_sequence/run_periodic.py | 3 +-- polling/periodic_sequence/run_worker.py | 3 +-- prometheus/starter.py | 5 ++--- prometheus/worker.py | 6 ++---- pydantic_converter/starter.py | 5 ++--- pydantic_converter/worker.py | 6 ++---- pydantic_converter_v1/starter.py | 5 ++--- pydantic_converter_v1/worker.py | 6 ++---- replay/replayer.py | 3 +-- replay/starter.py | 3 +-- replay/worker.py | 4 +--- resource_pool/starter.py | 3 +-- resource_pool/worker.py | 3 +-- schedules/run_worker.py | 4 +--- schedules/start_schedule.py | 4 +--- sentry/starter.py | 5 ++--- sentry/worker.py | 6 ++---- sleep_for_days/starter.py | 3 +-- sleep_for_days/worker.py | 3 +-- trio_async/starter.py | 3 +-- trio_async/worker.py | 3 +-- updatable_timer/starter.py | 3 +-- updatable_timer/wake_up_time_updater.py | 3 +-- updatable_timer/worker.py | 3 +-- worker_specific_task_queues/starter.py | 3 +-- worker_specific_task_queues/worker.py | 3 +-- worker_versioning/example.py | 10 ++++------ 101 files changed, 130 insertions(+), 270 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index 82d9f347..e6299fbc 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -4,11 +4,9 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - task_queue = "say-hello-task-queue" workflow_name = "say-hello-workflow" activity_name = "say-hello-activity" diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index 0133f9ee..1a4ab48b 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -6,13 +6,12 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from batch_sliding_window.batch_workflow import ( ProcessBatchWorkflow, ProcessBatchWorkflowInput, ) -from util import get_temporal_config_path async def main(): diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index 3fefa25f..f172c79c 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -6,13 +6,12 @@ from temporalio import worker from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from batch_sliding_window.batch_workflow import ProcessBatchWorkflow from batch_sliding_window.record_loader_activity import RecordLoader from batch_sliding_window.record_processor_workflow import RecordProcessorWorkflow from batch_sliding_window.sliding_window_workflow import SlidingWindowWorkflow -from util import get_temporal_config_path async def main(): diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index fd69651f..fcf39bed 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -3,12 +3,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import BasicBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index a266284b..061ed0d1 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -2,11 +2,9 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import BasicBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt: str) -> str: # Create client connected to server at the given address diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 21f59abc..19d06d11 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -2,11 +2,9 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index 9b73484a..e3aa6135 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -1,11 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 4a1b531f..0218eb11 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -3,12 +3,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import EntityBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index d21892e3..1b9babf8 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -2,11 +2,9 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import BedrockParams, EntityBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt): # Create client connected to server at the given address diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index 8ac5f962..fabe80b4 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -1,11 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import SignalQueryBedrockWorkflow -from util import get_temporal_config_path - async def main(): # Create client connected to server at the given address diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index 1300efec..c0052602 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -3,12 +3,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflows import SignalQueryBedrockWorkflow from bedrock.shared.activities import BedrockActivities -from util import get_temporal_config_path async def main(): diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index e30fdc28..5952b1ad 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -2,11 +2,9 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflows import SignalQueryBedrockWorkflow -from util import get_temporal_config_path - async def main(prompt): # Create client connected to server at the given address diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index c3ffd0cc..709a4dbd 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -10,13 +10,12 @@ ScheduleSpec, WorkflowFailureError, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from cloud_export_to_parquet.workflows import ( ProtoToParquet, ProtoToParquetWorkflowInput, ) -from util import get_temporal_config_path async def main() -> None: diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index 7c8cc4f2..b36fc69b 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -14,7 +14,6 @@ get_object_keys, ) from cloud_export_to_parquet.workflows import ProtoToParquet -from util import get_temporal_config_path async def main() -> None: diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 2487eae0..0d179436 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -2,10 +2,9 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from context_propagation import interceptor, shared, workflows -from util import get_temporal_config_path async def main(): @@ -19,7 +18,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/context_propagation/worker.py b/context_propagation/worker.py index e63d4a09..a7736b84 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -2,11 +2,10 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -19,7 +18,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 3bd62992..97192826 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_converter.shared import ( GreetingInput, @@ -9,7 +9,6 @@ greeting_data_converter, ) from custom_converter.workflow import GreetingWorkflow -from util import get_temporal_config_path async def main(): @@ -18,7 +17,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Without this we get: # TypeError: Object of type GreetingInput is not JSON serializable data_converter=greeting_data_converter, diff --git a/custom_converter/worker.py b/custom_converter/worker.py index 7f56cea2..fe75bce3 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,12 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from custom_converter.shared import greeting_data_converter from custom_converter.workflow import GreetingWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -17,7 +16,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Without this, when trying to run a workflow, we get: # KeyError: 'Unknown payload encoding my-greeting-encoding data_converter=greeting_data_converter, diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index 0ac8b190..73cfc9a6 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_decorator.worker import WaitForCancelWorkflow -from util import get_temporal_config_path async def main(): diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index fa2ec9aa..d33157b5 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -4,11 +4,10 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater -from util import get_temporal_config_path # Here we use our automatic heartbeater decorator. If this wasn't present, our diff --git a/custom_metric/starter.py b/custom_metric/starter.py index 85c9ea18..d2d40280 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -2,10 +2,9 @@ import uuid from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from custom_metric.workflow import StartTwoActivitiesWorkflow -from util import get_temporal_config_path async def main(): diff --git a/custom_metric/worker.py b/custom_metric/worker.py index 2bf020fc..fe7f8cee 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -3,7 +3,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import ( ActivityInboundInterceptor, @@ -14,7 +14,6 @@ from custom_metric.activity import print_and_sleep from custom_metric.workflow import StartTwoActivitiesWorkflow -from util import get_temporal_config_path class SimpleWorkerInterceptor(Interceptor): @@ -53,7 +52,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) worker = Worker( diff --git a/dsl/starter.py b/dsl/starter.py index 7c5fd0be..4d39f8d4 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -6,10 +6,9 @@ import dacite import yaml from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from dsl.workflow import DSLInput, DSLWorkflow -from util import get_temporal_config_path async def main(dsl_yaml: str) -> None: diff --git a/dsl/worker.py b/dsl/worker.py index 6f1d1eaa..7cc55867 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from dsl.activities import DSLActivities from dsl.workflow import DSLWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/encryption/starter.py b/encryption/starter.py index ec43d421..9f82fa9d 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -3,11 +3,10 @@ import temporalio.converter from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow -from util import get_temporal_config_path async def main(): @@ -25,7 +24,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/encryption/worker.py b/encryption/worker.py index 4d642058..28492c7c 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -4,11 +4,10 @@ import temporalio.converter from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from encryption.codec import EncryptionCodec -from util import get_temporal_config_path @workflow.defn(name="Workflow") @@ -35,7 +34,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 50eabd4b..86b79758 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -7,11 +7,10 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from gevent_async import workflow from gevent_async.executor import GeventExecutor -from util import get_temporal_config_path def main(): diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 4a9f8077..255dbfad 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -9,12 +9,11 @@ import gevent from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from gevent_async import activity, workflow from gevent_async.executor import GeventExecutor -from util import get_temporal_config_path def main(): diff --git a/hello/hello_activity.py b/hello/hello_activity.py index 5df39861..ca154561 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it @@ -50,7 +48,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index 41fe114f..b638e2c5 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -4,11 +4,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index 6334314d..cc63e099 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -7,11 +7,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # Activities that will be called by the workflow @@ -87,7 +85,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 0705ad02..7947fa06 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index 5cc4ce32..309ecff4 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -3,11 +3,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - class MyDatabaseClient: async def run_database_update(self) -> None: diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index ad2a7c1d..c9e5f371 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -8,11 +8,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import SharedStateManager, Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index d3919f0f..0db4503a 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index e9a67c3f..58475f44 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -4,11 +4,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 3b9baa42..6e81e786 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -7,12 +7,10 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import CancelledError from temporalio.worker import Worker -from util import get_temporal_config_path - @activity.defn def never_complete_activity() -> NoReturn: @@ -57,7 +55,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 68133aed..07e1b3c4 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -11,11 +11,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # --- Begin logging set‑up ---------------------------------------------------------- logging.basicConfig( stream=sys.stdout, diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 2198f117..028e8f78 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: @@ -38,7 +36,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index f6ec9ca8..5db2c826 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class LoopingWorkflow: diff --git a/hello/hello_cron.py b/hello/hello_cron.py index a3376d30..afe35372 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_exception.py b/hello/hello_exception.py index 2f35a7e1..423909be 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -8,12 +8,10 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import FailureError from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 6676f1b5..080bc089 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @dataclass class ComposeGreetingInput: diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index e7428ff7..de0f2852 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @activity.defn def say_hello_activity(name: str) -> str: diff --git a/hello/hello_patch.py b/hello/hello_patch.py index 102b54fe..03daf63f 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -6,11 +6,9 @@ from temporalio import activity, exceptions, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/hello/hello_query.py b/hello/hello_query.py index 65f0f02e..c8cb9c94 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -33,7 +31,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index 70b8e2b1..b886edc1 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: diff --git a/hello/hello_signal.py b/hello/hello_signal.py index 5fd16e77..c1332f24 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -3,11 +3,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -47,7 +45,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_update.py b/hello/hello_update.py index 2256eced..d3f7e0df 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -2,11 +2,9 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 34e4d256..7948e628 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -3,12 +3,11 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from hello_nexus.caller.workflows import CallerWorkflow from hello_nexus.service import MyOutput -from util import get_temporal_config_path NAMESPACE = "hello-nexus-basic-caller-namespace" TASK_QUEUE = "hello-nexus-basic-caller-task-queue" diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index 662ff445..f81cabcc 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -3,12 +3,11 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from hello_nexus.handler.service_handler import MyNexusServiceHandler from hello_nexus.handler.workflows import WorkflowStartedByNexusOperation -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/langchain/starter.py b/langchain/starter.py index b9a6f134..81e7feff 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -7,11 +7,9 @@ from fastapi import FastAPI, HTTPException from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from workflow import LangChainWorkflow, TranslateWorkflowParams -from util import get_temporal_config_path - @asynccontextmanager async def lifespan(app: FastAPI): @@ -19,7 +17,7 @@ async def lifespan(app: FastAPI): config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config.to_client_connect_config(), interceptors=[LangChainContextPropagationInterceptor()], ) yield diff --git a/langchain/worker.py b/langchain/worker.py index 5398c756..161a6faa 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -3,12 +3,10 @@ from activities import translate_phrase from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow -from util import get_temporal_config_path - interrupt_event = asyncio.Event() diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index a3c7f13a..944be2ba 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -2,7 +2,7 @@ from typing import Optional from temporalio.client import Client, WorkflowUpdateStage -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.introduction import TASK_QUEUE from message_passing.introduction.workflows import ( @@ -12,7 +12,6 @@ Language, SetLanguageInput, ) -from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index 97dad264..bdf8fec4 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -2,13 +2,12 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.introduction import TASK_QUEUE from message_passing.introduction.activities import call_greeting_service from message_passing.introduction.workflows import GreetingWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index f766589a..53ac0ef6 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -6,7 +6,7 @@ from temporalio import common from temporalio.client import Client, WorkflowHandle -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.safe_message_handlers.workflow import ( ClusterManagerAssignNodesToJobInput, @@ -14,7 +14,6 @@ ClusterManagerInput, ClusterManagerWorkflow, ) -from util import get_temporal_config_path async def do_cluster_lifecycle(wf: WorkflowHandle, delay_seconds: Optional[int] = None): diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index 24abcffd..5b8dc160 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.safe_message_handlers.workflow import ( @@ -12,7 +12,6 @@ start_cluster, unassign_nodes_for_job, ) -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index b7357298..537eede3 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -9,7 +9,7 @@ WorkflowHandle, WorkflowUpdateFailedError, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.exceptions import ApplicationError from message_passing.update_with_start.lazy_initialization import TASK_QUEUE @@ -17,7 +17,6 @@ ShoppingCartItem, ShoppingCartWorkflow, ) -from util import get_temporal_config_path async def handle_add_item_request( diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index 0a5ea896..ae48f8fa 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows from message_passing.update_with_start.lazy_initialization.activities import get_price -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index aa2f1f47..48e9bee9 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.waiting_for_handlers import ( TASK_QUEUE, @@ -10,7 +10,6 @@ WorkflowInput, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow -from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 3711846a..11bc9f00 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.waiting_for_handlers import TASK_QUEUE @@ -10,7 +10,6 @@ activity_executed_by_update_handler, ) from message_passing.waiting_for_handlers.workflows import WaitingForHandlersWorkflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index 62def8d2..585d14b9 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from message_passing.waiting_for_handlers_and_compensation import ( TASK_QUEUE, @@ -12,7 +12,6 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) -from util import get_temporal_config_path async def starter(exit_type: WorkflowExitType): diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index ccaba0f8..7ed1c040 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from message_passing.waiting_for_handlers_and_compensation import TASK_QUEUE @@ -14,7 +14,6 @@ from message_passing.waiting_for_handlers_and_compensation.workflows import ( WaitingForHandlersAndCompensationWorkflow, ) -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 3bd524ef..9f1d82b8 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -2,10 +2,9 @@ from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry -from util import get_temporal_config_path async def main(): @@ -15,7 +14,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 4a618a0e..57454b69 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -9,12 +9,10 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -58,7 +56,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index fb9eb358..7f945171 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -1,12 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, ) -from util import get_temporal_config_path async def main() -> None: diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index 5249adea..67783654 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -2,10 +2,9 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow -from util import get_temporal_config_path async def main(): @@ -13,7 +12,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config.to_client_connect_config(), plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 9092df87..6a4fba52 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -3,12 +3,11 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, ) -from util import get_temporal_config_path async def main(): @@ -17,7 +16,7 @@ async def main(): # Create client connected to server at the given address client = await Client.connect( - **config, + **config.to_client_connect_config(), plugins=[ OpenAIAgentsPlugin(), ], diff --git a/patching/starter.py b/patching/starter.py index d14f2c1b..44d746f6 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -2,12 +2,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile # Since it's just used for typing purposes, it doesn't matter which one we # import from patching.workflow_1_initial import MyWorkflow -from util import get_temporal_config_path async def main(): diff --git a/patching/worker.py b/patching/worker.py index 7b473cea..c5ab42a1 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -2,11 +2,10 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index 30803ab0..f1ca8041 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.frequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index 0ea08a16..212bba64 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -1,12 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.frequent.activities import compose_greeting from polling.frequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index b546a790..baf6fea4 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.infrequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index 4f955600..ae535cb6 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -1,12 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.infrequent.activities import compose_greeting from polling.infrequent.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index fddec690..d2166108 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from polling.periodic_sequence.workflows import GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index 1a562270..d34e8a79 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -1,12 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from polling.periodic_sequence.activities import compose_greeting from polling.periodic_sequence.workflows import ChildWorkflow, GreetingWorkflow -from util import get_temporal_config_path async def main(): diff --git a/prometheus/starter.py b/prometheus/starter.py index 05a5068c..5be2a2a3 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus -from util import get_temporal_config_path interrupt_event = asyncio.Event() @@ -17,7 +16,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) diff --git a/prometheus/worker.py b/prometheus/worker.py index 73e1de27..9a7d7841 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -3,12 +3,10 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker -from util import get_temporal_config_path - @workflow.defn class GreetingWorkflow: @@ -46,7 +44,7 @@ async def main(): # Connect client client = await Client.connect( - **config, + **config.to_client_connect_config(), runtime=runtime, ) diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index cc0a80f8..ff3a2960 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -5,10 +5,9 @@ from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from pydantic_converter.worker import MyPydanticModel, MyWorkflow -from util import get_temporal_config_path async def main(): @@ -20,7 +19,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index cf701e27..d519d23f 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -6,11 +6,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # Always pass through external modules to the sandbox that you know are safe for # workflow use with workflow.unsafe.imports_passed_through(): @@ -50,7 +48,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 1d404334..5ed5a255 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -4,11 +4,10 @@ from ipaddress import IPv4Address from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow -from util import get_temporal_config_path async def main(): @@ -20,7 +19,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index efb16adc..f5d140d6 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -21,8 +21,6 @@ from pydantic_converter_v1.converter import pydantic_data_converter -from util import get_temporal_config_path - class MyPydanticModel(BaseModel): some_ip: IPv4Address @@ -79,7 +77,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config, + **config.to_client_connect_config(), data_converter=pydantic_data_converter, ) diff --git a/replay/replayer.py b/replay/replayer.py index 99aa4cbb..285c7647 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -1,11 +1,10 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity -from util import get_temporal_config_path async def main(): diff --git a/replay/starter.py b/replay/starter.py index d54fb021..1dc4fe57 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from replay.worker import JustActivity, JustTimer, TimerThenActivity -from util import get_temporal_config_path async def main(): diff --git a/replay/worker.py b/replay/worker.py index 6bcef724..ab75327e 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -5,11 +5,9 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path - # While we could use multiple parameters in the activity, Temporal strongly # encourages using a single dataclass instead which can have fields added to it diff --git a/resource_pool/starter.py b/resource_pool/starter.py index fc487344..7aeb970d 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -3,7 +3,7 @@ from temporalio.client import Client, WorkflowFailureError, WorkflowHandle from temporalio.common import WorkflowIDConflictPolicy -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from resource_pool.pool_client.resource_pool_workflow import ( ResourcePoolWorkflow, @@ -14,7 +14,6 @@ ResourceUserWorkflowInput, ) from resource_pool.shared import RESOURCE_POOL_WORKFLOW_ID -from util import get_temporal_config_path async def main() -> None: diff --git a/resource_pool/worker.py b/resource_pool/worker.py index 7131a793..bd3f1e18 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow from resource_pool.resource_user_workflow import ResourceUserWorkflow, use_resource -from util import get_temporal_config_path async def main() -> None: diff --git a/schedules/run_worker.py b/schedules/run_worker.py index 3fdc15e9..0dc1b951 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -1,13 +1,11 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from your_activities import your_activity from your_workflows import YourSchedulesWorkflow -from util import get_temporal_config_path - async def main(): config = ClientConfig.load_client_connect_config() diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 0f0ebd82..31748874 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -9,11 +9,9 @@ ScheduleSpec, ScheduleState, ) -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from your_workflows import YourSchedulesWorkflow -from util import get_temporal_config_path - async def main(): config = ClientConfig.load_client_connect_config() diff --git a/sentry/starter.py b/sentry/starter.py index 160e61ce..c3f90f88 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,10 +1,9 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput -from util import get_temporal_config_path async def main(): @@ -12,7 +11,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Connect client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run workflow try: diff --git a/sentry/worker.py b/sentry/worker.py index 16330fac..8787d669 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -5,7 +5,7 @@ from sentry_sdk.integrations.asyncio import AsyncioIntegration from sentry_sdk.types import Event, Hint from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -17,8 +17,6 @@ from sentry.workflow import SentryExampleWorkflow interrupt_event = asyncio.Event() -from util import get_temporal_config_path - def before_send(event: Event, hint: Hint) -> Event | None: # Filter out __ShutdownRequested events raised by the worker's internals @@ -57,7 +55,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config) + client = await Client.connect(**config.to_client_connect_config()) # Run a worker for the workflow async with Worker( diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index ad7cfbb9..eca6fd29 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -3,11 +3,10 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 72e9a467..7176cc31 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -2,13 +2,12 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from sleep_for_days import TASK_QUEUE from sleep_for_days.activities import send_email from sleep_for_days.workflows import SleepForDaysWorkflow -from util import get_temporal_config_path async def main(): diff --git a/trio_async/starter.py b/trio_async/starter.py index 0d2cbdd3..177b01f6 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -2,10 +2,9 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from trio_async import workflows -from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives diff --git a/trio_async/worker.py b/trio_async/worker.py index 1bf4660e..55f30b20 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -5,11 +5,10 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from trio_async import activities, workflows -from util import get_temporal_config_path @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index a4185e4e..b3d66dd9 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -5,11 +5,10 @@ from temporalio import exceptions from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 216657f7..5f3e37c9 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -4,10 +4,9 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from updatable_timer.workflow import Workflow -from util import get_temporal_config_path async def main(client: Optional[Client] = None): diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 35d05793..551b8532 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -2,12 +2,11 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow -from util import get_temporal_config_path interrupt_event = asyncio.Event() diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index d876a81f..93a0e3eb 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -2,9 +2,8 @@ from uuid import uuid4 from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile -from util import get_temporal_config_path from worker_specific_task_queues.tasks import FileProcessing diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index db80c230..bda59f00 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -6,10 +6,9 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path from worker_specific_task_queues import tasks interrupt_event = asyncio.Event() diff --git a/worker_versioning/example.py b/worker_versioning/example.py index 4aa07278..f4c49c37 100644 --- a/worker_versioning/example.py +++ b/worker_versioning/example.py @@ -2,10 +2,9 @@ import uuid from temporalio.client import BuildIdOpAddNewCompatible, BuildIdOpAddNewDefault, Client -from temporalio.envconfig import ClientConfig +from temporalio.envconfig import ClientConfigProfile from temporalio.worker import Worker -from util import get_temporal_config_path from worker_versioning.activities import greet, super_greet from worker_versioning.workflow_v1 import MyWorkflow as MyWorkflowV1 from worker_versioning.workflow_v1_1 import MyWorkflow as MyWorkflowV1_1 @@ -13,11 +12,10 @@ async def main(): - config = ClientConfig.load_client_connect_config( - config_file=str(get_temporal_config_path()) - ) + config = ClientConfigProfile.load() + config["address"] = "localhost:7233" + client = await Client.connect(**config.to_client_connect_config()) - client = await Client.connect(**config) task_queue = f"worker-versioning-{uuid.uuid4()}" # Start a 1.0 worker From c31e56789c79728097897898b5a54e0a8354256f Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 10 Nov 2025 10:03:45 -0800 Subject: [PATCH 12/14] update new samples to use envconfig --- eager_wf_start/run.py | 6 +- nexus_multiple_args/caller/app.py | 9 +- nexus_multiple_args/handler/worker.py | 10 +- nexus_sync_operations/caller/app.py | 9 +- nexus_sync_operations/handler/worker.py | 9 +- openai_agents/mcp/run_file_system_worker.py | 5 +- openai_agents/mcp/run_file_system_workflow.py | 5 +- .../run_memory_research_scratchpad_worker.py | 5 +- ...run_memory_research_scratchpad_workflow.py | 9 +- openai_agents/mcp/run_prompt_server_worker.py | 5 +- .../mcp/run_prompt_server_workflow.py | 5 +- openai_agents/mcp/run_sse_worker.py | 5 +- openai_agents/mcp/run_sse_workflow.py | 5 +- .../mcp/run_streamable_http_worker.py | 5 +- .../mcp/run_streamable_http_workflow.py | 5 +- worker_versioning/app.py | 5 +- worker_versioning/example.py | 120 ------------------ worker_versioning/workerv1.py | 3 + worker_versioning/workerv1_1.py | 5 +- worker_versioning/workerv2.py | 5 +- 20 files changed, 84 insertions(+), 151 deletions(-) delete mode 100644 worker_versioning/example.py diff --git a/eager_wf_start/run.py b/eager_wf_start/run.py index c1daf82a..51a1ddf6 100644 --- a/eager_wf_start/run.py +++ b/eager_wf_start/run.py @@ -2,6 +2,7 @@ import uuid from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from eager_wf_start.activities import greeting @@ -13,7 +14,10 @@ async def main(): # Note that the worker and client run in the same process and share the same client connection. - client = await Client.connect("localhost:7233") + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) + worker = Worker( client, task_queue=TASK_QUEUE, diff --git a/nexus_multiple_args/caller/app.py b/nexus_multiple_args/caller/app.py index 88aadbf9..83c10dea 100644 --- a/nexus_multiple_args/caller/app.py +++ b/nexus_multiple_args/caller/app.py @@ -3,6 +3,7 @@ from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from nexus_multiple_args.caller.workflows import CallerWorkflow @@ -14,10 +15,10 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> tuple[str, str]: - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if client is None: + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config, namespace=NAMESPACE) async with Worker( client, diff --git a/nexus_multiple_args/handler/worker.py b/nexus_multiple_args/handler/worker.py index d12a7ee1..d7da6132 100644 --- a/nexus_multiple_args/handler/worker.py +++ b/nexus_multiple_args/handler/worker.py @@ -3,6 +3,7 @@ from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from nexus_multiple_args.handler.service_handler import MyNexusServiceHandler @@ -17,10 +18,11 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if client is None: + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config, namespace=NAMESPACE) + # Start the worker, passing the Nexus service handler instance, in addition to the # workflow classes that are started by your nexus operations, and any activities diff --git a/nexus_sync_operations/caller/app.py b/nexus_sync_operations/caller/app.py index 4966415c..653d945d 100644 --- a/nexus_sync_operations/caller/app.py +++ b/nexus_sync_operations/caller/app.py @@ -3,6 +3,7 @@ from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from nexus_sync_operations.caller.workflows import CallerWorkflow @@ -14,10 +15,10 @@ async def execute_caller_workflow( client: Optional[Client] = None, ) -> None: - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if client is None: + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config, namespace=NAMESPACE) async with Worker( client, diff --git a/nexus_sync_operations/handler/worker.py b/nexus_sync_operations/handler/worker.py index 5545adc0..04cf377f 100644 --- a/nexus_sync_operations/handler/worker.py +++ b/nexus_sync_operations/handler/worker.py @@ -3,6 +3,7 @@ from typing import Optional from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.introduction.activities import call_greeting_service @@ -18,10 +19,10 @@ async def main(client: Optional[Client] = None): logging.basicConfig(level=logging.INFO) - client = client or await Client.connect( - "localhost:7233", - namespace=NAMESPACE, - ) + if client is None: + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config, namespace=NAMESPACE) # Create the nexus service handler instance, starting the long-running entity workflow that # backs the Nexus service diff --git a/openai_agents/mcp/run_file_system_worker.py b/openai_agents/mcp/run_file_system_worker.py index 0eb440bb..90aead03 100644 --- a/openai_agents/mcp/run_file_system_worker.py +++ b/openai_agents/mcp/run_file_system_worker.py @@ -7,6 +7,7 @@ from agents.mcp import MCPServerStdio from temporalio.client import Client +from temporalio.envconfig import ClientConfig from temporalio.contrib.openai_agents import ( ModelActivityParameters, OpenAIAgentsPlugin, @@ -33,8 +34,10 @@ async def main(): ) # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_file_system_workflow.py b/openai_agents/mcp/run_file_system_workflow.py index a52e7d56..2322be0e 100644 --- a/openai_agents/mcp/run_file_system_workflow.py +++ b/openai_agents/mcp/run_file_system_workflow.py @@ -2,14 +2,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.mcp.workflows.file_system_workflow import FileSystemWorkflow async def main(): # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin(), ], diff --git a/openai_agents/mcp/run_memory_research_scratchpad_worker.py b/openai_agents/mcp/run_memory_research_scratchpad_worker.py index fb1d8494..c4033604 100644 --- a/openai_agents/mcp/run_memory_research_scratchpad_worker.py +++ b/openai_agents/mcp/run_memory_research_scratchpad_worker.py @@ -11,6 +11,7 @@ OpenAIAgentsPlugin, StatefulMCPServerProvider, ) +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from openai_agents.mcp.workflows.memory_research_scratchpad_workflow import ( @@ -32,8 +33,10 @@ async def main(): ) # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_memory_research_scratchpad_workflow.py b/openai_agents/mcp/run_memory_research_scratchpad_workflow.py index 03969fb4..c6ff2ed4 100644 --- a/openai_agents/mcp/run_memory_research_scratchpad_workflow.py +++ b/openai_agents/mcp/run_memory_research_scratchpad_workflow.py @@ -4,6 +4,7 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.mcp.workflows.memory_research_scratchpad_workflow import ( MemoryResearchScratchpadWorkflow, @@ -11,9 +12,13 @@ async def main(): + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", - plugins=[OpenAIAgentsPlugin()], + **config, + plugins=[ + OpenAIAgentsPlugin(), + ], ) result = await client.execute_workflow( diff --git a/openai_agents/mcp/run_prompt_server_worker.py b/openai_agents/mcp/run_prompt_server_worker.py index e390c0ac..cff8d1d7 100644 --- a/openai_agents/mcp/run_prompt_server_worker.py +++ b/openai_agents/mcp/run_prompt_server_worker.py @@ -11,6 +11,7 @@ OpenAIAgentsPlugin, StatelessMCPServerProvider, ) +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from openai_agents.mcp.workflows.prompt_server_workflow import PromptServerWorkflow @@ -32,8 +33,10 @@ async def main(): ) # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_prompt_server_workflow.py b/openai_agents/mcp/run_prompt_server_workflow.py index 79e4bf65..9cad2725 100644 --- a/openai_agents/mcp/run_prompt_server_workflow.py +++ b/openai_agents/mcp/run_prompt_server_workflow.py @@ -4,14 +4,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.mcp.workflows.prompt_server_workflow import PromptServerWorkflow async def main(): # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/mcp/run_sse_worker.py b/openai_agents/mcp/run_sse_worker.py index 406e65bf..d9f9dd38 100644 --- a/openai_agents/mcp/run_sse_worker.py +++ b/openai_agents/mcp/run_sse_worker.py @@ -11,6 +11,7 @@ OpenAIAgentsPlugin, StatelessMCPServerProvider, ) +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from openai_agents.mcp.workflows.sse_workflow import SseWorkflow @@ -32,8 +33,10 @@ async def main(): ) # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_sse_workflow.py b/openai_agents/mcp/run_sse_workflow.py index 42a45596..8effd5fe 100644 --- a/openai_agents/mcp/run_sse_workflow.py +++ b/openai_agents/mcp/run_sse_workflow.py @@ -4,14 +4,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.mcp.workflows.sse_workflow import SseWorkflow async def main(): # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/mcp/run_streamable_http_worker.py b/openai_agents/mcp/run_streamable_http_worker.py index 9c178b6f..210634bb 100644 --- a/openai_agents/mcp/run_streamable_http_worker.py +++ b/openai_agents/mcp/run_streamable_http_worker.py @@ -11,6 +11,7 @@ OpenAIAgentsPlugin, StatelessMCPServerProvider, ) +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from openai_agents.mcp.workflows.streamable_http_workflow import StreamableHttpWorkflow @@ -32,8 +33,10 @@ async def main(): ) # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_streamable_http_workflow.py b/openai_agents/mcp/run_streamable_http_workflow.py index aa5d1bac..b691e456 100644 --- a/openai_agents/mcp/run_streamable_http_workflow.py +++ b/openai_agents/mcp/run_streamable_http_workflow.py @@ -4,14 +4,17 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin +from temporalio.envconfig import ClientConfig from openai_agents.mcp.workflows.streamable_http_workflow import StreamableHttpWorkflow async def main(): # Create client connected to server at the given address + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect( - "localhost:7233", + **config, plugins=[OpenAIAgentsPlugin()], ) diff --git a/worker_versioning/app.py b/worker_versioning/app.py index 8b32aa94..78e1d641 100644 --- a/worker_versioning/app.py +++ b/worker_versioning/app.py @@ -5,6 +5,7 @@ import uuid from temporalio.client import Client +from temporalio.envconfig import ClientConfig TASK_QUEUE = "worker-versioning" DEPLOYMENT_NAME = "my-deployment" @@ -13,7 +14,9 @@ async def main() -> None: - client = await Client.connect("localhost:7233") + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Wait for v1 worker and set as current version logging.info( diff --git a/worker_versioning/example.py b/worker_versioning/example.py deleted file mode 100644 index f4c49c37..00000000 --- a/worker_versioning/example.py +++ /dev/null @@ -1,120 +0,0 @@ -import asyncio -import uuid - -from temporalio.client import BuildIdOpAddNewCompatible, BuildIdOpAddNewDefault, Client -from temporalio.envconfig import ClientConfigProfile -from temporalio.worker import Worker - -from worker_versioning.activities import greet, super_greet -from worker_versioning.workflow_v1 import MyWorkflow as MyWorkflowV1 -from worker_versioning.workflow_v1_1 import MyWorkflow as MyWorkflowV1_1 -from worker_versioning.workflow_v2 import MyWorkflow as MyWorkflowV2 - - -async def main(): - config = ClientConfigProfile.load() - config["address"] = "localhost:7233" - client = await Client.connect(**config.to_client_connect_config()) - - task_queue = f"worker-versioning-{uuid.uuid4()}" - - # Start a 1.0 worker - async with Worker( - client, - task_queue=task_queue, - workflows=[MyWorkflowV1], - activities=[greet, super_greet], - build_id="1.0", - use_worker_versioning=True, - ): - # Add 1.0 as the default version for the queue - await client.update_worker_build_id_compatibility( - task_queue, BuildIdOpAddNewDefault("1.0") - ) - - # Start a workflow which will run on the 1.0 worker - handle = await client.start_workflow( - MyWorkflowV1.run, - task_queue=task_queue, - id=f"worker-versioning-v1-{uuid.uuid4()}", - ) - # Signal the workflow to proceed - await handle.signal(MyWorkflowV1.proceeder, "go") - - # Give a chance for the worker to process the signal - # TODO Better? - await asyncio.sleep(1) - - # Add 1.1 as the default version for the queue, compatible with 1.0 - await client.update_worker_build_id_compatibility( - task_queue, BuildIdOpAddNewCompatible("1.1", "1.0") - ) - - # Stop the old worker, and start a 1.1 worker. We do this to speed along the example, since the - # 1.0 worker may continue to process tasks briefly after we make 1.1 the new default. - async with Worker( - client, - task_queue=task_queue, - workflows=[MyWorkflowV1_1], - activities=[greet, super_greet], - build_id="1.1", - use_worker_versioning=True, - ): - # Continue driving the workflow. Take note that the new version of the workflow run by the 1.1 - # worker is the one that takes over! You might see a workflow task timeout, if the 1.0 worker is - # processing a task as the version update happens. That's normal. - await handle.signal(MyWorkflowV1.proceeder, "go") - - # Add a new *incompatible* version to the task queue, which will become the new overall default for the queue. - await client.update_worker_build_id_compatibility( - task_queue, BuildIdOpAddNewDefault("2.0") - ) - - # Start a 2.0 worker - async with Worker( - client, - task_queue=task_queue, - workflows=[MyWorkflowV2], - activities=[greet, super_greet], - build_id="2.0", - use_worker_versioning=True, - ): - # Start a new workflow. Note that it will run on the new 2.0 version, without the client invocation changing - # at all! Note here we can use `MyWorkflowV1.run` because the signature of the workflow has not changed. - handle2 = await client.start_workflow( - MyWorkflowV1.run, - task_queue=task_queue, - id=f"worker-versioning-v2-{uuid.uuid4()}", - ) - - # Drive both workflows once more before concluding them. The first workflow will continue running on the 1.1 - # worker. - await handle.signal(MyWorkflowV1.proceeder, "go") - await handle2.signal(MyWorkflowV1.proceeder, "go") - await handle.signal(MyWorkflowV1.proceeder, "finish") - await handle2.signal(MyWorkflowV1.proceeder, "finish") - - # Wait for both workflows to complete - await handle.result() - await handle2.result() - - # Lastly we'll demonstrate how you can use the gRPC api to determine if certain build IDs are ready to be - # retired. There's more information in the documentation, but here's a quick example that shows us how to - # tell when the 1.0 worker can be retired: - - # There is a 5 minute buffer before we will consider IDs no longer reachable by new workflows, to - # account for replication in multi-cluster setups. Uncomment the following line to wait long enough to see - # the 1.0 worker become unreachable. - # await asyncio.sleep(60 * 5) - reachability = await client.get_worker_task_reachability( - build_ids=["2.0", "1.0", "1.1"] - ) - - if not reachability.build_id_reachability["1.0"].task_queue_reachability[ - task_queue - ]: - print("1.0 is ready to be retired!") - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/worker_versioning/workerv1.py b/worker_versioning/workerv1.py index 13c4ed4b..221b5ca9 100644 --- a/worker_versioning/workerv1.py +++ b/worker_versioning/workerv1.py @@ -5,6 +5,7 @@ from temporalio.client import Client from temporalio.common import WorkerDeploymentVersion +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker, WorkerDeploymentConfig from worker_versioning.activities import some_activity, some_incompatible_activity @@ -16,6 +17,8 @@ async def main() -> None: """Run worker v1.""" + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") client = await Client.connect("localhost:7233") # Create worker v1 diff --git a/worker_versioning/workerv1_1.py b/worker_versioning/workerv1_1.py index 779db3f9..4f21d616 100644 --- a/worker_versioning/workerv1_1.py +++ b/worker_versioning/workerv1_1.py @@ -5,6 +5,7 @@ from temporalio.client import Client from temporalio.common import WorkerDeploymentVersion +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker, WorkerDeploymentConfig from worker_versioning.activities import some_activity, some_incompatible_activity @@ -16,7 +17,9 @@ async def main() -> None: """Run worker v1.1.""" - client = await Client.connect("localhost:7233") + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create worker v1.1 worker = Worker( diff --git a/worker_versioning/workerv2.py b/worker_versioning/workerv2.py index 107e1a52..557f70ab 100644 --- a/worker_versioning/workerv2.py +++ b/worker_versioning/workerv2.py @@ -5,6 +5,7 @@ from temporalio.client import Client from temporalio.common import WorkerDeploymentVersion +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker, WorkerDeploymentConfig from worker_versioning.activities import some_activity, some_incompatible_activity @@ -16,7 +17,9 @@ async def main() -> None: """Run worker v2.""" - client = await Client.connect("localhost:7233") + config = ClientConfig.load_client_connect_config() + config.setdefault("target_host", "localhost:7233") + client = await Client.connect(**config) # Create worker v2 worker = Worker( From f2dd3d3a16a07829e9e8fd106e18df9bd68df501 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 10 Nov 2025 10:35:44 -0800 Subject: [PATCH 13/14] linting again --- activity_worker/activity_worker.py | 2 +- batch_sliding_window/starter.py | 2 +- batch_sliding_window/worker.py | 2 +- bedrock/basic/run_worker.py | 2 +- bedrock/basic/send_message.py | 2 +- bedrock/entity/end_chat.py | 2 +- bedrock/entity/get_history.py | 2 +- bedrock/entity/run_worker.py | 2 +- bedrock/entity/send_message.py | 2 +- bedrock/signals_and_queries/get_history.py | 2 +- bedrock/signals_and_queries/run_worker.py | 2 +- bedrock/signals_and_queries/send_message.py | 2 +- cloud_export_to_parquet/create_schedule.py | 2 +- cloud_export_to_parquet/run_worker.py | 2 +- context_propagation/starter.py | 4 ++-- context_propagation/worker.py | 4 ++-- custom_converter/starter.py | 4 ++-- custom_converter/worker.py | 4 ++-- custom_decorator/starter.py | 2 +- custom_decorator/worker.py | 2 +- custom_metric/starter.py | 4 +--- custom_metric/worker.py | 4 ++-- dsl/starter.py | 2 +- dsl/worker.py | 2 +- encryption/starter.py | 4 ++-- encryption/worker.py | 4 ++-- gevent_async/starter.py | 2 +- gevent_async/worker.py | 2 +- hello/hello_activity.py | 4 ++-- hello/hello_activity_async.py | 2 +- hello/hello_activity_choice.py | 4 ++-- hello/hello_activity_heartbeat.py | 2 +- hello/hello_activity_method.py | 2 +- hello/hello_activity_multiprocess.py | 2 +- hello/hello_activity_retry.py | 2 +- hello/hello_async_activity_completion.py | 2 +- hello/hello_cancellation.py | 4 ++-- hello/hello_change_log_level.py | 2 +- hello/hello_child_workflow.py | 4 ++-- hello/hello_continue_as_new.py | 2 +- hello/hello_cron.py | 2 +- hello/hello_exception.py | 2 +- hello/hello_local_activity.py | 2 +- hello/hello_parallel_activity.py | 2 +- hello/hello_patch.py | 2 +- hello/hello_query.py | 4 ++-- hello/hello_search_attributes.py | 2 +- hello/hello_signal.py | 4 ++-- hello/hello_update.py | 2 +- hello_nexus/caller/app.py | 2 +- hello_nexus/handler/worker.py | 2 +- langchain/starter.py | 4 ++-- langchain/worker.py | 2 +- message_passing/introduction/starter.py | 2 +- message_passing/introduction/worker.py | 2 +- message_passing/safe_message_handlers/starter.py | 2 +- message_passing/safe_message_handlers/worker.py | 2 +- .../update_with_start/lazy_initialization/starter.py | 2 +- .../update_with_start/lazy_initialization/worker.py | 2 +- message_passing/waiting_for_handlers/starter.py | 2 +- message_passing/waiting_for_handlers/worker.py | 2 +- .../waiting_for_handlers_and_compensation/starter.py | 2 +- .../waiting_for_handlers_and_compensation/worker.py | 2 +- nexus_multiple_args/caller/app.py | 3 ++- nexus_multiple_args/handler/worker.py | 4 ++-- nexus_sync_operations/caller/app.py | 3 ++- nexus_sync_operations/handler/worker.py | 3 ++- open_telemetry/starter.py | 4 ++-- open_telemetry/worker.py | 4 ++-- openai_agents/basic/run_agent_lifecycle_workflow.py | 2 +- openai_agents/basic/run_remote_image_workflow.py | 4 ++-- openai_agents/handoffs/run_message_filter_workflow.py | 4 ++-- openai_agents/mcp/run_file_system_worker.py | 4 ++-- openai_agents/mcp/run_file_system_workflow.py | 2 +- openai_agents/mcp/run_memory_research_scratchpad_worker.py | 2 +- openai_agents/mcp/run_memory_research_scratchpad_workflow.py | 2 +- patching/starter.py | 2 +- patching/worker.py | 2 +- polling/frequent/run_frequent.py | 2 +- polling/frequent/run_worker.py | 2 +- polling/infrequent/run_infrequent.py | 2 +- polling/infrequent/run_worker.py | 2 +- polling/periodic_sequence/run_periodic.py | 2 +- polling/periodic_sequence/run_worker.py | 2 +- prometheus/starter.py | 4 ++-- prometheus/worker.py | 4 ++-- pydantic_converter/starter.py | 4 ++-- pydantic_converter/worker.py | 4 ++-- pydantic_converter_v1/starter.py | 4 ++-- pydantic_converter_v1/worker.py | 4 ++-- replay/replayer.py | 2 +- replay/starter.py | 2 +- replay/worker.py | 2 +- resource_pool/starter.py | 2 +- resource_pool/worker.py | 2 +- schedules/run_worker.py | 2 +- schedules/start_schedule.py | 2 +- sentry/starter.py | 4 ++-- sentry/worker.py | 5 +++-- sleep_for_days/starter.py | 2 +- sleep_for_days/worker.py | 2 +- trio_async/starter.py | 2 +- trio_async/worker.py | 2 +- updatable_timer/starter.py | 2 +- updatable_timer/wake_up_time_updater.py | 2 +- updatable_timer/worker.py | 2 +- worker_specific_task_queues/starter.py | 2 +- worker_specific_task_queues/worker.py | 2 +- 108 files changed, 140 insertions(+), 138 deletions(-) diff --git a/activity_worker/activity_worker.py b/activity_worker/activity_worker.py index e6299fbc..986b0ae9 100644 --- a/activity_worker/activity_worker.py +++ b/activity_worker/activity_worker.py @@ -4,7 +4,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker task_queue = "say-hello-task-queue" diff --git a/batch_sliding_window/starter.py b/batch_sliding_window/starter.py index 1a4ab48b..7e3b1fb3 100644 --- a/batch_sliding_window/starter.py +++ b/batch_sliding_window/starter.py @@ -6,7 +6,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ( ProcessBatchWorkflow, diff --git a/batch_sliding_window/worker.py b/batch_sliding_window/worker.py index f172c79c..a72ed96c 100644 --- a/batch_sliding_window/worker.py +++ b/batch_sliding_window/worker.py @@ -6,7 +6,7 @@ from temporalio import worker from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from batch_sliding_window.batch_workflow import ProcessBatchWorkflow from batch_sliding_window.record_loader_activity import RecordLoader diff --git a/bedrock/basic/run_worker.py b/bedrock/basic/run_worker.py index fcf39bed..085b695c 100644 --- a/bedrock/basic/run_worker.py +++ b/bedrock/basic/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import BasicBedrockWorkflow diff --git a/bedrock/basic/send_message.py b/bedrock/basic/send_message.py index 061ed0d1..692a4927 100644 --- a/bedrock/basic/send_message.py +++ b/bedrock/basic/send_message.py @@ -2,7 +2,7 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import BasicBedrockWorkflow diff --git a/bedrock/entity/end_chat.py b/bedrock/entity/end_chat.py index 19d06d11..19984202 100644 --- a/bedrock/entity/end_chat.py +++ b/bedrock/entity/end_chat.py @@ -2,7 +2,7 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow diff --git a/bedrock/entity/get_history.py b/bedrock/entity/get_history.py index e3aa6135..ffcfa31e 100644 --- a/bedrock/entity/get_history.py +++ b/bedrock/entity/get_history.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import EntityBedrockWorkflow diff --git a/bedrock/entity/run_worker.py b/bedrock/entity/run_worker.py index 0218eb11..ecc76c52 100644 --- a/bedrock/entity/run_worker.py +++ b/bedrock/entity/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import EntityBedrockWorkflow diff --git a/bedrock/entity/send_message.py b/bedrock/entity/send_message.py index 1b9babf8..be7897f0 100644 --- a/bedrock/entity/send_message.py +++ b/bedrock/entity/send_message.py @@ -2,7 +2,7 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import BedrockParams, EntityBedrockWorkflow diff --git a/bedrock/signals_and_queries/get_history.py b/bedrock/signals_and_queries/get_history.py index fabe80b4..2bd6049f 100644 --- a/bedrock/signals_and_queries/get_history.py +++ b/bedrock/signals_and_queries/get_history.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow diff --git a/bedrock/signals_and_queries/run_worker.py b/bedrock/signals_and_queries/run_worker.py index c0052602..9d611588 100644 --- a/bedrock/signals_and_queries/run_worker.py +++ b/bedrock/signals_and_queries/run_worker.py @@ -3,7 +3,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflows import SignalQueryBedrockWorkflow diff --git a/bedrock/signals_and_queries/send_message.py b/bedrock/signals_and_queries/send_message.py index 5952b1ad..35a9df1c 100644 --- a/bedrock/signals_and_queries/send_message.py +++ b/bedrock/signals_and_queries/send_message.py @@ -2,7 +2,7 @@ import sys from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflows import SignalQueryBedrockWorkflow diff --git a/cloud_export_to_parquet/create_schedule.py b/cloud_export_to_parquet/create_schedule.py index 709a4dbd..1f40a3ed 100644 --- a/cloud_export_to_parquet/create_schedule.py +++ b/cloud_export_to_parquet/create_schedule.py @@ -10,7 +10,7 @@ ScheduleSpec, WorkflowFailureError, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from cloud_export_to_parquet.workflows import ( ProtoToParquet, diff --git a/cloud_export_to_parquet/run_worker.py b/cloud_export_to_parquet/run_worker.py index b36fc69b..6062abcd 100644 --- a/cloud_export_to_parquet/run_worker.py +++ b/cloud_export_to_parquet/run_worker.py @@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, diff --git a/context_propagation/starter.py b/context_propagation/starter.py index 0d179436..4d141dc0 100644 --- a/context_propagation/starter.py +++ b/context_propagation/starter.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from context_propagation import interceptor, shared, workflows @@ -18,7 +18,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/context_propagation/worker.py b/context_propagation/worker.py index a7736b84..70ffa368 100644 --- a/context_propagation/worker.py +++ b/context_propagation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from context_propagation import activities, interceptor, workflows @@ -18,7 +18,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use our interceptor interceptors=[interceptor.ContextPropagationInterceptor()], ) diff --git a/custom_converter/starter.py b/custom_converter/starter.py index 97192826..cc500ae4 100644 --- a/custom_converter/starter.py +++ b/custom_converter/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_converter.shared import ( GreetingInput, @@ -17,7 +17,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Without this we get: # TypeError: Object of type GreetingInput is not JSON serializable data_converter=greeting_data_converter, diff --git a/custom_converter/worker.py b/custom_converter/worker.py index fe75bce3..17186aee 100644 --- a/custom_converter/worker.py +++ b/custom_converter/worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_converter.shared import greeting_data_converter @@ -16,7 +16,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Without this, when trying to run a workflow, we get: # KeyError: 'Unknown payload encoding my-greeting-encoding data_converter=greeting_data_converter, diff --git a/custom_decorator/starter.py b/custom_decorator/starter.py index 73cfc9a6..aff675da 100644 --- a/custom_decorator/starter.py +++ b/custom_decorator/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_decorator.worker import WaitForCancelWorkflow diff --git a/custom_decorator/worker.py b/custom_decorator/worker.py index d33157b5..0d25145b 100644 --- a/custom_decorator/worker.py +++ b/custom_decorator/worker.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from custom_decorator.activity_utils import auto_heartbeater diff --git a/custom_metric/starter.py b/custom_metric/starter.py index d2d40280..aeb6d2b7 100644 --- a/custom_metric/starter.py +++ b/custom_metric/starter.py @@ -2,7 +2,7 @@ import uuid from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from custom_metric.workflow import StartTwoActivitiesWorkflow @@ -12,8 +12,6 @@ async def main(): config.setdefault("target_host", "localhost:7233") client = await Client.connect(**config) - client = await Client.connect(**config) - await client.start_workflow( StartTwoActivitiesWorkflow.run, id="execute-activity-workflow-" + str(uuid.uuid4()), diff --git a/custom_metric/worker.py b/custom_metric/worker.py index fe7f8cee..6a3be69a 100644 --- a/custom_metric/worker.py +++ b/custom_metric/worker.py @@ -3,7 +3,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import ( ActivityInboundInterceptor, @@ -52,7 +52,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) worker = Worker( diff --git a/dsl/starter.py b/dsl/starter.py index 4d39f8d4..eb0f328d 100644 --- a/dsl/starter.py +++ b/dsl/starter.py @@ -6,7 +6,7 @@ import dacite import yaml from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from dsl.workflow import DSLInput, DSLWorkflow diff --git a/dsl/worker.py b/dsl/worker.py index 7cc55867..e52ec872 100644 --- a/dsl/worker.py +++ b/dsl/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from dsl.activities import DSLActivities diff --git a/encryption/starter.py b/encryption/starter.py index 9f82fa9d..8caf764b 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -3,7 +3,7 @@ import temporalio.converter from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from encryption.codec import EncryptionCodec from encryption.worker import GreetingWorkflow @@ -24,7 +24,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/encryption/worker.py b/encryption/worker.py index 28492c7c..c0cb68b1 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -4,7 +4,7 @@ import temporalio.converter from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from encryption.codec import EncryptionCodec @@ -34,7 +34,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use the default converter, but change the codec data_converter=dataclasses.replace( temporalio.converter.default(), payload_codec=EncryptionCodec() diff --git a/gevent_async/starter.py b/gevent_async/starter.py index 86b79758..010803e5 100644 --- a/gevent_async/starter.py +++ b/gevent_async/starter.py @@ -7,7 +7,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from gevent_async import workflow from gevent_async.executor import GeventExecutor diff --git a/gevent_async/worker.py b/gevent_async/worker.py index 255dbfad..219908af 100644 --- a/gevent_async/worker.py +++ b/gevent_async/worker.py @@ -9,7 +9,7 @@ import gevent from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from gevent_async import activity, workflow diff --git a/hello/hello_activity.py b/hello/hello_activity.py index ca154561..69226772 100644 --- a/hello/hello_activity.py +++ b/hello/hello_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -48,7 +48,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_async.py b/hello/hello_activity_async.py index b638e2c5..6c1e195a 100644 --- a/hello/hello_activity_async.py +++ b/hello/hello_activity_async.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_activity_choice.py b/hello/hello_activity_choice.py index cc63e099..139d4006 100644 --- a/hello/hello_activity_choice.py +++ b/hello/hello_activity_choice.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # Activities that will be called by the workflow @@ -85,7 +85,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_activity_heartbeat.py b/hello/hello_activity_heartbeat.py index 7947fa06..a7a8ffe9 100644 --- a/hello/hello_activity_heartbeat.py +++ b/hello/hello_activity_heartbeat.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_activity_method.py b/hello/hello_activity_method.py index 309ecff4..0073ae45 100644 --- a/hello/hello_activity_method.py +++ b/hello/hello_activity_method.py @@ -3,7 +3,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_activity_multiprocess.py b/hello/hello_activity_multiprocess.py index c9e5f371..5751a210 100644 --- a/hello/hello_activity_multiprocess.py +++ b/hello/hello_activity_multiprocess.py @@ -8,7 +8,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import SharedStateManager, Worker diff --git a/hello/hello_activity_retry.py b/hello/hello_activity_retry.py index 0db4503a..c5007dfb 100644 --- a/hello/hello_activity_retry.py +++ b/hello/hello_activity_retry.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_async_activity_completion.py b/hello/hello_async_activity_completion.py index 58475f44..21a003df 100644 --- a/hello/hello_async_activity_completion.py +++ b/hello/hello_async_activity_completion.py @@ -4,7 +4,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_cancellation.py b/hello/hello_cancellation.py index 6e81e786..aaf0aa90 100644 --- a/hello/hello_cancellation.py +++ b/hello/hello_cancellation.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import CancelledError from temporalio.worker import Worker @@ -55,7 +55,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_change_log_level.py b/hello/hello_change_log_level.py index 07e1b3c4..4b7697f4 100644 --- a/hello/hello_change_log_level.py +++ b/hello/hello_change_log_level.py @@ -11,7 +11,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # --- Begin logging set‑up ---------------------------------------------------------- diff --git a/hello/hello_child_workflow.py b/hello/hello_child_workflow.py index 028e8f78..6f99af5b 100644 --- a/hello/hello_child_workflow.py +++ b/hello/hello_child_workflow.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -36,7 +36,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_continue_as_new.py b/hello/hello_continue_as_new.py index 5db2c826..a4947019 100644 --- a/hello/hello_continue_as_new.py +++ b/hello/hello_continue_as_new.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_cron.py b/hello/hello_cron.py index afe35372..cf1bc4b1 100644 --- a/hello/hello_cron.py +++ b/hello/hello_cron.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_exception.py b/hello/hello_exception.py index 423909be..a2d49633 100644 --- a/hello/hello_exception.py +++ b/hello/hello_exception.py @@ -8,7 +8,7 @@ from temporalio import activity, workflow from temporalio.client import Client, WorkflowFailureError from temporalio.common import RetryPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import FailureError from temporalio.worker import Worker diff --git a/hello/hello_local_activity.py b/hello/hello_local_activity.py index 080bc089..a1dd08ed 100644 --- a/hello/hello_local_activity.py +++ b/hello/hello_local_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_parallel_activity.py b/hello/hello_parallel_activity.py index de0f2852..680534ab 100644 --- a/hello/hello_parallel_activity.py +++ b/hello/hello_parallel_activity.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_patch.py b/hello/hello_patch.py index 03daf63f..a26e5474 100644 --- a/hello/hello_patch.py +++ b/hello/hello_patch.py @@ -6,7 +6,7 @@ from temporalio import activity, exceptions, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_query.py b/hello/hello_query.py index c8cb9c94..7ed132d1 100644 --- a/hello/hello_query.py +++ b/hello/hello_query.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -31,7 +31,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_search_attributes.py b/hello/hello_search_attributes.py index b886edc1..c858692a 100644 --- a/hello/hello_search_attributes.py +++ b/hello/hello_search_attributes.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello/hello_signal.py b/hello/hello_signal.py index c1332f24..ed7ce7b3 100644 --- a/hello/hello_signal.py +++ b/hello/hello_signal.py @@ -3,7 +3,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker @@ -45,7 +45,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/hello/hello_update.py b/hello/hello_update.py index d3f7e0df..4daa250a 100644 --- a/hello/hello_update.py +++ b/hello/hello_update.py @@ -2,7 +2,7 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/hello_nexus/caller/app.py b/hello_nexus/caller/app.py index 7948e628..639456fa 100644 --- a/hello_nexus/caller/app.py +++ b/hello_nexus/caller/app.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.caller.workflows import CallerWorkflow diff --git a/hello_nexus/handler/worker.py b/hello_nexus/handler/worker.py index f81cabcc..ded9c5ab 100644 --- a/hello_nexus/handler/worker.py +++ b/hello_nexus/handler/worker.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from hello_nexus.handler.service_handler import MyNexusServiceHandler diff --git a/langchain/starter.py b/langchain/starter.py index 81e7feff..6d9e00c2 100644 --- a/langchain/starter.py +++ b/langchain/starter.py @@ -7,7 +7,7 @@ from fastapi import FastAPI, HTTPException from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from workflow import LangChainWorkflow, TranslateWorkflowParams @@ -17,7 +17,7 @@ async def lifespan(app: FastAPI): config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, interceptors=[LangChainContextPropagationInterceptor()], ) yield diff --git a/langchain/worker.py b/langchain/worker.py index 161a6faa..b7fb7741 100644 --- a/langchain/worker.py +++ b/langchain/worker.py @@ -3,7 +3,7 @@ from activities import translate_phrase from langchain_interceptor import LangChainContextPropagationInterceptor from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from workflow import LangChainChildWorkflow, LangChainWorkflow diff --git a/message_passing/introduction/starter.py b/message_passing/introduction/starter.py index 944be2ba..aa5b8967 100644 --- a/message_passing/introduction/starter.py +++ b/message_passing/introduction/starter.py @@ -2,7 +2,7 @@ from typing import Optional from temporalio.client import Client, WorkflowUpdateStage -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.introduction import TASK_QUEUE from message_passing.introduction.workflows import ( diff --git a/message_passing/introduction/worker.py b/message_passing/introduction/worker.py index bdf8fec4..34974801 100644 --- a/message_passing/introduction/worker.py +++ b/message_passing/introduction/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.introduction import TASK_QUEUE diff --git a/message_passing/safe_message_handlers/starter.py b/message_passing/safe_message_handlers/starter.py index 53ac0ef6..9bc5c661 100644 --- a/message_passing/safe_message_handlers/starter.py +++ b/message_passing/safe_message_handlers/starter.py @@ -6,7 +6,7 @@ from temporalio import common from temporalio.client import Client, WorkflowHandle -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.safe_message_handlers.workflow import ( ClusterManagerAssignNodesToJobInput, diff --git a/message_passing/safe_message_handlers/worker.py b/message_passing/safe_message_handlers/worker.py index 5b8dc160..31e538d4 100644 --- a/message_passing/safe_message_handlers/worker.py +++ b/message_passing/safe_message_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.safe_message_handlers.workflow import ( diff --git a/message_passing/update_with_start/lazy_initialization/starter.py b/message_passing/update_with_start/lazy_initialization/starter.py index 537eede3..ec874939 100644 --- a/message_passing/update_with_start/lazy_initialization/starter.py +++ b/message_passing/update_with_start/lazy_initialization/starter.py @@ -9,7 +9,7 @@ WorkflowHandle, WorkflowUpdateFailedError, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.exceptions import ApplicationError from message_passing.update_with_start.lazy_initialization import TASK_QUEUE diff --git a/message_passing/update_with_start/lazy_initialization/worker.py b/message_passing/update_with_start/lazy_initialization/worker.py index ae48f8fa..1cc4f6ff 100644 --- a/message_passing/update_with_start/lazy_initialization/worker.py +++ b/message_passing/update_with_start/lazy_initialization/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.update_with_start.lazy_initialization import TASK_QUEUE, workflows diff --git a/message_passing/waiting_for_handlers/starter.py b/message_passing/waiting_for_handlers/starter.py index 48e9bee9..76829e0b 100644 --- a/message_passing/waiting_for_handlers/starter.py +++ b/message_passing/waiting_for_handlers/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers import ( TASK_QUEUE, diff --git a/message_passing/waiting_for_handlers/worker.py b/message_passing/waiting_for_handlers/worker.py index 11bc9f00..e32a2dcb 100644 --- a/message_passing/waiting_for_handlers/worker.py +++ b/message_passing/waiting_for_handlers/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers import TASK_QUEUE diff --git a/message_passing/waiting_for_handlers_and_compensation/starter.py b/message_passing/waiting_for_handlers_and_compensation/starter.py index 585d14b9..fbc5ae04 100644 --- a/message_passing/waiting_for_handlers_and_compensation/starter.py +++ b/message_passing/waiting_for_handlers_and_compensation/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio import client, common -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from message_passing.waiting_for_handlers_and_compensation import ( TASK_QUEUE, diff --git a/message_passing/waiting_for_handlers_and_compensation/worker.py b/message_passing/waiting_for_handlers_and_compensation/worker.py index 7ed1c040..2a27769d 100644 --- a/message_passing/waiting_for_handlers_and_compensation/worker.py +++ b/message_passing/waiting_for_handlers_and_compensation/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from message_passing.waiting_for_handlers_and_compensation import TASK_QUEUE diff --git a/nexus_multiple_args/caller/app.py b/nexus_multiple_args/caller/app.py index 83c10dea..b4d7ebc3 100644 --- a/nexus_multiple_args/caller/app.py +++ b/nexus_multiple_args/caller/app.py @@ -18,7 +18,8 @@ async def execute_caller_workflow( if client is None: config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") - client = await Client.connect(**config, namespace=NAMESPACE) + config.setdefault("namespace", NAMESPACE) + client = await Client.connect(**config) async with Worker( client, diff --git a/nexus_multiple_args/handler/worker.py b/nexus_multiple_args/handler/worker.py index d7da6132..079d08ae 100644 --- a/nexus_multiple_args/handler/worker.py +++ b/nexus_multiple_args/handler/worker.py @@ -21,8 +21,8 @@ async def main(client: Optional[Client] = None): if client is None: config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") - client = await Client.connect(**config, namespace=NAMESPACE) - + config.setdefault("namespace", NAMESPACE) + client = await Client.connect(**config) # Start the worker, passing the Nexus service handler instance, in addition to the # workflow classes that are started by your nexus operations, and any activities diff --git a/nexus_sync_operations/caller/app.py b/nexus_sync_operations/caller/app.py index 653d945d..375628d2 100644 --- a/nexus_sync_operations/caller/app.py +++ b/nexus_sync_operations/caller/app.py @@ -18,7 +18,8 @@ async def execute_caller_workflow( if client is None: config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") - client = await Client.connect(**config, namespace=NAMESPACE) + config.setdefault("namespace", NAMESPACE) + client = await Client.connect(**config) async with Worker( client, diff --git a/nexus_sync_operations/handler/worker.py b/nexus_sync_operations/handler/worker.py index 04cf377f..7783055a 100644 --- a/nexus_sync_operations/handler/worker.py +++ b/nexus_sync_operations/handler/worker.py @@ -22,7 +22,8 @@ async def main(client: Optional[Client] = None): if client is None: config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") - client = await Client.connect(**config, namespace=NAMESPACE) + config.setdefault("namespace", NAMESPACE), + client = await Client.connect(**config) # Create the nexus service handler instance, starting the long-running entity workflow that # backs the Nexus service diff --git a/open_telemetry/starter.py b/open_telemetry/starter.py index 9f1d82b8..9e8650b0 100644 --- a/open_telemetry/starter.py +++ b/open_telemetry/starter.py @@ -2,7 +2,7 @@ from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from open_telemetry.worker import GreetingWorkflow, init_runtime_with_telemetry @@ -14,7 +14,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/open_telemetry/worker.py b/open_telemetry/worker.py index 57454b69..631bd008 100644 --- a/open_telemetry/worker.py +++ b/open_telemetry/worker.py @@ -9,7 +9,7 @@ from temporalio import activity, workflow from temporalio.client import Client from temporalio.contrib.opentelemetry import TracingInterceptor -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -56,7 +56,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, # Use OpenTelemetry interceptor interceptors=[TracingInterceptor()], runtime=runtime, diff --git a/openai_agents/basic/run_agent_lifecycle_workflow.py b/openai_agents/basic/run_agent_lifecycle_workflow.py index 7f945171..2cd16c60 100644 --- a/openai_agents/basic/run_agent_lifecycle_workflow.py +++ b/openai_agents/basic/run_agent_lifecycle_workflow.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.agent_lifecycle_workflow import ( AgentLifecycleWorkflow, diff --git a/openai_agents/basic/run_remote_image_workflow.py b/openai_agents/basic/run_remote_image_workflow.py index 67783654..f2175f7f 100644 --- a/openai_agents/basic/run_remote_image_workflow.py +++ b/openai_agents/basic/run_remote_image_workflow.py @@ -2,7 +2,7 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.basic.workflows.remote_image_workflow import RemoteImageWorkflow @@ -12,7 +12,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config.to_client_connect_config(), + **config, plugins=[OpenAIAgentsPlugin()], ) diff --git a/openai_agents/handoffs/run_message_filter_workflow.py b/openai_agents/handoffs/run_message_filter_workflow.py index 6a4fba52..c2b2ba3d 100644 --- a/openai_agents/handoffs/run_message_filter_workflow.py +++ b/openai_agents/handoffs/run_message_filter_workflow.py @@ -3,7 +3,7 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import OpenAIAgentsPlugin -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from openai_agents.handoffs.workflows.message_filter_workflow import ( MessageFilterWorkflow, @@ -16,7 +16,7 @@ async def main(): # Create client connected to server at the given address client = await Client.connect( - **config.to_client_connect_config(), + **config, plugins=[ OpenAIAgentsPlugin(), ], diff --git a/openai_agents/mcp/run_file_system_worker.py b/openai_agents/mcp/run_file_system_worker.py index 90aead03..f7bd2909 100644 --- a/openai_agents/mcp/run_file_system_worker.py +++ b/openai_agents/mcp/run_file_system_worker.py @@ -7,12 +7,12 @@ from agents.mcp import MCPServerStdio from temporalio.client import Client -from temporalio.envconfig import ClientConfig from temporalio.contrib.openai_agents import ( ModelActivityParameters, OpenAIAgentsPlugin, StatelessMCPServerProvider, ) +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from openai_agents.mcp.workflows.file_system_workflow import FileSystemWorkflow @@ -37,7 +37,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_file_system_workflow.py b/openai_agents/mcp/run_file_system_workflow.py index 2322be0e..d076d3d5 100644 --- a/openai_agents/mcp/run_file_system_workflow.py +++ b/openai_agents/mcp/run_file_system_workflow.py @@ -12,7 +12,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config, plugins=[ OpenAIAgentsPlugin(), ], diff --git a/openai_agents/mcp/run_memory_research_scratchpad_worker.py b/openai_agents/mcp/run_memory_research_scratchpad_worker.py index c4033604..5e5f4b00 100644 --- a/openai_agents/mcp/run_memory_research_scratchpad_worker.py +++ b/openai_agents/mcp/run_memory_research_scratchpad_worker.py @@ -36,7 +36,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config, plugins=[ OpenAIAgentsPlugin( model_params=ModelActivityParameters( diff --git a/openai_agents/mcp/run_memory_research_scratchpad_workflow.py b/openai_agents/mcp/run_memory_research_scratchpad_workflow.py index c6ff2ed4..bf724f9a 100644 --- a/openai_agents/mcp/run_memory_research_scratchpad_workflow.py +++ b/openai_agents/mcp/run_memory_research_scratchpad_workflow.py @@ -15,7 +15,7 @@ async def main(): config = ClientConfig.load_client_connect_config() config.setdefault("target_host", "localhost:7233") client = await Client.connect( - **config, + **config, plugins=[ OpenAIAgentsPlugin(), ], diff --git a/patching/starter.py b/patching/starter.py index 44d746f6..f1b92f32 100644 --- a/patching/starter.py +++ b/patching/starter.py @@ -2,7 +2,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig # Since it's just used for typing purposes, it doesn't matter which one we # import diff --git a/patching/worker.py b/patching/worker.py index c5ab42a1..417c8ef9 100644 --- a/patching/worker.py +++ b/patching/worker.py @@ -2,7 +2,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from patching.activities import post_patch_activity, pre_patch_activity diff --git a/polling/frequent/run_frequent.py b/polling/frequent/run_frequent.py index f1ca8041..42048092 100644 --- a/polling/frequent/run_frequent.py +++ b/polling/frequent/run_frequent.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.frequent.workflows import GreetingWorkflow diff --git a/polling/frequent/run_worker.py b/polling/frequent/run_worker.py index 212bba64..cf5ccb78 100644 --- a/polling/frequent/run_worker.py +++ b/polling/frequent/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.frequent.activities import compose_greeting diff --git a/polling/infrequent/run_infrequent.py b/polling/infrequent/run_infrequent.py index baf6fea4..8a0ea871 100644 --- a/polling/infrequent/run_infrequent.py +++ b/polling/infrequent/run_infrequent.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.infrequent.workflows import GreetingWorkflow diff --git a/polling/infrequent/run_worker.py b/polling/infrequent/run_worker.py index ae535cb6..f52a8082 100644 --- a/polling/infrequent/run_worker.py +++ b/polling/infrequent/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.infrequent.activities import compose_greeting diff --git a/polling/periodic_sequence/run_periodic.py b/polling/periodic_sequence/run_periodic.py index d2166108..393fb8be 100644 --- a/polling/periodic_sequence/run_periodic.py +++ b/polling/periodic_sequence/run_periodic.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from polling.periodic_sequence.workflows import GreetingWorkflow diff --git a/polling/periodic_sequence/run_worker.py b/polling/periodic_sequence/run_worker.py index d34e8a79..9689ef2f 100644 --- a/polling/periodic_sequence/run_worker.py +++ b/polling/periodic_sequence/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from polling.periodic_sequence.activities import compose_greeting diff --git a/prometheus/starter.py b/prometheus/starter.py index 5be2a2a3..571aee07 100644 --- a/prometheus/starter.py +++ b/prometheus/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from prometheus.worker import GreetingWorkflow, init_runtime_with_prometheus @@ -16,7 +16,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) diff --git a/prometheus/worker.py b/prometheus/worker.py index 9a7d7841..b41b75c5 100644 --- a/prometheus/worker.py +++ b/prometheus/worker.py @@ -3,7 +3,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig from temporalio.worker import Worker @@ -44,7 +44,7 @@ async def main(): # Connect client client = await Client.connect( - **config.to_client_connect_config(), + **config, runtime=runtime, ) diff --git a/pydantic_converter/starter.py b/pydantic_converter/starter.py index ff3a2960..47766be6 100644 --- a/pydantic_converter/starter.py +++ b/pydantic_converter/starter.py @@ -5,7 +5,7 @@ from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from pydantic_converter.worker import MyPydanticModel, MyWorkflow @@ -19,7 +19,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter/worker.py b/pydantic_converter/worker.py index d519d23f..8acc1125 100644 --- a/pydantic_converter/worker.py +++ b/pydantic_converter/worker.py @@ -6,7 +6,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker # Always pass through external modules to the sandbox that you know are safe for @@ -48,7 +48,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/starter.py b/pydantic_converter_v1/starter.py index 5ed5a255..33b0ad28 100644 --- a/pydantic_converter_v1/starter.py +++ b/pydantic_converter_v1/starter.py @@ -4,7 +4,7 @@ from ipaddress import IPv4Address from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from pydantic_converter_v1.converter import pydantic_data_converter from pydantic_converter_v1.worker import MyPydanticModel, MyWorkflow @@ -19,7 +19,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index f5d140d6..5ff65e1e 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -7,7 +7,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -77,7 +77,7 @@ async def main(): # Connect client using the Pydantic converter client = await Client.connect( - **config.to_client_connect_config(), + **config, data_converter=pydantic_data_converter, ) diff --git a/replay/replayer.py b/replay/replayer.py index 285c7647..4787b33b 100644 --- a/replay/replayer.py +++ b/replay/replayer.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Replayer from replay.worker import JustActivity, JustTimer, TimerThenActivity diff --git a/replay/starter.py b/replay/starter.py index 1dc4fe57..228e50c3 100644 --- a/replay/starter.py +++ b/replay/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from replay.worker import JustActivity, JustTimer, TimerThenActivity diff --git a/replay/worker.py b/replay/worker.py index ab75327e..4ac57da2 100644 --- a/replay/worker.py +++ b/replay/worker.py @@ -5,7 +5,7 @@ from temporalio import activity, workflow from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker diff --git a/resource_pool/starter.py b/resource_pool/starter.py index 7aeb970d..2a50357a 100644 --- a/resource_pool/starter.py +++ b/resource_pool/starter.py @@ -3,7 +3,7 @@ from temporalio.client import Client, WorkflowFailureError, WorkflowHandle from temporalio.common import WorkflowIDConflictPolicy -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from resource_pool.pool_client.resource_pool_workflow import ( ResourcePoolWorkflow, diff --git a/resource_pool/worker.py b/resource_pool/worker.py index bd3f1e18..253e5f8e 100644 --- a/resource_pool/worker.py +++ b/resource_pool/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from resource_pool.pool_client.resource_pool_workflow import ResourcePoolWorkflow diff --git a/schedules/run_worker.py b/schedules/run_worker.py index 0dc1b951..00d14aaa 100644 --- a/schedules/run_worker.py +++ b/schedules/run_worker.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from your_activities import your_activity from your_workflows import YourSchedulesWorkflow diff --git a/schedules/start_schedule.py b/schedules/start_schedule.py index 31748874..ead6202b 100644 --- a/schedules/start_schedule.py +++ b/schedules/start_schedule.py @@ -9,7 +9,7 @@ ScheduleSpec, ScheduleState, ) -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from your_workflows import YourSchedulesWorkflow diff --git a/sentry/starter.py b/sentry/starter.py index c3f90f88..aa3f6271 100644 --- a/sentry/starter.py +++ b/sentry/starter.py @@ -1,7 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from sentry.workflow import SentryExampleWorkflow, SentryExampleWorkflowInput @@ -11,7 +11,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Connect client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run workflow try: diff --git a/sentry/worker.py b/sentry/worker.py index 8787d669..1bcd153e 100644 --- a/sentry/worker.py +++ b/sentry/worker.py @@ -5,7 +5,7 @@ from sentry_sdk.integrations.asyncio import AsyncioIntegration from sentry_sdk.types import Event, Hint from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from temporalio.worker.workflow_sandbox import ( SandboxedWorkflowRunner, @@ -18,6 +18,7 @@ interrupt_event = asyncio.Event() + def before_send(event: Event, hint: Hint) -> Event | None: # Filter out __ShutdownRequested events raised by the worker's internals if str(hint.get("exc_info", [None])[0].__name__) == "_ShutdownRequested": @@ -55,7 +56,7 @@ async def main(): config.setdefault("target_host", "localhost:7233") # Start client - client = await Client.connect(**config.to_client_connect_config()) + client = await Client.connect(**config) # Run a worker for the workflow async with Worker( diff --git a/sleep_for_days/starter.py b/sleep_for_days/starter.py index eca6fd29..98dc083d 100644 --- a/sleep_for_days/starter.py +++ b/sleep_for_days/starter.py @@ -3,7 +3,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from sleep_for_days import TASK_QUEUE from sleep_for_days.workflows import SleepForDaysWorkflow diff --git a/sleep_for_days/worker.py b/sleep_for_days/worker.py index 7176cc31..59799607 100644 --- a/sleep_for_days/worker.py +++ b/sleep_for_days/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from sleep_for_days import TASK_QUEUE diff --git a/trio_async/starter.py b/trio_async/starter.py index 177b01f6..6535ca98 100644 --- a/trio_async/starter.py +++ b/trio_async/starter.py @@ -2,7 +2,7 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from trio_async import workflows diff --git a/trio_async/worker.py b/trio_async/worker.py index 55f30b20..f1c2a30b 100644 --- a/trio_async/worker.py +++ b/trio_async/worker.py @@ -5,7 +5,7 @@ import trio_asyncio from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from trio_async import activities, workflows diff --git a/updatable_timer/starter.py b/updatable_timer/starter.py index b3d66dd9..8ce0f4f9 100644 --- a/updatable_timer/starter.py +++ b/updatable_timer/starter.py @@ -5,7 +5,7 @@ from temporalio import exceptions from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from updatable_timer import TASK_QUEUE from updatable_timer.workflow import Workflow diff --git a/updatable_timer/wake_up_time_updater.py b/updatable_timer/wake_up_time_updater.py index 5f3e37c9..43d24838 100644 --- a/updatable_timer/wake_up_time_updater.py +++ b/updatable_timer/wake_up_time_updater.py @@ -4,7 +4,7 @@ from typing import Optional from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from updatable_timer.workflow import Workflow diff --git a/updatable_timer/worker.py b/updatable_timer/worker.py index 551b8532..8bb3d47a 100644 --- a/updatable_timer/worker.py +++ b/updatable_timer/worker.py @@ -2,7 +2,7 @@ import logging from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from updatable_timer import TASK_QUEUE diff --git a/worker_specific_task_queues/starter.py b/worker_specific_task_queues/starter.py index 93a0e3eb..61009436 100644 --- a/worker_specific_task_queues/starter.py +++ b/worker_specific_task_queues/starter.py @@ -2,7 +2,7 @@ from uuid import uuid4 from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from worker_specific_task_queues.tasks import FileProcessing diff --git a/worker_specific_task_queues/worker.py b/worker_specific_task_queues/worker.py index bda59f00..95824cfd 100644 --- a/worker_specific_task_queues/worker.py +++ b/worker_specific_task_queues/worker.py @@ -6,7 +6,7 @@ from temporalio import activity from temporalio.client import Client -from temporalio.envconfig import ClientConfigProfile +from temporalio.envconfig import ClientConfig from temporalio.worker import Worker from worker_specific_task_queues import tasks From 8e751c548087b625a31a95df5034475b6a83e7b0 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 10 Nov 2025 10:45:40 -0800 Subject: [PATCH 14/14] remove redundant files/code --- encryption/starter.py | 9 --------- encryption/worker.py | 9 --------- temporal.toml | 4 ---- util.py | 16 ---------------- 4 files changed, 38 deletions(-) delete mode 100644 temporal.toml delete mode 100644 util.py diff --git a/encryption/starter.py b/encryption/starter.py index 8caf764b..f2570936 100644 --- a/encryption/starter.py +++ b/encryption/starter.py @@ -22,15 +22,6 @@ async def main(): ), ) - # Connect client - client = await Client.connect( - **config, - # Use the default converter, but change the codec - data_converter=dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() - ), - ) - # Run workflow result = await client.execute_workflow( GreetingWorkflow.run, diff --git a/encryption/worker.py b/encryption/worker.py index c0cb68b1..d3387c70 100644 --- a/encryption/worker.py +++ b/encryption/worker.py @@ -32,15 +32,6 @@ async def main(): ), ) - # Connect client - client = await Client.connect( - **config, - # Use the default converter, but change the codec - data_converter=dataclasses.replace( - temporalio.converter.default(), payload_codec=EncryptionCodec() - ), - ) - # Run a worker for the workflow async with Worker( client, diff --git a/temporal.toml b/temporal.toml deleted file mode 100644 index df78a1ab..00000000 --- a/temporal.toml +++ /dev/null @@ -1,4 +0,0 @@ -# Default profile for local development -[profile.default] -address = "localhost:7233" -namespace = "default" \ No newline at end of file diff --git a/util.py b/util.py deleted file mode 100644 index b15a68d0..00000000 --- a/util.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Utility module -""" -from pathlib import Path - - -def get_temporal_config_path() -> Path: - """ - Get the path to the temporal.toml configuration file. - - This assumes the temporal.toml file is in the root of the samples-python repository. - - Returns: - Path to temporal.toml - """ - return Path(__file__).resolve().parent / "temporal.toml"