Skip to main content

Downloading Results

After a Bacalhau job completes, you'll need to retrieve the output files generated by your job. This guide explains the basics of downloading job results.

What You'll Learn​

  • How to specify output paths in your jobs
  • How to retrieve job results using the CLI

Getting Job Results​

To download the results of a completed job:

bacalhau job get <jobID>

This command downloads all outputs from the job to your current directory.

Specifying an Output Directory​

You can specify where to save the downloaded results:

bacalhau job get <jobID> --output-dir /path/to/save

Download Timeout Setting​

For larger downloads, you can adjust the timeout:

bacalhau job get <jobID> --download-timeout-secs 10m

Specifying Job Outputs and Publisher​

When submitting a job, you need to define which files or directories should be collected as outputs, and where those outputs should be published.

Using Command Line​

For Docker jobs, use the --output flag to define outputs and the --publisher flag to specify where to publish the results:

bacalhau docker run \
--output results:/outputs \
--publisher s3://my-bucket/results-folder \
ubuntu:latest \
-- echo "Hello, World!" > /outputs/hello.txt

This tells Bacalhau to:

  1. Collect everything in the /outputs directory of the container
  2. Publish it to the specified S3 bucket and path
  3. Make it available for download with bacalhau job get

Using Declarative Submission​

You can also define outputs in a job specification file:

Type: batch
Count: 1
Tasks:
- Name: main
Engine:
Type: docker
Params:
Image: python:3.9
Entrypoint:
- 'python'
- '-c'
- "import os; os.makedirs('/outputs', exist_ok=True); open('/outputs/result.txt', 'w').write('Analysis complete!')"
Publisher:
Type: s3
Params:
Bucket: my-bucket
Key: results-folder
ResultPaths:
- Name: results
Path: /outputs

Submit this job using:

bacalhau job run job-spec.yaml

Multiple Output Paths​

You can specify multiple output paths in a single job:

bacalhau docker run \
--output logs:/var/log \
--output results:/outputs \
--publisher s3://my-bucket/results-folder \
ubuntu:latest \
-- <your-command>

Downloaded Results Structure​

After running bacalhau job get, the results will be organized in a directory structure like this:

.
├── job-j-6bafb8d4
│ ├── exitCode
│ ├── outputs
│ │ └── file1
│ ├── stderr
│ └── stdout

The directory structure includes:

  • exitCode: Contains the exit code of the job
  • outputs: Contains all the files from the job's specified output directories
  • stderr: Captures any error output from the job
  • stdout: Captures the standard output from the job