(3/n) Introduce declarative YAML task definitions - #81
Conversation
geoalgo
left a comment
There was a problem hiding this comment.
LGTM overall, I have left some comments.
| args = list(sys.argv[1:] if argv is None else argv) | ||
| if args[:1] == ["tasks"]: | ||
| from judgearena.tasks.cli import run_task_command | ||
|
|
||
| run_task_command(args[1:]) | ||
| return | ||
|
|
||
| try: | ||
| cfg = build_run_config(argv) | ||
| cfg = build_run_config(args) |
There was a problem hiding this comment.
Can you add a comment here on the rationale? Why doing run_task_command only when "tasks" is passed as CLI?
It is not obvious to understand what this code does.
There was a problem hiding this comment.
Hi David,
This function basically changes the execution flow for the main entry point. If judgearena tasks if provided we can execute arbitrary command like --list to see all the available tasks (or validate any) - if not provided simply execute the workflow. I think we can discard this if you think we dont need such functionality but for completeness I did implement it anyways.
There was a problem hiding this comment.
Ok I would suggest something like this to improve readability:
is_task_cli = args[:1] == ["tasks"]
if is_task_cli:
# handle the case where we run `judgearena tasks ARGS`
from judgearena.tasks.cli import run_task_command
run_task_command(args[1:])
else:
# generic case for other commands
cfg = build_run_config(args)which is more readable (but still a bit hacky).
There was a problem hiding this comment.
I agree, this is more readable
| return merged | ||
|
|
||
|
|
||
| class TaskLoader: |
There was a problem hiding this comment.
See my other comment, we just need one function to load all tasks which returns a dict all of those can be in the same file.
There was a problem hiding this comment.
I thing merging these two into a single registry would make the registry larger, as function wise, registry.py handles resolving the tasks by calling the loader. However as registry is the only script that calls TaskLoader, it is also OK to put them all in.
However, compared to TaskRegistry which is basically a dict, I feel like TaskLoader class is more graceful. Instead of providing the functions like load,..., discover, it just provides a single object loader which just handles all the things we want to do.
Happy to convert it to functions or merge it with registry if you think that is more cleaner and readable approach
There was a problem hiding this comment.
Why do we need both? Both seems to be utils to load tasks?
It seems that this class has complex logic to detect whether tasks are valid after a recursive walk.
I think we can make it much simpler, just browse for files with exact names "task_config.yaml" in subdirs.
We do not want to do any patching, anything that does not match convention should just be rejected with a warning possibly.
There was a problem hiding this comment.
So the catch is future PR's introduces some smarter logic for loading and extending tasks. For example specifying xxx-en will be load the english dataset or some datasets like official protocol configs we are willing to add extendes the `base.yaml.
There was a problem hiding this comment.
sorry cant parse your sentence.
There was a problem hiding this comment.
Ah sorry. I got your question wrong. We can indeed just merge these two functionailties, because TaskLoader is never called in other places. There should be some complex logic for resolving the task, but it can be handled by the functions instead of some class object. I will simplify it
0ca3154 to
14bb329
Compare
Define validated YAML task specifications with discovery commands and package AlpacaEval as the first task.
Use registered definitions for runner, baseline, prompt, and judge defaults while retaining fallbacks for unmigrated tasks.
Use task-declared source revisions and field mappings for instruction and pre-generated output tables.
Store compact task versions and resolved YAML hashes in run metadata without embedding the full definition.
- cli.py: comment the reason tasks subcommands are routed before build_run_config - paths.py: remove the dead duplicate download_hf (shadowed by utils/io.py) and its now-unused imports - utils/io.py: use if/else and comment the packaged-task vs legacy dataset branches
Replace the TaskRegistry class and its dict-facade API (get/find/list/ validate_all) with a cached load_tasks() -> dict[str, ResolvedTaskSpec] and dict access at call sites. Drop the ValidationReport, TaskSummary, and UnknownTaskError wrappers; the CLI now formats the unknown-task message and counts with len(). get_packaged_task stays as the thin load_tasks().get() helper used across the codebase. Addresses review comments #3 and #6.
Route the 'tasks validate' confirmation through logger.info (status, to stderr) and configure logging on the tasks CLI path, keeping print for list/show which emit results to stdout.
14bb329 to
5297408
Compare
| return merged | ||
|
|
||
|
|
||
| class TaskLoader: |
There was a problem hiding this comment.
sorry cant parse your sentence.
|
|
||
| configure_logging() | ||
| run_task_command(args[1:]) | ||
| return |
There was a problem hiding this comment.
we still have return, can you do else as described in the comment bellow?
There was a problem hiding this comment.
Fixed it, as there was few blocks I did not put else: but it makes it more readable.
| if is_task_cli: | ||
| from judgearena.tasks.cli import run_task_command | ||
|
|
||
| configure_logging() |
There was a problem hiding this comment.
why would we configure logging only in this case? dont we want to have it before the if?
There was a problem hiding this comment.
So there was a bit confusion.. Because run_task_command basically executes task/cli.py, which has logging but in cli.py, we configure logging using verbosity and log_file for the main executions. However we actually do not need logging for the task commands so I think its safer to simply remove it
There was a problem hiding this comment.
Fixed this, we dont need logging for task commands which just validates or prints a task. logging is useful if we want to have some organized hierarchy in logging as well as a way to save them for debugging & reporting.
Summary
Task-specific configuration is currently distributed across Python constants, dataset loaders, baseline mappings, prompt
registries, and runner conditions. Adding or changing a task therefore requires modifying several unrelated modules.
This PR introduces declarative YAML task definitions, inspired by the task packaging approach used by lm-evaluation-
harness.
AlpacaEval is migrated as the first packaged task. Existing benchmarks continue using their current fallback behavior
until they are migrated in later PRs.
Task definitions
A task YAML describes the stable contract of a benchmark:
The main sections are:
The protocol does not contain implementation code. It references registered components such as pairwise,
judgearena_tables, pairwise_preference, and pairwise_win_rate.
Main components
The new task package contains three main responsibilities:
The schema defines the supported dataset sources, baseline strategies, judge settings, and scoring configuration.
Unknown fields are rejected.
The loader reads YAML safely, resolves optional _base.yaml inheritance, and calculates hashes for the source and
resolved definitions.
The registry discovers packaged tasks by ID and verifies that every referenced runner, dataset adapter, prompt,
parser, and scorer exists.
The CLI allows users to inspect and validate task definitions before running them.
Runtime behavior
When a task is executed, JudgeArena resolves it through the registry:
Task ID
-> load and validate task YAML
-> resolve dataset source and field mappings
-> apply task protocol defaults
-> select the registered runner
-> generate, judge, and score
Task definitions provide benchmark defaults, while users can still configure experiment-specific values.
The effective precedence is:
CLI flags -> run config YAML -> task-defined defaults -> framework defaults
For example:
Additional changes
result.