Fix/issue 30 docs and template#32
Merged
Merged
Conversation
…ter ABC
docs/reference/api.md previously documented a fictional EnvAdapter API
(execute / evaluate / build_prompt + DataItem / TaskResult) and a
BENCHMARK_REGISTRY that never existed in code. Anyone following the
documented contract would hit ImportError or TypeError on the first
instantiation.
Replace both pages with the real shape from skillopt/envs/base.py and
skillopt/datasets/base.py:
- EnvAdapter: build_train_env, build_eval_env, rollout, reflect,
get_task_types (the 5 actual abstract methods).
- Rollout dicts: id / hard / soft required; everything else preserved
into RolloutResult.extras.
- Reflect dicts: {patch, source_type} schema as consumed by
run_minibatch_reflect.
- BatchSpec: slotted-but-mutable dataclass matching the actual
definition (payload defaults to None, metadata to dict()).
- SplitDataLoader.load_split_items as the one mandatory loader method.
- Registry: _ENV_REGISTRY in scripts/train.py (lazy try/except
ImportError block), not a non-existent BENCHMARK_REGISTRY in
skillopt/envs/__init__.py.
- _base_: documented as a string path, since the current YAML loader
only accepts strings.
The new-benchmark.md guide now walks through a docfaithful worked
example with a real rollout helper (chat_target + scorer) instead of
hand-waving over the rollout step. Refs microsoft#30.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
The shipped env_template.py and loader_template.py described the same fictional async execute / evaluate / build_prompt API documented in docs/reference/api.md. As a result TemplateBenchmarkEnv(cfg) raised 'TypeError: Can't instantiate abstract class' for every copy-and-paste user who followed the in-tree scaffold. Rewrite the template so it's a working starting point: - env_template.py: TemplateBenchmarkEnv(EnvAdapter) now implements all five real abstract methods (build_train_env, build_eval_env, rollout, reflect, get_task_types) with no-op defaults documented as TODO. Instantiable today; pytest 60/60 still passes. - loader_template.py: TemplateBenchmarkLoader(SplitDataLoader) implements load_split_items for .json / .jsonl input and explains the optional load_raw_items override for split_mode="ratio". - README.md: usage steps now point at scripts/train.py's _ENV_REGISTRY (the real registry) instead of a non-existent BENCHMARK_REGISTRY in skillopt/envs/__init__.py, and link to the rewritten new-benchmark guide. - config_template.yaml: _base_ is a string path (not a list, which the loader rejects); skill_init is commented out with a note so the template config doesn't reference a file the user hasn't created. Verified locally: 'from skillopt.envs._template.env_template import TemplateBenchmarkEnv; TemplateBenchmarkEnv()' succeeds. Refs microsoft#30. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Issue #30 reported that
docs/reference/api.md,docs/guide/new-benchmark.md,and
skillopt/envs/_template/all described a fictionalEnvAdapterAPI(
execute / evaluate / build_prompt+DataItem / TaskResult+BENCHMARK_REGISTRY+skillopt.data.base) that does not exist in thecodebase. Following the guide ended in
ImportError,TypeError: Can't instantiate abstract class, orValueError: Unknown environment.This PR rewrites the docs + template to match the real ABC in
skillopt/envs/base.pyandskillopt/datasets/base.py. No productioncode is touched.
Changes
docs/reference/api.md— replaces the fictional API with the real 5abstract methods (
build_train_env / build_eval_env / rollout / reflect / get_task_types), correctBatchSpecshape, realSplitDataLoadercontract, and a note that registration lives in_ENV_REGISTRY(inscripts/train.py), not aBENCHMARK_REGISTRY.docs/guide/new-benchmark.md— full workeddocfaithfulexampleincluding loader, rollout helper (using
skillopt.model.chat_target),adapter, registration block, and a
_base_:string-form config.skillopt/envs/_template/— template now subclasses the real ABCsand is instantiable out of the box.
Verified
pytest tests/→ 60/60 passedpython -c "from skillopt.envs._template.env_template import TemplateBenchmarkEnv; TemplateBenchmarkEnv()"succeedspython scripts/train.py --helpunchangedcodex exec --sandbox read-only(second pass: APPROVE)Closes #30.