mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-23 00:15:20 +02:00
add script to run all tasks in task file
This commit is contained in:
parent
57be4ec42e
commit
a6cb062862
1 changed files with 58 additions and 0 deletions
58
tasks/run_task_file.py
Normal file
58
tasks/run_task_file.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
# run all tasks in a given file
|
||||
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
def run_task(task_path, task_id, profiles=None):
|
||||
"""Run a single task using main.js"""
|
||||
# Convert task_path to absolute path if it's relative
|
||||
if not os.path.isabs(task_path):
|
||||
task_path = os.path.abspath(task_path)
|
||||
|
||||
cmd = ["node", "main.js", "--task_path", task_path, "--task_id", task_id]
|
||||
|
||||
# Add profiles if provided
|
||||
if profiles:
|
||||
cmd.extend(["--profiles", *profiles])
|
||||
|
||||
print(f"Running task: {task_id}")
|
||||
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Execute the command from the project root directory
|
||||
process = subprocess.run(cmd, check=True, cwd=project_root)
|
||||
|
||||
return process.returncode == 0
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Run all tasks in a JSON file sequentially')
|
||||
parser.add_argument('--task_path', required=True, help='Path to the task file')
|
||||
parser.add_argument('--profiles', nargs='+', help='List of agent profile paths')
|
||||
parser.add_argument('--delay', type=int, default=2, help='Delay in seconds between tasks')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Load the task file
|
||||
with open(args.task_path, 'r') as f:
|
||||
tasks = json.load(f)
|
||||
|
||||
print(f"Found {len(tasks)} tasks in {args.task_path}")
|
||||
|
||||
# Run each task sequentially
|
||||
successful_tasks = 0
|
||||
for task_id in tasks:
|
||||
success = run_task(args.task_path, task_id, args.profiles)
|
||||
if success:
|
||||
successful_tasks += 1
|
||||
|
||||
# Wait between tasks
|
||||
time.sleep(args.delay)
|
||||
|
||||
print(f"Completed {successful_tasks}/{len(tasks)} tasks successfully")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Add table
Reference in a new issue