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
5 changes: 4 additions & 1 deletion activity_worker/activity_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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"
Expand All @@ -18,7 +19,9 @@ async def say_hello_activity(name: str) -> str:

async def main():
# Create client to localhost on default namespace
client = await Client.connect("localhost:7233")
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]):
Expand Down
5 changes: 4 additions & 1 deletion batch_sliding_window/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

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

# Create client
client = await Client.connect("localhost:7233")
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")
Expand Down
5 changes: 4 additions & 1 deletion batch_sliding_window/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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
Expand All @@ -19,7 +20,9 @@ async def main():
logging.basicConfig(level=logging.INFO)

# Create client
client = await Client.connect("localhost:7233")
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)
Expand Down
6 changes: 5 additions & 1 deletion bedrock/basic/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker
from workflows import BasicBedrockWorkflow

Expand All @@ -11,7 +12,10 @@

async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

activities = BedrockActivities()

# Run the worker
Expand Down
5 changes: 4 additions & 1 deletion bedrock/basic/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import sys

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import BasicBedrockWorkflow


async def main(prompt: str) -> str:
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
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"
Expand Down
5 changes: 4 additions & 1 deletion bedrock/entity/end_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import sys

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import EntityBedrockWorkflow


async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

workflow_id = "entity-bedrock-workflow"

Expand Down
6 changes: 5 additions & 1 deletion bedrock/entity/get_history.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import asyncio

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import EntityBedrockWorkflow


async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

workflow_id = "entity-bedrock-workflow"

handle = client.get_workflow_handle(workflow_id)
Expand Down
6 changes: 5 additions & 1 deletion bedrock/entity/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker
from workflows import EntityBedrockWorkflow

Expand All @@ -11,7 +12,10 @@

async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

activities = BedrockActivities()

# Run the worker
Expand Down
5 changes: 4 additions & 1 deletion bedrock/entity/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import sys

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import BedrockParams, EntityBedrockWorkflow


async def main(prompt):
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

workflow_id = "entity-bedrock-workflow"

Expand Down
6 changes: 5 additions & 1 deletion bedrock/signals_and_queries/get_history.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import asyncio

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import SignalQueryBedrockWorkflow


async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

workflow_id = "bedrock-workflow-with-signals"

handle = client.get_workflow_handle(workflow_id)
Expand Down
6 changes: 5 additions & 1 deletion bedrock/signals_and_queries/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker
from workflows import SignalQueryBedrockWorkflow

Expand All @@ -11,7 +12,10 @@

async def main():
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

activities = BedrockActivities()

# Run the worker
Expand Down
5 changes: 4 additions & 1 deletion bedrock/signals_and_queries/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import sys

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import SignalQueryBedrockWorkflow


async def main(prompt):
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
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
Expand Down
6 changes: 5 additions & 1 deletion cloud_export_to_parquet/create_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ScheduleSpec,
WorkflowFailureError,
)
from temporalio.envconfig import ClientConfig

from cloud_export_to_parquet.workflows import (
ProtoToParquet,
Expand All @@ -20,7 +21,10 @@
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")
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(
num_delay_hour=2,
Expand Down
5 changes: 4 additions & 1 deletion cloud_export_to_parquet/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,7 +19,9 @@
async def main() -> None:
"""Main worker function."""
# Create client connected to server at the given address
client = await Client.connect("localhost:7233")
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)

# Run the worker
worker: Worker = Worker(
Expand Down
6 changes: 5 additions & 1 deletion context_propagation/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

from context_propagation import interceptor, shared, workflows

Expand All @@ -12,9 +13,12 @@ async def main():
# Set the user ID
shared.user_id.set("some-user")

config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")

# Connect client
client = await Client.connect(
"localhost:7233",
**config,
# Use our interceptor
interceptors=[interceptor.ContextPropagationInterceptor()],
)
Expand Down
6 changes: 5 additions & 1 deletion context_propagation/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker

from context_propagation import activities, interceptor, workflows
Expand All @@ -12,9 +13,12 @@
async def main():
logging.basicConfig(level=logging.INFO)

config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")

# Connect client
client = await Client.connect(
"localhost:7233",
**config,
# Use our interceptor
interceptors=[interceptor.ContextPropagationInterceptor()],
)
Expand Down
6 changes: 5 additions & 1 deletion custom_converter/starter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

from custom_converter.shared import (
GreetingInput,
Expand All @@ -11,9 +12,12 @@


async def main():
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")

# Connect client
client = await Client.connect(
"localhost:7233",
**config,
# Without this we get:
# TypeError: Object of type GreetingInput is not JSON serializable
data_converter=greeting_data_converter,
Expand Down
6 changes: 5 additions & 1 deletion custom_converter/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Worker

from custom_converter.shared import greeting_data_converter
Expand All @@ -10,9 +11,12 @@


async def main():
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")

# Connect client
client = await Client.connect(
"localhost:7233",
**config,
# Without this, when trying to run a workflow, we get:
# KeyError: 'Unknown payload encoding my-greeting-encoding
data_converter=greeting_data_converter,
Expand Down
5 changes: 4 additions & 1 deletion custom_decorator/starter.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import asyncio

from temporalio.client import Client
from temporalio.envconfig import ClientConfig

from custom_decorator.worker import WaitForCancelWorkflow


async def main():
# Connect client
client = await Client.connect("localhost:7233")
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(
Expand Down
5 changes: 4 additions & 1 deletion custom_decorator/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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
Expand Down Expand Up @@ -51,7 +52,9 @@ def cancel_activity(self) -> None:

async def main():
# Connect client
client = await Client.connect("localhost:7233")
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(
Expand Down
Loading
Loading