Run
Description
The bacalhau job run
command facilitates the initiation of a job from a file or directly from the standard input (stdin). The command supports both JSON and YAML data formats. This command is particularly useful for quickly executing a job without the need for manual configurations.
Usage
Flags
--dry-run
:Description: With this flag, the job will not be submitted. Instead, it will display what would have been submitted, providing a way to preview before actual submission.
-f
,--follow
:Description: If provided, the command will continuously display the output from the job as it runs.
--id-only
:Description: On successful job submission, only the Job ID will be printed.
--node-details
:Description: Displays details of all nodes. Note that this flag is overridden if
--id-only
is provided.
--show-warnings
:Description: Shows any warnings that occur during the job submission.
--wait
:Description: Waits for the job to finish execution. To set this to false, use --wait=false
Default:
true
--wait-timeout-secs int
:Description: If
--wait
is provided, this flag sets the maximum time (in seconds) the command will wait for the job to finish before it terminates.Default:
600
seconds
-h
,--help
:Description: Displays help information for the
run
command.
Global Flags
--api-host string
:Description: Specifies the host used for RESTful communication between the client and server. The flag is disregarded if
BACALHAU_API_HOST
environment variable is set.Default:
bootstrap.production.bacalhau.org
--api-port int
:Description: Determines the port for REST communication. If
BACALHAU_API_PORT
environment variable is set, this flag will be ignored.Default:
1234
--log-mode logging-mode
:Description: Selects the desired log format. Options include:
default
,station
,json
,combined
, andevent
.Default:
default
--repo string
:Description: Defines the path to the bacalhau repository.
Default:
$HOME/.bacalhau
Examples
Sample Job (job.yaml
)
A sample job used in the following examples is provided below:
This configuration describes a batch job that runs a Docker task. It utilizes the ubuntu:latest
image and executes the command echo Hello Bacalhau!
.
Running a Job using a YAML Configuration:
To run a job with a configuration provided in a
job.yaml
file:Command:
Expected Output:
Running a Job and Following its Logs:
Command:
Expected Output:
Running a Job Without Waiting:
Command:
Expected Output:
Fetching Only the Job ID Upon Submission:
Command:
Expected Output:
Fetching Only the Job ID and Wait for Completion:
Command:
Expected Output:
Running a Job with Node Details:
Command:
Expected Output:
Rerunning a previously submitting job:
Command:
Expected Output:
Job Templating
The bacalhau job run
command also supports templating, which allows users to dynamically inject variables into their job specifications. Additional flags related to templating include:
--no-template
:Description: Disable the templating feature. When this flag is set, the job spec will be used as-is, without any placeholder replacements.
-E, --template-envs
:Description: Specify a regular expression pattern for selecting environment variables to be included as template variables in the job spec. e.g.
--template-envs ".*"
will include all environment variables.
-V, --template-vars
:Description: Replace a placeholder in the job spec with a value. e.g.
--template-vars foo=bar
Overview
Templating is particularly useful when running multiple jobs with varying parameters such as DuckDB query, S3 buckets, prefixes, and time ranges without the need to edit each job specification file manually.
Templating Implementation
The templating functionality in Bacalhau is built upon the Go text/template package. This powerful library offers a wide range of features for manipulating and formatting text based on template definitions and input variables.
For more detailed information about the Go text/template library and its syntax, please refer to the official documentation: Go text/template Package.
Basic Templating Example
Sample Job Spec with Templating Variables:
Running with Templating:
Defining Flag Multiple Times:
Disabling Templating:
Using Environment Variables for Templates
You can also use environment variables for templating:
Passing A Subset of Environment Variables:
Dry Run to Preview Templated Spec
To preview the final templated job spec without actually submitting the job, you can use the --dry-run
flag:
This will output the processed job specification, showing you how the placeholders have been replaced with the provided values.
Advanced Templating Examples
Query Live Logs
This is an ops job that runs on all nodes that match the job selection criteria. It accepts duckdb query variable, and two optional start-time and end-time variables to define the time range for the query.
To run this job, you can use the following command:
Query S3 Logs
This is a batch job that runs on a single node. It accepts the duckdb query variable, and four other variables to define the S3 bucket, prefix, and pattern for the logs and the AWS region.
To run this job, you can use the following command:
Last updated
Was this helpful?