Dependencies
Inspect Flow automatically creates isolated virtual environments for each workflow run, ensuring repeatability and avoiding dependency conflicts with your system Python environment. Because each run starts with a fresh environment, dependencies must be resolved—either automatically detected from your project files or explicitly specified in your configuration.
When you run flow run config.py, Flow:
- Creates a temporary virtual environment with
uv - Installs dependencies from dependency files and/or config file
- Executes your evaluations in this isolated environment
- Cleans up the temporary environment after completion (logs persist in
log_dir)
Automatic Dependency Discovery
By default, Flow automatically discovers and installs dependencies without requiring explicit configuration:
- Dependency files: Searches upward from your config file directory for
pyproject.tomlorrequirements.txt. Relative paths will be resolved relative to the config file (when using the CLI) orbase_dirarg (when using the API) - Package inference: Detects packages from object names in your config:
- Models:
model="openai/gpt-4"→ installsopenai - Tasks:
name="inspect_evals/mmlu"→ installsinspect-evals
- Models:
- Config inheritance: Automatically includes any
_flow.pyfiles in the config directory or parent directories (see Inheritance). These files can specify default dependencies that apply to all including configs.
This means most workflows require no dependency configuration at all!
Explicit Dependencies
While automatic dependency discovery works for most cases, you may need explicit dependencies when you require specific package versions for reproducibility e.g. openai==2.8.0, need to specify a non-standard dependency file location, or need to override the automatic detection behavior. Explicit dependencies give you full control over what gets installed in your workflow’s virtual environment.
The dependencies field in FlowSpec accepts a FlowDependencies object:
config.py
from inspect_flow import FlowDependencies, FlowSpec, FlowTask
FlowSpec(
dependencies=FlowDependencies(
dependency_file="../foo/pyproject.toml",
additional_dependencies=["pandas==2.0.0"],
auto_detect_dependencies=True,
),
log_dir="logs",
tasks=[
FlowTask(
name="inspect_evals/gpqa_diamond",
model="openai/gpt-5",
),
],
)- 1
-
How to find dependency files: Defaults to
"auto"which auto-detects arequirements.txtor apyproject.tomlfile. May also be set to a path to a dependency file or"no_file"to not use a dependency file. When usingpyproject.toml, if auv.lockfile exists in the same directory, it will be used automatically for reproducible installs. - 2
- Extra packages beyond the dependency file. Accepts a string or list of strings. Supports: PyPI packages, Git repositories, local packages.
- 3
-
Auto-install packages based on task and model names in the config (default:
True). For example,model="openai/gpt-4"installsopenai, andname="inspect_evals/mmlu"installsinspect-evals.
Python Version
Specify the Python version for your spec’s virtual environment:
config.py
from inspect_flow import FlowSpec, FlowTask
FlowSpec(
python_version="3.11",
log_dir="logs",
tasks=[
FlowTask(
name="inspect_evals/gpqa_diamond",
model="openai/gpt-5",
),
],
)Checking Config
To verify which dependencies and Python version will be used:
flow run config.py --dry-runFor repeatable workflows:
- Pin PyPI package versions:
"inspect-evals==0.3.15" - Pin Git commits:
"git+https://github.com/user/repo@commit_hash" - Specify
python_versionexplicitly - Use
uv.lockwithpyproject.tomlfor locked dependencies (automatically detected if present)