Skip to content

fix: guard tools build-context on directory existence and fix SLURM env var escaping#134

Merged
coketaste merged 1 commit into
developfrom
coketaste/fix-tests
May 29, 2026
Merged

fix: guard tools build-context on directory existence and fix SLURM env var escaping#134
coketaste merged 1 commit into
developfrom
coketaste/fix-tests

Conversation

@coketaste

Copy link
Copy Markdown
Collaborator

Summary

  • docker_builder.py: The --build-context tools= flag was unconditionally passed to every docker build command, causing builds to fail when scripts/common/tools doesn't exist. It is now
    only included when the directory is present.
  • slurm.py: shlex.quote() wraps values in single quotes, which prevents variable expansion but also breaks values containing spaces or paths when interpreted in SLURM batch scripts.
    Replaced with double-quote escaping (, ", $, `) to safely handle special characters while remaining compatible with SLURM's bash environment.

Test plan

  • Run a Docker build in an environment without scripts/common/tools — confirm build proceeds without the --build-context flag and does not error
  • Run a Docker build in an environment with scripts/common/tools — confirm --build-context tools= is included as before
  • Submit a SLURM job with env vars containing spaces, $VAR references, or file paths — confirm they are exported correctly in the batch script

…n SLURM

- docker_builder: only pass --build-context tools= when scripts/common/tools exists
- slurm: use double-quote escaping for env var values instead of shlex.quote to preserve special characters like spaces and paths correctly

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
@coketaste coketaste self-assigned this May 29, 2026
Copilot AI review requested due to automatic review settings May 29, 2026 14:45
@coketaste
coketaste merged commit 2b4018b into develop May 29, 2026
1 check failed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

coketaste added a commit that referenced this pull request Jun 8, 2026
A merge brought in manual double-quote escaping (PR #134) for env var
values while this branch's tests expected shlex.quote output, causing two
test_slurm_multi failures. Revert to shlex.quote, which is Python's
standard shell-safe quoting and is already used for the script path and
model args a few lines above. This restores consistency and reliably
handles spaces, paths, and special characters.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
coketaste added a commit that referenced this pull request Jun 13, 2026
…NNER resolver (#132)

* refactor: canonicalize launcher aliases and extract MAD_MULTI_NODE_RUNNER resolver

- Add canonicalize_distributed_launcher() to common.py with sglang_disagg → sglang-disagg alias
- Replace inline duplicate checks in k8s_template_context.py and slurm.py with the helper
- Extract _resolve_local_multi_node_runner_env() method in container_runner.py; self-managed
  launchers (vllm/sglang/sglang-disagg/primus) now always set MAD_MULTI_NODE_RUNNER="" so
  downstream scripts under set -u don't fail
- Add test coverage for new helper and extracted method, including sglang_disagg alias path

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* fix: address code review findings from launcher-update review

- common.py: add missing blank line after canonicalize_distributed_launcher
  (E305 flake8 violation)
- slurm.py: canonicalize launcher aliases before normalize_launcher in
  _prepare_template_context so sglang_disagg reaches _generate_launcher_command
  as the canonical sglang-disagg instead of being silently mapped to "docker"
- slurm.py: revert slurm_multi env-var export to shlex.quote (shell injection
  safe) from the double-quote form that was not injection-safe
- test_slurm_multi.py: align export assertions with shlex.quote output

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* fix: simplify sglang-disagg dispatch in _generate_launcher_command

_prepare_template_context() already canonicalizes launcher aliases before
calling normalize_launcher(), so launcher_type is always in canonical form
by the time it reaches _generate_launcher_command(). Replace the
redundant canonicalize_distributed_launcher() call with a direct equality
check, consistent with all other launcher branches.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* fix: use shlex.quote for slurm_multi env var exports

A merge brought in manual double-quote escaping (PR #134) for env var
values while this branch's tests expected shlex.quote output, causing two
test_slurm_multi failures. Revert to shlex.quote, which is Python's
standard shell-safe quoting and is already used for the script path and
model args a few lines above. This restores consistency and reliably
handles spaces, paths, and special characters.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* fix: remove deprecated Typer is_flag/flag_value from --use-image

The is_flag=False/flag_value="auto" workaround emitted a DeprecationWarning
at import time and was already non-functional in Typer 0.24.2 (bare
--use-image errored "requires an argument"). Make --use-image a normal
value option and document --use-image auto as the auto-detect form, which
already works. Update docs that referenced the broken bare-flag form.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* fix: resolve launcher inconsistencies for sentinels and aliases

Suppress the "Unrecognized launcher" warning for deployment-mode
sentinels (docker/native) since defaulting them to torchrun is expected,
not an error. Persist the normalized SLURM launcher back onto
distributed_config so reporting paths see the same launcher the template
used instead of re-mapping aliases (e.g. sglang_disagg) to "docker".

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants