Repository navigation
Expand file tree
/
Copy pathtrigger.py
More file actions
54 lines (43 loc) · 1.82 KB
/
Copy pathtrigger.py
File metadata and controls
54 lines (43 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Start a factory run on your deployed workflow service, through the Render API.
python scripts/trigger.py examples/issues/01-word-count-hyphens.json
python scripts/trigger.py examples/issues/*.json --concurrency 3 # factory_many
python scripts/trigger.py examples/issues/01-word-count-hyphens.json --wait
Needs RENDER_API_KEY. WORKFLOW_SLUG defaults to openhands-render, the service
name in render.yaml. Against `render workflows dev`, set RENDER_USE_LOCAL_DEV=true.
"""
from __future__ import annotations
import argparse
import asyncio
import json
import os
from pathlib import Path
from render import RenderAsync
async def main() -> None:
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument("issues", nargs="+", help="issue JSON files")
parser.add_argument(
"--concurrency", type=int, default=4, help="parallel issues for factory_many"
)
parser.add_argument("--wait", action="store_true", help="wait for the run and print its result")
args = parser.parse_args()
slug = os.environ.get("WORKFLOW_SLUG", "openhands-render")
issues = [json.loads(Path(p).read_text()) for p in args.issues]
if len(issues) == 1:
task, data = f"{slug}/factory", [issues[0]]
else:
task, data = f"{slug}/factory_many", [issues, args.concurrency]
render = RenderAsync()
run = await render.workflows.start_task(task, data)
print(f"started {task}: {run.id}")
print("follow it in the Dashboard (your workflow → Runs), or rerun with --wait")
if args.wait:
details = await run
print(
json.dumps(
{"status": str(details.status), "results": details.results}, indent=2, default=str
)
)
if __name__ == "__main__":
asyncio.run(main())