Write a SpecConfig

Overview

A job specification defines how Bacalhau should execute your workload. This guide provides a complete reference of all supported options, configurations, and their valid values.

Basic Structure

A job specification is a JSON document with the following structure:

{
  "Name": "my-job",
  "Type": "batch",
  "Count": 1,
  "Tasks": [{
    "Name": "main",
    "Engine": {
      "Type": "docker",
      "Params": {
        "Image": "ubuntu:latest"
      }
    },
    "Resources": {
      "CPU": "1",
      "Memory": "1GB"
    }
  }]
}

Field Reference

Job Level Fields

Field
Type
Required
Default
Valid Values

Name

string

Yes

-

Alphanumeric with - and _

Type

string

Yes

batch

batch, service, daemon, ops

Count

integer

No

1

1 or greater

Priority

integer

No

0

0-100

Namespace

string

No

default

Valid DNS label

Labels

object

No

{}

Key-value string pairs

Tasks

array

Yes

-

Array of task objects

Types

These are the types of jobs:

  • batch: Run once and complete

  • service: Run continuously with specified replica count

  • daemon: Run continuously on all matching nodes

  • ops: Run once on all matching nodes

Task Configuration

Tasks define the actual work to be performed. Each task requires:

  1. Engine configuration (how to run)

  2. Resource requirements (what it needs)

  3. Data handling (inputs/outputs)

Inside tasks, there are a number of fields.

Task Level Fields

Field
Type
Required
Default
Valid Values

Name

string

Yes

-

Alphanumeric with - and _

Engine

object

Yes

-

Engine configuration

Resources

object

Yes

-

Resource requirements

InputSources

array

No

[]

Array of input sources

ResultPaths

array

No

[]

Array of result paths

Network

object

No

{"Type": "none"}

Network configuration

Timeouts

object

No

-

Timeout settings

Env

object

No

{}

Key-value string pairs

Meta

object

No

{}

Key-value string pairs

Additionally, there are sub-fields to fill in.

Engine Types

  • docker: Docker container execution

  • wasm: WebAssembly module execution

Engine Configuration

Docker Engine Parameters

Parameter
Type
Required
Description

Image

string

Yes

Docker image name

Entrypoint

array

No

Container entrypoint

Parameters

array

No

Command parameters

WorkingDirectory

string

No

Working directory

EnvironmentVariables

object

No

Environment variables

Ports

array

No

Port mappings

Example:

"Engine": {
  "Type": "docker",
  "Params": {
    "Image": "python:3.9-slim",
    "Entrypoint": ["python"],
    "Parameters": ["-c", "print('hello')"],
    "WorkingDirectory": "/app",
    "EnvironmentVariables": {
      "PYTHONUNBUFFERED": "1"
    }
  }
}

Common Edge Cases:

  • Images without default entrypoints require explicit entrypoint

  • Environment variables with spaces or special characters need proper escaping

  • Working directory must exist in container

  • Large images may exceed node storage limits

WASM Engine Parameters

Parameter
Type
Required
Description

EntryModule

string

Yes

WASM module path

EntryPoint

string

Yes

Exported function name

Parameters

array

No

Function arguments

EnvironmentVariables

object

No

Environment variables

Example:

"Engine": {
  "Type": "wasm",
  "Params": {
    "EntryModule": "app.wasm",
    "EntryPoint": "_start",
    "Parameters": ["--verbose"],
    "EnvironmentVariables": {
      "MEMORY_LIMIT": "512MB"
    }
  }
}

Storage Types

  • ipfs: IPFS content (you must provide your own IPFS endpoint)

  • s3: Amazon S3 storage

  • local: Local filesystem

  • urlDownload: HTTP/HTTPS URLs

  • s3PreSigned: Pre-signed S3 URLs

Network Types

  • none: No network access (default)

  • http: Limited HTTP/HTTPS access

  • full: Unrestricted network access

Publisher Types

  • ipfs: Publish to IPFS

  • s3: Upload to S3

  • local: Store locally

  • noop: Discard results

Resource Requirements

Resource Fields

Field
Type
Required
Format
Range

CPU

string

Yes

Decimal

0.1 to node max

Memory

string

Yes

Size + Unit

1MB to node max

Disk

string

Yes

Size + Unit

10MB to node max

GPU

string

No

Integer

0 to node max

Example:

"Resources": {
  "CPU": "1.5",
  "Memory": "2GB",
  "Disk": "10GB",
  "GPU": "1"
}

Data Handling

Input Source Fields

Field
Type
Required
Description

Source.Type

string

Yes

One of: ipfs, s3, local, urlDownload, s3PreSigned, inline

Source.Params

object

Yes

Source-specific parameters

Target

string

Yes

Absolute mount path

Alias

string

No

Friendly identifier

Source Type Parameters

IPFS:

{
  "CID": "string",
  "Gateway": "string"
}

S3:

{
  "Bucket": "string",
  "Key": "string",
  "Region": "string",
  "Endpoint": "string",
  "AccessKeyID": "string",
  "SecretAccessKey": "string"
}

URL:

{
  "URL": "string",
  "Headers": {
    "string": "string"
  }
}

Inline:

{
  "Content": "string"
}

Example:

"InputSources": [
  {
    "Source": {
      "Type": "ipfs",
      "Params": {
        "CID": "QmHash..."
      }
    },
    "Target": "/inputs/data",
    "Alias": "dataset"
  }
]

This can accept multiple sources - for example:

"InputSources": [
  {
    "Source": {"Type": "ipfs", ...},
    "Target": "/inputs/data1"
  },
  {
    "Source": {"Type": "s3", ...},
    "Target": "/inputs/data2"
  }
]

Network Configuration

"Network": {
  "Type": "http",
  "Domains": ["api.example.com"],
  "EnableIPv6": true,
  "DNS": ["8.8.8.8"],
  "Policies": {
    "Egress": {
      "Ports": ["80", "443"]
    }
  }
}

Timeout Configuration

"Timeouts": {
  "ExecutionTimeout": 3600,
  "QueueTimeout": 300,
  "TotalTimeout": 4000
}

Validation and Testing

Pre-Submission Validation

You can test your job schema by running the validatecommand. E.g.

bacalhau validate job.json

Test Runs

Bacalhau also supports --dry-runfor testing, though this is only done locally. It does not test against the network.

bacalhau run --dry-run job.json

Troubleshooting Guide

Common Error Messages

  1. Resource Errors

    Error: insufficient resources: CPU request exceeds node capacity

    Solution: Check node capabilities and adjust requests

  2. Network Errors

    Error: network access denied: domain not in allowlist

    Solution: Verify network policy and domain lists

  3. Timeout Errors

    Error: job exceeded ExecutionTimeout

    Solution: Adjust timeouts or optimize job

Last updated

Was this helpful?