Bacalhau Docs
GithubSlackBlogEnterprise
v1.5.x
  • Documentation
  • Use Cases
  • CLI & API
  • References
  • Community
v1.5.x
  • Welcome
  • Getting Started
    • How Bacalhau Works
    • Installation
    • Create Network
    • Hardware Setup
    • Container Onboarding
      • Docker Workloads
      • WebAssembly (Wasm) Workloads
  • Setting Up
    • Running Nodes
      • Node Onboarding
      • GPU Installation
      • Job selection policy
      • Access Management
      • Node persistence
      • Connect Storage
      • Configuring Transport Level Security
      • Limits and Timeouts
      • Test Network Locally
      • Bacalhau WebUI
      • Private IPFS Network Setup
    • Workload Onboarding
      • Container
        • Docker Workload Onboarding
        • WebAssembly (Wasm) Workloads
        • Bacalhau Docker Image
        • How To Work With Custom Containers in Bacalhau
      • Python
        • Building and Running Custom Python Container
        • Running Pandas on Bacalhau
        • Running a Python Script
        • Running Jupyter Notebooks on Bacalhau
        • Scripting Bacalhau with Python
      • R (language)
        • Building and Running your Custom R Containers on Bacalhau
        • Running a Simple R Script on Bacalhau
      • Run CUDA programs on Bacalhau
      • Running a Prolog Script
      • Reading Data from Multiple S3 Buckets using Bacalhau
      • Running Rust programs as WebAssembly (WASM)
      • Generate Synthetic Data using Sparkov Data Generation technique
    • Data Ingestion
      • Copy Data from URL to Public Storage
      • Pinning Data
      • Running a Job over S3 data
    • Networking Instructions
      • Accessing the Internet from Jobs
      • Utilizing NATS.io within Bacalhau
    • GPU Workloads Setup
    • Automatic Update Checking
    • Marketplace Deployments
      • Google Cloud Marketplace
  • Guides
    • (Updated) Configuration Management
    • Write a config.yaml
    • Write a SpecConfig
  • Examples
    • Data Engineering
      • Using Bacalhau with DuckDB
      • Ethereum Blockchain Analysis with Ethereum-ETL and Bacalhau
      • Convert CSV To Parquet Or Avro
      • Simple Image Processing
      • Oceanography - Data Conversion
      • Video Processing
    • Model Inference
      • EasyOCR (Optical Character Recognition) on Bacalhau
      • Running Inference on Dolly 2.0 Model with Hugging Face
      • Speech Recognition using Whisper
      • Stable Diffusion on a GPU
      • Stable Diffusion on a CPU
      • Object Detection with YOLOv5 on Bacalhau
      • Generate Realistic Images using StyleGAN3 and Bacalhau
      • Stable Diffusion Checkpoint Inference
      • Running Inference on a Model stored on S3
    • Model Training
      • Training Pytorch Model with Bacalhau
      • Training Tensorflow Model
      • Stable Diffusion Dreambooth (Finetuning)
    • Molecular Dynamics
      • Running BIDS Apps on Bacalhau
      • Coresets On Bacalhau
      • Genomics Data Generation
      • Gromacs for Analysis
      • Molecular Simulation with OpenMM and Bacalhau
  • References
    • Jobs Guide
      • Job Specification
        • Job Types
        • Task Specification
          • Engines
            • Docker Engine Specification
            • WebAssembly (WASM) Engine Specification
          • Publishers
            • IPFS Publisher Specification
            • Local Publisher Specification
            • S3 Publisher Specification
          • Sources
            • IPFS Source Specification
            • Local Source Specification
            • S3 Source Specification
            • URL Source Specification
          • Network Specification
          • Input Source Specification
          • Resources Specification
          • ResultPath Specification
        • Constraint Specification
        • Labels Specification
        • Meta Specification
      • Job Templates
      • Queuing & Timeouts
        • Job Queuing
        • Timeouts Specification
      • Job Results
        • State
    • CLI Guide
      • Single CLI commands
        • Agent
          • Agent Overview
          • Agent Alive
          • Agent Node
          • Agent Version
        • Config
          • Config Overview
          • Config Auto-Resources
          • Config Default
          • Config List
          • Config Set
        • Job
          • Job Overview
          • Job Describe
          • Job Exec
          • Job Executions
          • Job History
          • Job List
          • Job Logs
          • Job Run
          • Job Stop
        • Node
          • Node Overview
          • Node Approve
          • Node Delete
          • Node List
          • Node Describe
          • Node Reject
      • Command Migration
    • API Guide
      • Bacalhau API overview
      • Best Practices
      • Agent Endpoint
      • Orchestrator Endpoint
      • Migration API
    • Node Management
    • Authentication & Authorization
    • Database Integration
    • Debugging
      • Debugging Failed Jobs
      • Debugging Locally
    • Running Locally In Devstack
    • Setting up Dev Environment
  • Help & FAQ
    • Bacalhau FAQs
    • Glossary
    • Release Notes
      • v1.5.0 Release Notes
      • v1.4.0 Release Notes
  • Integrations
    • Apache Airflow Provider for Bacalhau
    • Lilypad
    • Bacalhau Python SDK
    • Observability for WebAssembly Workloads
  • Community
    • Social Media
    • Style Guide
    • Ways to Contribute
