Skip to content

Commit ffe0d78

Browse files
simplify
1 parent 7658256 commit ffe0d78

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

src/agentex/lib/cli/templates/temporal/README.md.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ result = await workflow.execute_activity(
283283
heartbeat_timeout=timedelta(minutes=1), # Optional: heartbeat monitoring
284284
retry_policy=RetryPolicy(maximum_attempts=3) # Optional: retry policy
285285
)
286+
287+
# Don't forget to register your custom activities in run_worker.py:
288+
# all_activities = get_all_activities() + [your_custom_activity_function]
286289
```
287290

288291
### Integration with External Services

src/agentex/lib/cli/templates/temporal/project/run_worker.py.j2

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import asyncio
2-
import importlib.util
3-
import sys
4-
from pathlib import Path
52

63
from agentex.lib.core.temporal.activities import get_all_activities
74
from agentex.lib.core.temporal.workers.worker import AgentexWorker
@@ -17,29 +14,6 @@ environment_variables = EnvironmentVariables.refresh()
1714
logger = make_logger(__name__)
1815

1916

20-
def load_custom_activities():
21-
"""Load custom activities from project/activities.py if it exists"""
22-
activities_path = Path(__file__).parent / "activities.py"
23-
custom_activities = []
24-
25-
if activities_path.exists():
26-
logger.info(f"Loading custom activities from {activities_path}")
27-
spec = importlib.util.spec_from_file_location("project.activities", activities_path)
28-
if spec and spec.loader:
29-
module = importlib.util.module_from_spec(spec)
30-
sys.modules["project.activities"] = module
31-
spec.loader.exec_module(module)
32-
33-
# Find all activity functions (decorated with @activity.defn)
34-
for name in dir(module):
35-
obj = getattr(module, name)
36-
if callable(obj) and hasattr(obj, "__temporal_activity_definition__"):
37-
custom_activities.append(obj)
38-
logger.info(f" - Registered custom activity: {name}")
39-
40-
return custom_activities
41-
42-
4317
async def main():
4418
# Setup debug mode if enabled
4519
setup_debug_if_enabled()
@@ -48,10 +22,7 @@ async def main():
4822
if task_queue_name is None:
4923
raise ValueError("WORKFLOW_TASK_QUEUE is not set")
5024

51-
# Load all activities (both core and custom)
52-
all_activities = get_all_activities()
53-
custom_activities = load_custom_activities()
54-
all_activities.extend(custom_activities)
25+
all_activities = get_all_activities() + [] # add your own activities here
5526

5627
# Create a worker with automatic tracing
5728
worker = AgentexWorker(

0 commit comments

Comments
 (0)