feat: add Experiment.export() to write runnable scripts without submitting#466
Open
feat: add Experiment.export() to write runnable scripts without submitting#466
Conversation
…tting Adds `Experiment.export(output_dir)` which writes one script per job into a self-contained directory plus a `submit_all.sh` launcher, enabling users to inspect, version, and manually submit jobs without going through the NeMo Run execution pipeline. Each scheduler's `_submit_dryrun()` now writes its script to `executor.experiment_dir` when set: - LocalExecutor → <task>.sh (executable bash) - DockerExecutor → <task>.yaml - SkypilotExecutor / SkypilotJobsExecutor → <task>.yaml - LeptonExecutor → <task>.sh (executable bash) - DGXCloudExecutor → <task>_torchrun_job.sh (was hardcoded, now uses job_name) `Experiment.export()` redirects all executor experiment_dirs to output_dir, runs dryrun to trigger script writing, then generates submit_all.sh with the correct submit command per executor type (sbatch, sky launch, etc.). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
…t tasks Demonstrates Experiment.export() across all common executor types: - export_local.py — single LocalExecutor job → .sh + submit_all.sh - export_multi_job.py — three-job pipeline (preprocess/train/evaluate) - export_script.py — run.Script (inline bash) tasks - export_slurm.py — two SlurmExecutor jobs → *_sbatch.sh; no cluster needed - export_dgxcloud.py — DGXCloudExecutor job → *_torchrun_job.sh; no API calls needed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
…nd Script tasks" This reverts commit 9a6c46c. Signed-off-by: oliver könig <okoenig@nvidia.com>
Addresses CodeQL finding: overly permissive chmod 0o755 made generated scripts world-readable/executable. Changed to 0o750 in local.py, lepton.py, and the submit_all.sh writer in experiment.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
_submit_dryrun() was unconditionally writing torchrun_job.sh, crashing with AttributeError when job_name is unset (executor not yet assigned to an experiment). Guard with `if executor.experiment_dir:` consistent with all other schedulers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
- Change chmod from 0o750 to 0o700 in local.py, lepton.py, and experiment.py to silence CodeQL "overly permissive" findings - Fix _write_submit_script to handle JobGroup (uses job.executors, not the nonexistent job.jobs attribute) - Add test_lepton.py (new file) covering create_scheduler, _submit_dryrun, file write, and no-write-without-experiment_dir - Add test_submit_dryrun_writes_script/yaml to dgxcloud, docker, local, skypilot, and skypilot_jobs scheduler tests - Add test_experiment_export_job_group covering the JobGroup branch in Experiment.export() - Fix missing import os in test_dgxcloud.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
Fixes code-scanning alerts 564 and 565 ("File is not always closed"):
- test_lepton.py: use `with open(script) as f` instead of bare open()
- test_local.py: same fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: oliver könig <okoenig@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Experiment.export(output_dir, exist_ok=False)which writes one script per job to a self-contained directory plus asubmit_all.shlauncher — no jobs are submitted_submit_dryrun()now writes its script toexecutor.experiment_dirwhen set:LocalExecutor→<task>.sh(executable bash)DockerExecutor→<task>.yamlSkypilotExecutor/SkypilotJobsExecutor→<task>.yamlLeptonExecutor→<task>.sh(executable bash)DGXCloudExecutor→<task>_torchrun_job.sh(was hardcoded, now usesjob_name)Experiment.export()redirects all executorexperiment_dirs tooutput_dir, runs dryrun to trigger script writing, then generatessubmit_all.shwith the correct submit command per executor type (sbatch,sky launch, etc.)Example — SLURM
Output directory:
pretrain_sbatch.shsubmit_all.shTest plan
uv run -- pytest test/run/test_experiment.py -k "export" -v— 4 new tests passuv run -- pytest test/run/test_experiment.py— all 66 tests passruff check --fix . && ruff format .— clean🤖 Generated with Claude Code