Skip to main content

Overview

The Job class is the single entrypoint for launching a set of trials in Harbor. It handles database initialization, task and dataset management, and saves job-level results to the database and filesystem. Import: from harbor import Job

Constructor

JobConfig
required
The job configuration object that defines all aspects of the evaluation run.

Properties

After initialization, the Job instance has these key attributes:
  • config: JobConfig - The job configuration
  • is_resuming: bool - Whether this job is resuming from a previous run
  • job_dir: Path - Directory where job results are stored

Methods

run

Executes all trials defined in the job configuration.
JobResult
Contains comprehensive results including:
  • Trial results for all executions
  • Aggregate statistics across agents and datasets
  • Timing information
  • Computed metrics
Example:

Lifecycle Hooks

Register callbacks for various trial lifecycle events. All hooks return self for method chaining.

on_trial_started

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when a trial begins execution.
Example:

on_environment_started

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when a trial’s environment is ready.

on_agent_started

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when an agent begins execution.

on_verification_started

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when verification begins.

on_trial_ended

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when a trial ends (success or failure). The TrialHookEvent.result field will contain the TrialResult.
Example:

on_trial_cancelled

Callable[[TrialHookEvent], Awaitable[None]]
required
Async function called when a trial is cancelled.

Complete Example