-
Notifications
You must be signed in to change notification settings - Fork 6
(3/n) Introduce declarative YAML task definitions #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kargibora
wants to merge
12
commits into
refactor/benchmark-packages-main
from
refactor/task-yaml-core
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2155e29
Add declarative task registry
kargibora 54627ab
Resolve task runtime policy from YAML
kargibora 782ec88
Load registered datasets from task YAML
kargibora 196ed9a
Record task definition provenance
kargibora 46395df
refactor: address review feedback on task CLI dispatch and download_hf
kargibora e26dc47
refactor: collapse task registry into load_tasks() dict
kargibora 5297408
refactor: log task validate status instead of printing it
kargibora 4e62ab5
Merge remote-tracking branch 'origin/refactor/benchmark-packages-main…
kargibora b95a160
refactor: name the task-CLI dispatch condition (review feedback)
kargibora 3dc21c0
fix: ruff check
kargibora b744f37
refactor: configure default logging before CLI dispatch
kargibora 9dcc6eb
refactor: task subcommands print directly instead of logging
kargibora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from judgearena.cli import cli | ||
|
|
||
| cli() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| """Dataset adapter for JudgeArena's packaged instruction/output tables.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| import pandas as pd | ||
| from huggingface_hub import snapshot_download | ||
|
|
||
| from judgearena.tasks.schema import HuggingFaceDatasetSource, ResolvedTaskSpec | ||
|
|
||
|
|
||
| def download_task_sources(task: ResolvedTaskSpec, local_dir: Path) -> None: | ||
| """Download every Hugging Face source declared by a table-backed task.""" | ||
| if task.spec.dataset.adapter != "judgearena_tables": | ||
| raise ValueError( | ||
| f"Task {task.task!r} uses dataset adapter " | ||
| f"{task.spec.dataset.adapter!r}, not 'judgearena_tables'." | ||
| ) | ||
| local_dir.mkdir(exist_ok=True, parents=True) | ||
| for name, source in task.spec.dataset.sources.items(): | ||
| if not isinstance(source, HuggingFaceDatasetSource): | ||
| raise ValueError( | ||
| f"Dataset source {name!r} for task {task.task!r} is not supported " | ||
| "by the 'judgearena_tables' adapter." | ||
| ) | ||
| snapshot_download( | ||
| repo_id=source.repo_id, | ||
| repo_type="dataset", | ||
| revision=source.revision, | ||
| allow_patterns=list(source.allow_patterns) or None, | ||
| local_dir=local_dir, | ||
| force_download=False, | ||
| ) | ||
|
|
||
|
|
||
| def load_task_instructions( | ||
| task: ResolvedTaskSpec, local_tables_path: Path | ||
| ) -> pd.DataFrame: | ||
| """Load a task's table and map its declared fields to runner names.""" | ||
| download_task_sources(task, local_tables_path) | ||
| path = local_tables_path / "instructions" / f"{task.task}.csv" | ||
| if not path.exists(): | ||
| raise FileNotFoundError(f"Instruction table not found at {path}") | ||
| df = pd.read_csv(path) | ||
|
|
||
| fields = task.spec.dataset.fields | ||
| field_mapping = { | ||
| fields.id: "instruction_index", | ||
| fields.instruction: "instruction", | ||
| } | ||
| if fields.category is not None: | ||
| field_mapping[fields.category] = "category" | ||
| missing = sorted(set(field_mapping) - set(df.columns)) | ||
| if missing: | ||
| raise ValueError( | ||
| f"Task {task.task!r} is missing declared dataset fields: {missing}." | ||
| ) | ||
| return df.rename(columns=field_mapping) | ||
|
|
||
|
|
||
| def load_task_model_outputs( | ||
| task: ResolvedTaskSpec, local_tables_path: Path | ||
| ) -> pd.DataFrame | None: | ||
| """Load optional pre-generated model outputs for a table-backed task.""" | ||
| download_task_sources(task, local_tables_path) | ||
| path = local_tables_path / "model_outputs" / f"{task.task}.csv.zip" | ||
| if not path.exists(): | ||
| return None | ||
| return pd.read_csv(path) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.