Repository navigation
refactor(pipeline): take the run's inputs as an EvaluationSettings #1648
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
base: main
Are you sure you want to change the base?
Changes from all commits
8f06729
fc1c9e9
a09fa85
5e3347c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Added | ||
|
|
||
| - **`EvaluationPipeline` accepts an `EvaluationSettings` object.** Python callers can pass the same run settings as one object with `EvaluationPipeline(settings=...)`. Existing positional and keyword arguments still work. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Settings for one run of :class:`~dokimi.orchestrator.pipeline.EvaluationPipeline`.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
| from typing import Any, Callable, Optional | ||
|
|
||
| from dokimi.defaults import (DEFAULT_ANSWER_MODEL, DEFAULT_ANSWER_PROVIDER, DEFAULT_JUDGE_MODEL, DEFAULT_JUDGE_PROVIDER, | ||
| DEFAULT_RETRIEVAL_TOP_K) | ||
| from dokimi.orchestrator.arm_answering import Checkpoint | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix before merge (blocking): No test checks that Suggestion: Add a test to I tested this patch: it fixes the problem, and the tests still pass. Patch--- a/dokimi/tests/test_pipeline_settings.py
+++ b/dokimi/tests/test_pipeline_settings.py
@@ -3,7 +3,7 @@
"""EvaluationPipeline takes its inputs as an EvaluationSettings, or as the same fields as keywords."""
-from dataclasses import fields
+from dataclasses import FrozenInstanceError, fields
from pathlib import Path
import pytest
@@ -51,6 +51,12 @@
assert "settings" not in names
+def test_the_settings_object_is_frozen(tmp_path):
+ settings = EvaluationSettings(product="oneTBB", output_dir=tmp_path, description="d")
+ with pytest.raises(FrozenInstanceError):
+ settings.product = "other"
+
+
def test_settings_and_keywords_together_are_refused(tmp_path):
settings = EvaluationSettings(product="oneTBB", output_dir=tmp_path, description="d")
with pytest.raises(TypeError, match="takes settings or keyword arguments, not both"):DetailsThe description calls the settings object frozen, and it is: assigning to a field raises |
||
| class EvaluationSettings: | ||
| """ | ||
| The inputs of one pipeline run. ``EvaluationPipeline(settings=...)`` takes this | ||
| object; ``EvaluationPipeline(**fields)`` builds it from the same fields. | ||
|
|
||
| Fields: | ||
| product: Product name (e.g., "oneDNN") | ||
| output_dir: Base directory for outputs | ||
| repo: GitHub repo (e.g., "oneapi-src/oneDNN"). Optional — when | ||
| omitted, ``description`` must be provided so the LLM can | ||
| generate personas without GitHub data. | ||
| description: Plain-text description of the product. Used as the | ||
| sole signal for persona generation when ``repo`` is not given. | ||
| Also useful to supplement GitHub data. | ||
| custom_questions_path: Optional path to manual questions JSON | ||
| model: LLM model for generation/answering | ||
| provider: Provider for generation/answering | ||
| judge_model: LLM model for evaluation | ||
| judge_provider: Provider for evaluation | ||
| judge_temperature: Optional judge sampling temperature; unset leaves | ||
| the provider default | ||
| personas_count: Target number of personas | ||
| questions_per_topic: Questions per topic per persona | ||
| top_k: Docs to retrieve before reranking | ||
| rerank_threshold: Min relevance score | ||
| debug_retrieval: Include retrieval metadata | ||
| doc_source: Documentation source descriptor — 'context7' (default), | ||
| 'local:<path>', or 'url:<url>' | ||
| context7_id: Explicit Context7 library ID (e.g., 'intel/mkl-dnn'). | ||
| Overrides the auto-resolved ID when doc_source is 'context7'. | ||
| max_tokens_per_question: Token budget for documentation retrieved per question | ||
| force_regen: Regenerate the question set even when a cached one exists | ||
| questions_from: Reuse an existing question set (file, or a run | ||
| directory holding questions/<product_key>.json). | ||
| product_key: Registry key used for output file names and golden | ||
| question-set lookup (defaults to ``product``). | ||
| questions_root: Directory holding golden question sets named | ||
| ``<product_key>_golden.json``, for example a checkout of the | ||
| evaluation-content repository. When given and the file is | ||
| present it is the run's whole question set and generation is | ||
| skipped; when it is absent a warning is logged and questions are | ||
| generated. Without this argument (and without | ||
| ``custom_questions_path``) the run has no golden set. | ||
| registry: ProductRegistry used to find the declared context7_id | ||
| (default: the bundled products.yaml) | ||
| judge_placeholder: No effect, warned: since method version 4 the | ||
| context arm answers a question with no document found with the | ||
| plain prompt, and that answer is judged (#228 step 4c) | ||
| checkpoint: Makes the file the answered questions are kept in until | ||
| the answers file is saved, from the answers path | ||
| (``commands.arms.pipeline_checkpoint``); none by default | ||
| """ | ||
|
|
||
| product: str | ||
| output_dir: Path | ||
| repo: Optional[str] = None | ||
| description: Optional[str] = None | ||
| custom_questions_path: Optional[Path] = None | ||
| model: str = DEFAULT_ANSWER_MODEL | ||
| provider: str = DEFAULT_ANSWER_PROVIDER | ||
| judge_model: str = DEFAULT_JUDGE_MODEL | ||
| judge_provider: str = DEFAULT_JUDGE_PROVIDER | ||
| judge_temperature: Optional[float] = None | ||
| personas_count: int = 5 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must fix (blocking): No test checks the defaults: if I change Also at: Suggestion: Add a test to I tested this patch: it fixes the problem, and the tests still pass. Patch--- a/dokimi/tests/test_pipeline_settings.py
+++ b/dokimi/tests/test_pipeline_settings.py
@@ -72,3 +72,9 @@
def test_the_settings_are_not_stored_on_the_pipeline(tmp_path):
pipe = EvaluationPipeline(settings=EvaluationSettings(product="oneTBB", output_dir=Path(tmp_path), description="d"))
assert not any(isinstance(v, EvaluationSettings) for v in vars(pipe).values())
+
+
+def test_the_fields_keep_their_defaults(tmp_path):
+ settings = EvaluationSettings(product="oneTBB", output_dir=tmp_path, description="d")
+ assert (settings.personas_count, settings.questions_per_topic, settings.max_tokens_per_question,
+ settings.judge_placeholder) == (5, 2, 4000, False)DetailsI changed |
||
| questions_per_topic: int = 2 | ||
| top_k: int = DEFAULT_RETRIEVAL_TOP_K | ||
| rerank_threshold: float = 0.3 | ||
| debug_retrieval: bool = False | ||
| doc_source: str = "context7" | ||
| context7_id: Optional[str] = None | ||
| max_tokens_per_question: int = 4000 | ||
| force_regen: bool = False | ||
| questions_from: Optional[Path] = None | ||
| product_key: Optional[str] = None | ||
| questions_root: Optional[Path] = None | ||
| registry: Optional[Any] = None | ||
| judge_placeholder: bool = False | ||
| checkpoint: Optional[Callable[[Path], Checkpoint]] = None | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix before merge (blocking): No test covers positional arguments passed with
settings=: removing the check atpipeline.py:114passes every changed test.Suggestion: Add a case to
dokimi/tests/test_pipeline_settings.pythat passes one positional argument together withsettings=and expects thenot bothTypeError.I tested this patch: it fixes the problem, and the tests still pass.
Patch
Details
I tried
EvaluationPipeline("other", path, settings=settings). The latest commit refuses it with thenot bothTypeError atpipeline.py:114. If I changeelif args or kwargs:toelif kwargs:, the call goes through with the positional argument silently ignored, and every changed test still passes, because the tests only combinesettings=with keyword arguments.