Add files property to run configurations#2848
Merged
Conversation
Each item in the `files` property maps a local path (a file or a dir) to a container path. Each local path is packed into a tar archive and uploaded to the server similar to the code repo archive/diff. On the server, each archive is stored in the DB as `FileArchiveModel` linked to the user. Archive blobs are optionally uploaded to the storage (again, similar to the code blob). When the job is submitted to the runner, files (if any) are uploaded after `/api/submit` but before `/api/upload_code`. The runner unpacks archives as follows: * If the path already exists, it's removed * If any parent dirs of the path are missing, they are created as owned by the run user. The owner of the existing dirs is not changed. * The owner of the path (and all subpaths in the case of the directory) is set to the run user. The permissions from the archive (and thus from the user's machine) are preserved. Part-of: #2738
r4victor
reviewed
Jun 27, 2025
|
|
||
|
|
||
| class FilesAPIClient(APIClientGroup): | ||
| def get_archive_by_hash(self, hash: str) -> FileArchive: |
Collaborator
There was a problem hiding this comment.
Any plans to use this function?
Collaborator
Author
There was a problem hiding this comment.
dstack itself does not use this API method at the moment, but it can be used to avoid uploading a large archive if it's already uploaded (e.g., in RunCollection.apply_plan):
- Create an archive, get a hash
- Check if the archive is already uploaded, calling this method
- If the archive is already uploaded, reuse
idreturned by the method, upload the archive otherwise
We could improve RunCollection.apply_plan by adding this additional check for large archives (for small ones the additional API call only increases execution time).
r4victor
approved these changes
Jun 27, 2025
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.
Each item in the
filesproperty maps a local path (a file or a dir) to a container path. Each local path is packed into a tar archive and uploaded to the server similar to the code repo archive/diff.On the server, each archive is stored in the DB as
FileArchiveModellinked to the user. Archive blobs are optionally uploaded to the storage (again, similar to the code blob).When the job is submitted to the runner, files (if any) are uploaded after
/api/submitbut before/api/upload_code.The runner unpacks archives as follows:
Part-of: #2738