Powered by GitBook
LogoLogo

Use Cases

  • Distributed ETL
  • Edge ML
  • Distributed Data Warehousing
  • Fleet Management

About Us

  • Who we are
  • What we value

News & Blog

  • Blog

Get Support

  • Request Enterprise Solutions

Expanso (2025). All Rights Reserved.

On this page
  • Description
  • Usage
  • Flags
  • Global Flags
  • Examples
  • Running python tasks
  • Running duckdb queries

Was this helpful?

Export as PDF
  1. References
  2. CLI Guide
  3. Single CLI commands
  4. Job

Job Exec

PreviousJob DescribeNextJob Executions

Was this helpful?

Description

The bacalhau exec command allows for the specification of jobs to be executed from the command line without the need for a job specification file (see ).

Usage

bacalhau exec [flags] [job-type] arguments

Flags

  1. -h, --help:

    • Description: Displays help information for the exec sub-command.

  2. --code:

    • Includes the specified code in the job. This can be a single file or a directory containing many files. There is a limit of 10Mb on the size of the uploaded code.

  3. -f, --follow:

    • Description: If provided, the command will continuously display the output from the job as it runs.

  4. --wait

    • Description: Wait for the job to finish. Use --wait=false to return as soon as the job is submitted.

  5. --wait-timeout-secs

    • Description: When using --wait, how many seconds to wait for the job to complete before giving up.

  6. --node-details

    • Description: Print out details of all nodes (overridden by --id-only).

  7. --id-only:

    • Description: On successful job submission, only the Job ID will be printed.

  8. -p, --publisher

    • Description: Where to publish the result of the job.

      Examples:

      Publish to IPFS

      -p ipfs

      Publish to S3

      -p s3://bucket/key

  9. -i, --input

    • Description: Mount URIs as inputs to the job. Can be specified multiple times. Format: src=URI,dst=PATH[,opt=key=value]

      Examples:

      Mount IPFS CID to /inputs directory

      -i ipfs://QmeZRGhe4PmjctYVSVHuEiA9oSXnqmYa4kQubSHgWbjv72

      Mount S3 object to a specific path

      -i s3://bucket/key,dst=/my/input/path

      Mount S3 object with specific endpoint and region

      -i src=s3://bucket/key,dst=/my/input/path,opt=endpoint=https://s3.example.com,opt=region=us-east-1

  10. -o, --output

    • Description: name:path of the output data volumes. 'outputs:/outputs' is always added unless '/outputs' is mapped to a different name.

  11. -e, --env

    • Description: The environment variables to supply to the job (e.g. --env FOO=bar --env BAR=baz)

  12. --timeout

    • Description: Job execution timeout in seconds (e.g. 300 for 5 minutes)

  13. -l, --labels

    • Description: List of labels for the job. Enter multiple in the format '-l a -l 2'. All characters not matching /a-zA-Z0-9_:|-/ and all emojis will be stripped.

  14. -s, --selector

    • Description: Selector (label query) to filter nodes on which this job can be executed, supports '=', '==', and '!='.(e.g. -s key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.

Global Flags

  1. --api-host string:

    • Description: Specifies the host used for RESTful communication between the client and server. The flag is disregarded if the BACALHAU_API_HOST environment variable is set.

    • Default: bootstrap.production.bacalhau.org

  2. --api-port int:

    • Description: Specifies the port for REST communication. If the BACALHAU_API_PORT environment variable is set, this flag will be ignored.

    • Default: 1234

  3. --log-mode logging-mode:

    • Description: Sets the desired log format. Options are: default, station, json, combined, and event.

    • Default: default

  4. --repo string:

    • Description: Defines the path to the bacalhau repository.

    • Default: ``$HOME/.bacalhau`

Examples

Running python tasks

  1. Basic Usage:

    Command:

    bacalhau exec python -- -c "import this"

    Output:

    The Zen of Python, by Tim Peters
    
    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    ....
  2. Single file Python:

    Command:

    bacalhau exec --code=app.py python app.py

    where app.py is

    """
    pip install colorama
    """
    
    from colorama import Fore
    print(Fore.RED + "Hello World")

    Output:

    As red text

    Hello World

Running duckdb queries

  1. Basic Usage:

    Command:

    cat describe.sql
      DESCRIBE TABLE '/inputs/world-cities_csv.csv';
    
    bacalhau exec --code=describe.sql -i src=https://datahub.io/core/world-cities/r/world-cities.csv,dst=/inputs duckdb -- -init /code/describe.sql

    Output:

         ┌─────────────┬─────────────┬─────────┬─────────┬─────────┬─────────┐
         │ column_name │ column_type │  null   │   key   │ default │  extra  │
         │   varchar   │   varchar   │ varchar │ varchar │ varchar │ varchar │
         ├─────────────┼─────────────┼─────────┼─────────┼─────────┼─────────┤
         │ name        │ VARCHAR     │ YES     │         │         │         │
         │ country     │ VARCHAR     │ YES     │         │         │         │
         │ subcountry  │ VARCHAR     │ YES     │         │         │         │
         │ geonameid   │ BIGINT      │ YES     │         │         │         │
         └─────────────┴─────────────┴─────────┴─────────┴─────────┴─────────┘
job run