Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions runner/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const (
// The current user's homedir (as of 2024-12-28, it's always root) should be used
// instead of the hardcoded value
RunnerHomeDir = "/root"
// A repo directory and a default working directory for the job
RunnerWorkingDir = "/workflow"
)

const LegacyRepoDir = "/workflow"

const (
RunnerHTTPPort = 10999
RunnerSSHPort = 10022
Expand Down
5 changes: 4 additions & 1 deletion runner/internal/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ func (ex *RunExecutor) setJobWorkingDir(ctx context.Context) error {
return gerrors.Wrap(err)
}
} else {
ex.jobWorkingDir, err = common.ExpandPath(*ex.jobSpec.WorkingDir, "", ex.jobHomeDir)
// We still support relative paths, as 0.19.27 server uses relative paths when possible
// for compatibility with pre-0.19.27 runners.
// Replace consts.LegacyRepoDir with "" eventually.
ex.jobWorkingDir, err = common.ExpandPath(*ex.jobSpec.WorkingDir, consts.LegacyRepoDir, ex.jobHomeDir)
if err != nil {
return gerrors.Wrap(err)
}
Expand Down
17 changes: 13 additions & 4 deletions src/dstack/_internal/server/services/jobs/configurators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,23 @@ def _repo_dir(self) -> str:

def _working_dir(self) -> Optional[str]:
"""
Returns absolute path or None
Returns path or None

None means the default working directory taken from the image

Currently, for compatibility with pre-0.19.27 runners, the path may be relative.
Future versions should return only absolute paths
"""
working_dir = self.run_spec.configuration.working_dir
if working_dir is None or is_absolute_posix_path(working_dir):
if working_dir is None:
return working_dir
# Legacy configuration; relative working_dir is deprecated
return str(PurePosixPath(LEGACY_REPO_DIR) / working_dir)
# Return a relative path if possible
if is_absolute_posix_path(working_dir):
try:
return str(PurePosixPath(working_dir).relative_to(LEGACY_REPO_DIR))
except ValueError:
pass
return working_dir

def _python(self) -> str:
if self.run_spec.configuration.python is not None:
Expand Down
Loading