Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
strategy:
fail-fast: true
matrix:
python: ["3.10", "3.13"]
python: ["3.10", "3.14"]
os: [ubuntu-latest, macos-intel, macos-arm, windows-latest]
include:
- os: macos-intel
runsOn: macos-13
runsOn: macos-15-intel
- os: macos-arm
runsOn: macos-14
runsOn: macos-latest
runs-on: ${{ matrix.runsOn || matrix.os }}
steps:
- uses: astral-sh/setup-uv@v5
Expand Down
1 change: 0 additions & 1 deletion bedrock/basic/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class BasicBedrockWorkflow:
@workflow.run
async def run(self, prompt: str) -> str:

workflow.logger.info("Prompt: %s" % prompt)

response = await workflow.execute_activity_method(
Expand Down
1 change: 0 additions & 1 deletion bedrock/entity/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async def run(
self,
params: BedrockParams,
) -> str:

if params and params.conversation_summary:
self.conversation_history.append(
("conversation_summary", params.conversation_summary)
Expand Down
2 changes: 1 addition & 1 deletion cloud_export_to_parquet/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
with workflow.unsafe.imports_passed_through():
from cloud_export_to_parquet.data_trans_activities import (
DataTransAndLandActivityInput,
GetObjectKeysActivityInput,
data_trans_and_land,
get_object_keys,
GetObjectKeysActivityInput,
)
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion custom_converter/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self) -> None:
# Just add ours as first before the defaults
super().__init__(
GreetingEncodingPayloadConverter(),
*DefaultPayloadConverter.default_encoding_payload_converters
*DefaultPayloadConverter.default_encoding_payload_converters,
)


Expand Down
1 change: 0 additions & 1 deletion custom_metric/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def intercept_activity(

class CustomScheduleToStartInterceptor(ActivityInboundInterceptor):
async def execute_activity(self, input: ExecuteActivityInput):

schedule_to_start = (
activity.info().started_time
- activity.info().current_attempt_scheduled_time
Expand Down
1 change: 0 additions & 1 deletion eager_wf_start/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


async def main():

# Note that the worker and client run in the same process and share the same client connection.
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
Expand Down
1 change: 0 additions & 1 deletion env_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

2 changes: 0 additions & 2 deletions gevent_async/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async def async_main():
# running this async main. The max_workers here needs to have enough room to
# support the max concurrent activities/workflows settings.
with GeventExecutor(max_workers=200) as executor:

# Run a worker for the workflow and activities
async with Worker(
client,
Expand All @@ -68,7 +67,6 @@ async def async_main():
max_concurrent_activities=100,
max_concurrent_workflow_tasks=100,
):

# Wait until interrupted
logging.info("Worker started, ctrl+c to exit")
await interrupt_event.wait()
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ async def main():
# This same thread pool could be passed to multiple workers if desired.
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async def main():
# to supply an activity executor because they run in
# the worker's event loop.
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ async def main():
activities=[order_apples, order_bananas, order_cherries, order_oranges],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def main():
workflows=[MyWorkflow],
activities=[my_activities.do_database_thing],
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async def main():
multiprocessing.Manager()
),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_activity_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_async_activity_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ async def main():
workflows=[GreetingWorkflow],
activities=[composer.compose_greeting],
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ async def main():
activities=[never_complete_activity, cleanup_activity],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to start the workflow.
# Note, in many production setups, the client would be in a completely
# separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_child_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ async def main():
task_queue="hello-child-workflow-task-queue",
workflows=[GreetingWorkflow, ComposeGreetingWorkflow],
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_continue_as_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async def main():
task_queue="hello-continue-as-new-task-queue",
workflows=[LoopingWorkflow],
):

# While the worker is running, use the client to run the workflow. Note,
# in many production setups, the client would be in a completely
# separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

print("Running workflow once a minute")

# While the worker is running, use the client to start the workflow.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_local_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_mtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ async def main():
activities=[compose_greeting],
activity_executor=ThreadPoolExecutor(5),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_parallel_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async def main():
activities=[say_hello_activity],
activity_executor=ThreadPoolExecutor(10),
):

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async def main():
task_queue="hello-query-task-queue",
workflows=[GreetingWorkflow],
):

# While the worker is running, use the client to start the workflow.
# Note, in many production setups, the client would be in a completely
# separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_search_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ async def main():
task_queue="hello-search-attributes-task-queue",
workflows=[GreetingWorkflow],
):

# While the worker is running, use the client to start the workflow.
# Note, in many production setups, the client would be in a completely
# separate process from the worker.
Expand Down
1 change: 0 additions & 1 deletion hello/hello_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ async def main():
task_queue="hello-signal-task-queue",
workflows=[GreetingWorkflow],
):

# While the worker is running, use the client to start the workflow.
# Note, in many production setups, the client would be in a completely
# separate process from the worker.
Expand Down
4 changes: 3 additions & 1 deletion message_passing/waiting_for_handlers/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ async def _check_run(
wait_for_stage=client.WorkflowUpdateStage.ACCEPTED,
)
except Exception as e:
print(f" 🔴 caught exception while starting update: {e}: {e.__cause__ or ''}")
print(
f" 🔴 caught exception while starting update: {e}: {e.__cause__ or ''}"
)

