Repository navigation
Conversation
`load_apply_configuration()` converted the configuration path into a path relative to the current directory unconditionally. For a configuration passed by absolute path — or any other file outside the cwd — `Path.relative_to()` raised `ValueError: ... is not in the subpath of ...`, so the CLI crashed with a traceback before contacting the server. Fall back to the absolute path when the configuration is not under the cwd. Relative `repos` and `files` entries are resolved against the configuration's directory, so they keep working with an absolute path. Closes dstackai#4444
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.
Problem
dstack apply -f /abs/path/.dstack.ymlcrashes with a traceback before contacting the server:load_apply_configuration()always converted the configuration path into a path relative to the current directory:Path.relative_to()raisesValueErrorfor any file outside the cwd, so applying a configuration by absolute path — or from any other directory — never got past argument parsing. Relative paths containing..happened to work becausePath.absolute()keeps the..segments.Fixes #4444.
Fix
Try the relative form first (unchanged behavior for configurations under the cwd) and fall back to the absolute path when the configuration is not under the cwd. Relative
reposandfilesentries are resolved against the configuration's directory (Path(configuration_path).resolve().parent), so they keep resolving correctly either way. The stdin (-f -) path is untouched.Tests
New
src/tests/_internal/cli/services/configurators/test_apply_configuration.py:..segments is still returned unchangedConfigurationErrorThe first test fails on
mainwith the reportedValueErrorand passes with the patch.uv run ruff checkanduv run ruff format --checkpass on both changed files.