Skip to content

Commit 5c2bf28

Browse files
authored
Move dataset hydration into Python config package. (#15)
* refactor: centralize dataset and task configuration logic into new shared `dataset_config_python.hydrate` module * feat: update dataset configuration schemas and add missing python package dependencies to CI workflows
1 parent 4587f8d commit 5c2bf28

16 files changed

Lines changed: 690 additions & 258 deletions

File tree

‎.github/workflows/dash_evals_module_tests.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
run: |
3636
source .venv/bin/activate
3737
pip install --upgrade pip
38+
pip install -e ../dataset_config_python
3839
pip install -e ".[dev]"
3940
4041
- name: Run tests

‎.github/workflows/docs.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
run: |
3333
pip install --upgrade pip
3434
pip install -r docs/requirements.txt
35+
pip install -e packages/dataset_config_python
3536
pip install -e packages/dash_evals
3637
3738
- name: Install Dart dependencies

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This repo includes
1111

1212
- **eval runner** — Python package for running LLM evaluations with configurable tasks, variants, and models
1313
- **config packages** — Dart and Python packages that resolve dataset YAML into EvalSet JSON for the runner
14+
- **NB**: These packages largely overlap, and coexist for backwards compatibility purposes. In time, the Dart package will be deprecated.
1415
- **devals CLI** — Dart CLI for creating and managing dataset samples, tasks, and jobs
1516
- **Evaluation Explorer** — Dart/Flutter app for browsing and analyzing results
1617

‎docs/contributing/packages/dash_evals.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ src/dash_evals/
4141

4242
1. **Configure**: The Dart `dataset_config_dart` package parses dataset YAML and resolves it into an `EvalSet` JSON manifest
4343
2. **Load**: The Python runner reads the JSON manifest via `json_runner.py`, resolving task functions dynamically with `importlib`
44-
3. **Execute**: Each task function receives its dataset and task definition, producing an `inspect_ai.Task`
45-
4. **Score**: Scorers evaluate model outputs against targets
46-
5. **Log**: Results written to the configured `log_dir`
44+
3. **Hydrate**: Config dicts are converted to Inspect AI objects (datasets, MCP servers, skills) using shared helpers from `dataset_config_python.hydrate`
45+
4. **Execute**: Each task function receives its dataset and task definition, producing an `inspect_ai.Task`
46+
5. **Score**: Scorers evaluate model outputs against targets
47+
6. **Log**: Results written to the configured `log_dir`
4748

4849
Alternatively, the runner can be invoked directly with `--task` and `--model` arguments (via `args_runner.py`), bypassing the Dart config pipeline.
4950

‎docs/contributing/repository_structure.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ evals/
1010
│ ├── devals_cli/ # Dart CLI for managing dataset (devals)
1111
│ ├── dataset_config_dart/ # Dart library: YAML → EvalSet JSON
1212
│ ├── dash_evals/ # Python evaluation runner
13-
│ ├── dataset_config_python/ # Python configuration models
13+
│ ├── dataset_config_python/ # Python config: YAML → EvalSet JSON + config → Inspect AI objects
1414
│ └── eval_explorer/ # Dart/Flutter results viewer (Serverpod)
1515
├── tool/ # Utility scripts
1616
├── pubspec.yaml # Dart workspace configuration

‎docs/guides/about_the_framework.md‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ YAML config → Dart resolver → JSON manifest → Python runner → Inspect AI
1818
|-------|---------|-------------|
1919
| **YAML config** | — | Your `task.yaml` and `job.yaml` files |
2020
| **Dart resolver** | `dataset_config_dart` | Parses YAML, resolves globs and references, produces a JSON manifest |
21+
| **Hydration** | `dataset_config_python` | Converts config dicts into Inspect AI objects (datasets, MCP servers, skills) |
2122
| **Python runner** | `dash_evals` | Reads the manifest, builds Inspect AI `Task` objects, calls `eval_set()` |
2223
| **Inspect AI** | `inspect_ai` | Runs solver chains, sends prompts, collects responses, runs scorers |
2324

@@ -148,16 +149,19 @@ calling `submit()`.
148149

149150
## Shared helpers
150151

151-
The `task_helpers.py` module contains functions used across all tasks:
152-
153-
| Helper | What it does |
154-
|--------|-------------|
155-
| `append_context_injection(chain, config)` | Adds a `context_injector` solver if the variant has `files` |
156-
| `append_model_interaction(chain, config)` | Adds `react()` (if tools exist) or `generate()` (if not) |
157-
| `get_skill_tool(config)` | Creates a skill tool if the variant has `skills` configured |
158-
| `build_task_metadata(config)` | Builds the metadata dict for the `Task` object |
159-
| `create_mcp_servers(configs, sandbox_type)` | Creates MCP server objects from variant config |
160-
| `validate_sandbox_tools(config, tool_names)` | Checks that sandbox-requiring tools aren't used on local |
152+
The `task_helpers.py` module contains functions used across all tasks. Some of
153+
these are re-exported from `dataset_config_python.hydrate` — the shared
154+
config-interpretation layer that both `dash_evals` and external consumers (like
155+
yardstick) use to ensure consistent hydration of config into Inspect AI objects.
156+
157+
| Helper | Source | What it does |
158+
|--------|--------|-------------|
159+
| `create_mcp_servers(configs, sandbox_type)` | `dataset_config_python` | Creates MCP server objects from variant config |
160+
| `get_skill_tool(config)` | `dataset_config_python` | Creates a skill tool if the variant has `skills` configured |
161+
| `build_task_metadata(config)` | `dataset_config_python` | Builds the metadata dict for the `Task` object |
162+
| `append_context_injection(chain, config)` | `dash_evals` | Adds a `context_injector` solver if the variant has `files` |
163+
| `append_model_interaction(chain, config)` | `dash_evals` | Adds `react()` (if tools exist) or `generate()` (if not) |
164+
| `validate_sandbox_tools(config, tool_names)` | `dash_evals` | Checks that sandbox-requiring tools aren't used on local |
161165

162166
These helpers mean that most of the variant logic (context injection, MCP tools,
163167
skills) is handled **automatically**. You just need to define the core solver

‎docs/reference/dart_api/dataset_config_dart/dataset_config_dart.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ and [`MemoryDataset`](https://inspect.aisi.org.uk/reference/inspect_ai.dataset.h
336336
#### `Dataset`
337337

338338
```dart
339-
Dataset({List<Sample> samples, String? name, String? location, bool shuffled})
339+
Dataset({List<Sample> samples, String? name, String? location, bool shuffled, String format, String? source, Map<String, dynamic>? args})
340340
```
341341

342342
#### `Dataset.fromJson`
@@ -1007,7 +1007,7 @@ inspect_eval_arguments:
10071007
#### `Job`
10081008

10091009
```dart
1010-
Job({String? description, required String logDir, int maxConnections, List<String>? models, Map<String, Map<String, dynamic>>? variants, List<String>? taskPaths, Map<String, JobTask>? tasks, bool saveExamples, Map<String, dynamic>? sandbox, Map<String, dynamic>? inspectEvalArguments, TagFilter? taskFilters, TagFilter? sampleFilters})
1010+
Job({String? description, required String logDir, int maxConnections, required List<String> models, Map<String, Map<String, dynamic>>? variants, List<String>? taskPaths, Map<String, JobTask>? tasks, bool saveExamples, Map<String, dynamic>? sandbox, Map<String, dynamic>? inspectEvalArguments, TagFilter? taskFilters, TagFilter? sampleFilters})
10111011
```
10121012

10131013
#### `Job.fromJson`
@@ -1203,7 +1203,7 @@ former `TaskConfig` model-package class.
12031203
#### `ParsedTask`
12041204

12051205
```dart
1206-
ParsedTask({required String id, required String func, required List<Sample> samples, required Variant variant, String sandboxType, String? systemMessage, bool saveExamples, String? examplesDir, Map<String, dynamic>? sandboxParameters, Map<String, String>? taskFiles, String? taskSetup, String? model, Map<String, dynamic>? config, Map<String, String>? modelRoles, Object? sandbox, Object? approval, Object? epochs, Object? failOnError, bool? continueOnFail, int? messageLimit, int? tokenLimit, int? timeLimit, int? workingLimit, double? costLimit, Object? earlyStopping, String? displayName, Object? version, Map<String, dynamic>? metadata})
1206+
ParsedTask({required String id, required String func, required List<Sample> samples, required Variant variant, String sandboxType, String? systemMessage, bool saveExamples, String? examplesDir, Map<String, dynamic>? sandboxParameters, Map<String, String>? taskFiles, String? taskSetup, String? model, Map<String, dynamic>? config, Map<String, String>? modelRoles, Object? sandbox, Object? approval, Object? epochs, Object? failOnError, bool? continueOnFail, int? messageLimit, int? tokenLimit, int? timeLimit, int? workingLimit, double? costLimit, Object? earlyStopping, String? displayName, Object? version, Map<String, dynamic>? metadata, String datasetFormat, String? datasetSource, Map<String, dynamic>? datasetArgs})
12071207
```
12081208

12091209
### Properties
@@ -1304,6 +1304,18 @@ ParsedTask({required String id, required String func, required List<Sample> samp
13041304

13051305
Additional metadata to associate with the task.
13061306

1307+
- **`datasetFormat`** → `String` *(final)*
1308+
1309+
Dataset format: 'memory' (inline samples), 'json', or 'csv'.
1310+
1311+
- **`datasetSource`** → `String?` *(final)*
1312+
1313+
File path or URL for json/csv datasets.
1314+
1315+
- **`datasetArgs`** → `Map<String, dynamic>?` *(final)*
1316+
1317+
Extra kwargs passed to json_dataset() or csv_dataset().
1318+
13071319
### Methods
13081320

13091321
#### `copyWith`
@@ -1722,6 +1734,10 @@ Job createDefaultJob(String baseDir)
17221734

17231735
Create a [Job] with default settings (when no job file is provided).
17241736

1737+
Note: The caller must specify models, as there are no defaults.
1738+
This method creates a job with an empty models list; the resolver
1739+
will raise an error if models is empty at resolution time.
1740+
17251741
**Parameters:**
17261742

17271743
- `baseDir` (`String`) *(required)*

‎packages/dash_evals/pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"openai>=2.8.1,<3.0.0",
1616
"firebase-admin>=6.0.0,<8.0.0",
1717
"pydantic>=2.0.0,<3.0.0",
18+
"dataset-config-python",
1819
]
1920

2021
[project.optional-dependencies]

‎packages/dash_evals/src/dash_evals/runner/json_runner.py‎

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212

1313
import inspect_ai
14-
from inspect_ai.dataset import MemoryDataset, Sample, csv_dataset, json_dataset
14+
from dataset_config_python.hydrate import build_dataset as _build_dataset
1515

1616
from dash_evals.utils.logging import capture_output, setup_logging
1717

@@ -94,74 +94,8 @@ def _resolve_task_func(name: str):
9494
return func
9595

9696

97-
def _build_dataset(task_def: dict):
98-
"""Build an Inspect AI dataset from a task definition.
9997

100-
Dispatches on ``task_def["dataset"]["format"]``:
10198

102-
- ``"memory"`` (default): builds a ``MemoryDataset`` from inline samples.
103-
- ``"json"``: delegates to ``inspect_ai.dataset.json_dataset(source, **args)``.
104-
- ``"csv"``: delegates to ``inspect_ai.dataset.csv_dataset(source, **args)``.
105-
106-
Args:
107-
task_def: A task entry from the EvalSet JSON manifest.
108-
109-
Returns:
110-
An Inspect AI dataset object.
111-
112-
Raises:
113-
ValueError: If the dataset format is unrecognized or required fields
114-
(e.g. ``source`` for json/csv) are missing.
115-
"""
116-
dataset_def = task_def.get("dataset")
117-
task_name = task_def.get("name", "")
118-
119-
if not dataset_def:
120-
return MemoryDataset([], name=task_name)
121-
122-
fmt = dataset_def.get("format", "memory")
123-
extra_args: dict = dataset_def.get("args") or {}
124-
125-
if fmt == "json":
126-
source = dataset_def.get("source")
127-
if not source:
128-
raise ValueError(
129-
f"Task '{task_name}': dataset format 'json' requires a 'source' field."
130-
)
131-
return json_dataset(source, **extra_args)
132-
133-
if fmt == "csv":
134-
source = dataset_def.get("source")
135-
if not source:
136-
raise ValueError(
137-
f"Task '{task_name}': dataset format 'csv' requires a 'source' field."
138-
)
139-
return csv_dataset(source, **extra_args)
140-
141-
if fmt == "memory":
142-
raw_samples = dataset_def.get("samples", [])
143-
samples = []
144-
for raw in raw_samples:
145-
sample = Sample(
146-
input=raw["input"],
147-
target=raw.get("target", ""),
148-
id=raw.get("id"),
149-
metadata=raw.get("metadata"),
150-
files=raw.get("files"),
151-
setup=raw.get("setup"),
152-
sandbox=raw.get("sandbox"),
153-
)
154-
samples.append(sample)
155-
156-
return MemoryDataset(
157-
samples,
158-
name=dataset_def.get("name", task_name),
159-
)
160-
161-
raise ValueError(
162-
f"Task '{task_name}': unknown dataset format '{fmt}'. "
163-
f"Expected one of: 'memory', 'json', 'csv'."
164-
)
16599

166100

167101
def run_from_json(manifest_path: str | Path) -> bool:

0 commit comments

Comments
 (0)