activity-core/src/activity_core/workflows.py

58 lines
1.6 KiB
Python
Raw Normal View History

"""Temporal workflow definitions for activity-core.
Two workflows are registered here:
- RunActivityWorkflow orchestrator-tq
- TaskExecutorWorkflow task-execution-tq
Workflow IDs follow the conventions in docs/conventions.md:
RunActivityWorkflow: activity-{activity_id}:{trigger_key}
TaskExecutorWorkflow: task-{run_id}:{task_type}:{index}
Implementations are added in T18T19; stubs here let the worker
register and the type system resolve references in T14T17.
"""
from __future__ import annotations
from datetime import timedelta
from temporalio import workflow
with workflow.unsafe.imports_passed_through():
from activity_core.activities import (
load_activity_definition,
log_run,
resolve_context,
)
_DEFAULT_TIMEOUT = timedelta(minutes=5)
@workflow.defn
class RunActivityWorkflow:
"""Durable orchestration workflow.
Sequence (T18):
1. load_activity_definition(activity_id)
2. resolve_context(context_sources)
3. evaluate_templates(task_templates, context) pure function, no activity
4. spawn TaskExecutorWorkflow child per template result
5. log_run(...)
"""
@workflow.run
async def run(self, activity_id: str, trigger_key: str) -> dict:
raise NotImplementedError("T18")
@workflow.defn
class TaskExecutorWorkflow:
"""Child workflow that executes one concrete task instance.
Stub implementation in T19.
"""
@workflow.run
async def run(self, run_id: str, task_type: str, params: dict) -> dict:
raise NotImplementedError("T19")