MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _create_run_yaml

Function _create_run_yaml

demo/ai_scientists/web/app.py:155–189  ·  view source on GitHub ↗

Create a per-run YAML from the base template, patching domain, intent & paths.

(run_id: str, domain: str, intent: str)

Source from the content-addressed store, hash-verified

153# ---------------------------------------------------------------------------
154
155def _create_run_yaml(run_id: str, domain: str, intent: str) -> tuple[str, str]:
156 """Create a per-run YAML from the base template, patching domain, intent & paths."""
157 base_text = BASE_YAML.read_text(encoding="utf-8")
158
159 task_name = f"ai_scientists_web_{run_id[:8]}"
160 output_dir = f"/workspace/outputs/{task_name}"
161
162 patched = re.sub(
163 r'^(name:\s*)".+"', f'\\1"{task_name}"',
164 base_text, count=1, flags=re.MULTILINE,
165 )
166 patched = re.sub(
167 r'^(\s*domain:\s*)".+"', f'\\1"{domain}"',
168 patched, count=1, flags=re.MULTILINE,
169 )
170 patched = re.sub(
171 r'^(\s*intent:\s*)".+"', f'\\1"{intent}"',
172 patched, count=1, flags=re.MULTILINE,
173 )
174 patched = re.sub(
175 r'^(\s*output_dir:\s*)".+"', f'\\1"{output_dir}"',
176 patched, count=1, flags=re.MULTILINE,
177 )
178 # Patch memory_file to use the run-specific output dir (full YAML only)
179 patched = re.sub(
180 r'^(\s*memory_file:\s*)".+"',
181 f'\\1"{output_dir}/writer/memory.json"',
182 patched, count=1, flags=re.MULTILINE,
183 )
184
185 run_dir = PROJECT_ROOT / "outputs" / "_ui_runs"
186 run_dir.mkdir(parents=True, exist_ok=True)
187 yaml_path = run_dir / f"{task_name}.yaml"
188 yaml_path.write_text(patched, encoding="utf-8")
189 return str(yaml_path), task_name
190
191
192# ---------------------------------------------------------------------------

Callers 1

api_generateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected