Overview
TheBaseEnvironment abstract class defines the interface for containerized environments where agents execute tasks. Harbor supports multiple environment backends including Docker, Daytona, E2B, Modal, and GKE.
Import: from harbor.environments.base import BaseEnvironment
Class Attributes
Path
required
Path to the environment directory containing definition files (e.g.,
docker-compose.yaml).str
required
The name of the environment, typically the task name.
str
required
Unique session identifier for this environment instance, typically the trial name.
TrialPaths
required
Path configuration for the trial.
EnvironmentConfig
required
Environment configuration from the task definition.
logging.Logger
required
Logger instance for the environment.
Constructor
Path
required
Path to the environment directory.
str
required
Name of the environment.
str
required
Session ID for this instance.
TrialPaths
required
Trial paths configuration.
EnvironmentConfig
required
Environment configuration from task.
logging.Logger | None
Optional logger instance.
int | None
Override CPU allocation. Warning: May disqualify from leaderboards.
int | None
Override memory allocation in MB. Warning: May disqualify from leaderboards.
int | None
Override storage allocation in MB. Warning: May disqualify from leaderboards.
int | None
Override GPU allocation. Warning: May disqualify from leaderboards.
bool
default:"False"
Suppress warnings about resource overrides.
Abstract Methods
type
DOCKER, DAYTONA, MODAL).
EnvironmentType
required
The environment type identifier.
Abstract Properties
bool
required
Whether the environment mounts the logging directories.
bool
required
Whether this environment type supports GPU allocation.
bool
required
Whether this environment type supports disabling internet access.
start
bool
required
Whether to force a rebuild of the environment.
stop
bool
required
Whether to delete the environment after stopping.
File Operations
upload_file
Path | str
required
Local file path to upload.
str
required
Target path in the environment.
upload_dir
Path | str
required
Local directory to upload.
str
required
Target directory in the environment.
download_file
str
required
File path in the environment.
Path | str
required
Local target path.
download_dir
str
required
Directory path in the environment.
Path | str
required
Local target directory.
exec
str
required
The command to execute.
str | None
Working directory for command execution.
dict[str, str] | None
Environment variables to set.
int | None
Command timeout in seconds.
ExecResult
Result containing stdout, stderr, and return code.
Concrete Methods
is_dir
str
required
Path to check in the environment.
bool
True if path exists and is a directory.
is_file
str
required
Path to check in the environment.
bool
True if path exists and is a regular file.
attach
os.execvp. Not supported by all environment types.
Raises: NotImplementedError if the environment doesn’t support attaching.
ExecResult Model
str | None
Standard output from the command.
str | None
Standard error from the command.
int
required
Exit code from the command.
Example Implementation
Related Types
- EnvironmentConfig - Environment configuration
- BaseAgent - Agent interface