Manage Files and Artifacts
Sandbox filesystem APIs and commands inspect and transfer files in the running container. The quick start creates /workspace as scratch space; uploading a file there does not add it to Polyaxon's artifact store.
The Python examples reuse the sandbox client from that guide. The CLI examples reuse its quick-start project and RUN_UUID variable.
List Files
listing = sandbox.fs.ls("/workspace")
for entry in listing.entries or []:
print(entry.type, entry.name)polyaxon sandbox ls -p quick-start -uid $RUN_UUID /workspaceList recursively when needed:
listing = sandbox.fs.ls("/workspace", recursive=True)
for entry in listing.entries or []:
print(entry.type, entry.name)polyaxon sandbox ls -p quick-start -uid $RUN_UUID /workspace --recursiveUpload Files
uploaded = sandbox.fs.upload_file(
local_path="./sandbox/local.txt",
path="/workspace/local.txt",
)
print(uploaded.path, uploaded.bytes_written)polyaxon sandbox upload -p quick-start -uid $RUN_UUID \
./sandbox/local.txt /workspace/local.txtDownload Files
local_path = sandbox.fs.download_file(
path="/workspace/local.txt",
local_path="./sandbox/local.downloaded.txt",
)
print(local_path)polyaxon sandbox download -p quick-start -uid $RUN_UUID \
/workspace/local.txt ./sandbox/local.downloaded.txtPreserve Outputs
Files under /workspace may disappear when the run is stopped or replaced. For durable results, write them under the path returned by tracking.get_outputs_path(). Polyaxon syncs that run output directory to the configured artifact store.
For tracking artifacts from Python code, see tracking artifacts.
File Transfer Guidance
- Use
sandbox.fsor the sandbox upload and download commands for small targeted files. - Use SSH-based tools such as SFTP or SCP for larger interactive transfer workflows. You can also use rsync when the container image includes it.
- Use
tracking.get_outputs_path()for model files, reports, checkpoints, and generated datasets that Polyaxon should retain.
See the Python filesystem reference or the sandbox CLI reference for the full interfaces.