if exit_type == WorkflowExitType.CANCELLATION:
await wf_handle.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ async def _check_run(
wait_for_stage=client.WorkflowUpdateStage.ACCEPTED,
)
except Exception as e:
print(f" 🔴 caught exception while starting update: {e}: {e.__cause__ or ''}")
print(
f" 🔴 caught exception while starting update: {e}: {e.__cause__ or ''}"
)

if exit_type == WorkflowExitType.CANCELLATION:
await wf_handle.cancel()
Expand Down
2 changes: 1 addition & 1 deletion nexus_sync_operations/handler/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def main(client: Optional[Client] = None):
if client is None:
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
config.setdefault("namespace", NAMESPACE),
config.setdefault("namespace", NAMESPACE)
client = await Client.connect(**config)

# Create the nexus service handler instance, starting the long-running entity workflow that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ async def run(self, tool_use_behavior: str = "default") -> str:
config = RunConfig()

if tool_use_behavior == "default":
behavior: Literal[
"run_llm_again", "stop_on_first_tool"
] | ToolsToFinalOutputFunction = "run_llm_again"
behavior: (
Literal["run_llm_again", "stop_on_first_tool"]
| ToolsToFinalOutputFunction
) = "run_llm_again"
elif tool_use_behavior == "first_tool":
behavior = "stop_on_first_tool"
elif tool_use_behavior == "custom":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class FinalResult(BaseModel):
class AgentLifecycleWorkflow:
@workflow.run
async def run(self, max_number: int) -> FinalResult:

multiply_agent = Agent(
name="Multiply Agent",
instructions="Multiply the number by 2 and then return the final result.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class DynamicSystemPromptWorkflow:
@workflow.run
async def run(self, user_message: str, style: Optional[str] = None) -> str:
if style is None:
selected_style: Literal[
"haiku", "pirate", "robot"
] = workflow.random().choice(["haiku", "pirate", "robot"])
selected_style: Literal["haiku", "pirate", "robot"] = (
workflow.random().choice(["haiku", "pirate", "robot"])
)
else:
# Validate that the provided style is one of the allowed values
if style not in ["haiku", "pirate", "robot"]:
Expand Down
6 changes: 3 additions & 3 deletions openai_agents/customer_service/customer_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ async def on_seat_booking_handoff(
### AGENTS


def init_agents() -> Tuple[
Agent[AirlineAgentContext], Dict[str, Agent[AirlineAgentContext]]
]:
def init_agents() -> (
Tuple[Agent[AirlineAgentContext], Dict[str, Agent[AirlineAgentContext]]]
):
"""
Initialize the agents for the airline customer service workflow.
:return: triage agent
Expand Down
16 changes: 7 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }]
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = ["temporalio>=1.19.0,<2"]
dependencies = ["temporalio>=1.20.0,<2"]

[project.urls]
Homepage = "https://github.com/temporalio/samples-python"
Expand All @@ -16,8 +16,7 @@ Documentation = "https://docs.temporal.io/docs/python"

[dependency-groups]
dev = [
"black>=22.3.0,<23",
"isort>=5.10.1,<6",
"ruff>=0.5.0,<0.6",
"mypy>=1.4.1,<2",
"pytest>=7.1.2,<8",
"pytest-asyncio>=0.18.3,<0.19",
Expand All @@ -37,7 +36,7 @@ encryption = [
"cryptography>=38.0.1,<39",
"aiohttp>=3.8.1,<4",
]
gevent = ["gevent==25.4.2 ; python_version >= '3.8'"]
gevent = ["gevent>=25.4.2 ; python_version >= '3.8'"]
langchain = [
"langchain>=0.1.7,<0.2 ; python_version >= '3.8.1' and python_version < '4.0'",
"langchain-openai>=0.0.6,<0.0.7 ; python_version >= '3.8.1' and python_version < '4.0'",
Expand Down Expand Up @@ -119,8 +118,8 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poe.tasks]
format = [{cmd = "uv run black ."}, {cmd = "uv run isort ."}]
lint = [{cmd = "uv run black --check ."}, {cmd = "uv run isort --check-only ."}, {ref = "lint-types" }]
format = [{cmd = "uv run ruff check --select I --fix"}, {cmd = "uv run ruff format"}]
lint = [{cmd = "uv run ruff check --select I"}, {cmd = "uv run ruff format --check"}, {ref = "lint-types"}]
lint-types = "uv run --all-groups mypy --check-untyped-defs --namespace-packages ."
test = "uv run --all-groups pytest"

Expand All @@ -130,9 +129,8 @@ log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"

[tool.isort]
profile = "black"
skip_gitignore = true
[tool.ruff]
target-version = "py310"

[tool.mypy]
ignore_missing_imports = true
Expand Down
2 changes: 2 additions & 0 deletions sentry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This sample shows how to configure [Sentry](https://sentry.io) SDK (version 2) to intercept and capture errors from the Temporal SDK
for workflows and activities. The integration adds some useful context to the errors, such as the activity type, task queue, etc.

Note: Sentry currently does not support Python 3.14, likewise this sample does not support Python 3.14.

## Further details

This is a small modification of the original example Sentry integration in this repo based on SDK v1. The integration
Expand Down
1 change: 0 additions & 1 deletion tests/hello/hello_change_log_level_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


async def test_workflow_with_log_capture(client: Client):

log_stream = io.StringIO()
handler = logging.StreamHandler(log_stream)
handler.setLevel(logging.ERROR)
Expand Down
Loading
Loading