Add -e/--env passthrough to run-recipe.py

Fixes #81. Allows passing environment variables (e.g. HF_TOKEN)
through to the container when launching via recipes, mirroring
the existing -e flag in launch-cluster.sh.

Usage: ./run-recipe.sh glm-4.7-flash-awq --solo -e HF_TOKEN=$HF_TOKEN
This commit is contained in:
mariosaladino
2026-03-06 21:50:29 +01:00
parent eb8abcca7f
commit f95beba566
2 changed files with 50 additions and 0 deletions

View File

@@ -818,6 +818,7 @@ Examples:
launch_group.add_argument("-d", "--daemon", action="store_true", help="Run in daemon mode")
launch_group.add_argument("-t", "--container", dest="container_override", help="Override container image from recipe")
launch_group.add_argument("--nccl-debug", choices=["VERSION", "WARN", "INFO", "TRACE"], help="NCCL debug level")
launch_group.add_argument("-e", "--env", action="append", dest="env_vars", default=[], metavar="VAR=VALUE", help="Environment variable to pass to container (e.g. -e HF_TOKEN=xxx). Can be used multiple times.")
# Cluster discovery options
discover_group = parser.add_argument_group("Cluster discovery")
@@ -1118,6 +1119,8 @@ Examples:
cmd_parts.extend(["-n", ",".join(nodes)])
if args.nccl_debug:
cmd_parts.extend(["--nccl-debug", args.nccl_debug])
for env_var in args.env_vars:
cmd_parts.extend(["-e", env_var])
cmd_parts.extend(["\\", "\n --launch-script", "/tmp/tmpXXXXXX.sh"])
print(" ".join(cmd_parts))
print()
@@ -1159,6 +1162,9 @@ Examples:
if args.nccl_debug:
cmd.extend(["--nccl-debug", args.nccl_debug])
for env_var in args.env_vars:
cmd.extend(["-e", env_var])
# Add launch script
cmd.extend(["--launch-script", temp_script])