Add finetune MCP server with real training path, mock toggle, templates and CLI demo - #1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fca1d2f61e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| run_dir = Path("./data/finetune/runs") / run_id | ||
| run_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| replacements = {"{{MODEL_ID}}": normalized_model_id, "{{DATASET_PATH}}": dataset_path} | ||
| for src in template_root.iterdir(): |
There was a problem hiding this comment.
Resolve dataset_path before writing template config
The dataset download tool returns local_path as a repo‑relative path (e.g., data/finetune/datasets/...), and _prepare_template writes that value directly into the template config via the {{DATASET_PATH}} replacement. When a real job runs, _run_job executes train.py with cwd=run_dir, so that relative path gets resolved under the run directory (e.g., data/finetune/runs/<id>/data/finetune/datasets/...) and datasets.load_dataset will fail with “file not found” unless the caller provided an absolute path. To avoid real finetune runs breaking on the normal tool flow, resolve to an absolute path or rewrite the dataset path relative to run_dir before templating.
Useful? React with 👍 / 👎.
Motivation
CentralAgent/NodeAgentto discover and use tools from multiple MCP servers and make the finetune pipeline runnable from the CLI without external orchestration.functiongemmarepo while keeping a safe mock fallback for demos.Description
mcp_servers/finetune_serverimplementingserver.py(tool handlers),job_store.py(SQLite-backed job/events store), and__main__.pyfor stdio transport, plus a JSON-stable helper and_normalize_model_idthat readsFUNCTIONGEMMA_HF_REPOfrom env.apps/finetune_workflow/templates/basewithtrain.py(usestransformers,datasets,peft) andconfig.json, and ascripts/run_finetune_demo.pyCLI that wiresmock_modeinto the sandbox run input.core/mcp/config.py, addingMCPServerManager.list_server_ids(), and changingNodeAgentto aggregate MCP tool catalogs across all servers; also added API endpoints/v1/finetune/jobs/{job_id}and/v1/finetune/jobs/{job_id}/eventsinapps/api/main.py.data/agent_specs/finetune_planner.json,data/agent_specs/finetune_monitor.json,data/schemas/finetune_*.json,data/workflow_archetypes/finetune_llm_auto_v1.json, and a concrete workflow), updatedrequirements.txtwith training-related libs, and addedtests/test_finetune_mcp.pyexercising the mock lifecycle.Testing
tests/test_finetune_mcp.pythat exercises the mocked finetune lifecycle (list_models->search_datasets->download_dataset->prepare_template->start_job->wait_for_job->run_evaluation).Codex Task