Skip to content

fix: allow zero seed in optimization configurations - #358

Open
Gambit-Checkmate wants to merge 1 commit into
deeppavlov:devfrom
Gambit-Checkmate:fix/allow-zero-optimization-seed
Open

Gambit-Checkmate wants to merge 1 commit into
deeppavlov:devfrom
Gambit-Checkmate:fix/allow-zero-optimization-seed

Conversation

@Gambit-Checkmate

Copy link
Copy Markdown

OptimizationConfig(seed=0) currently fails validation, so Pipeline.from_preset(..., seed=0) and the dictionary-config constructor also reject an otherwise valid random seed. Use NonNegativeInt to accept zero while keeping negative seeds invalid, and regenerate the optimizer JSON schema with the same inclusive lower bound.

Closes #352.

Validation on Windows / Python 3.12:

  • Added the regression tests first: all three zero-seed cases failed on the original code.
  • After the fix, python -X utf8 -m pytest tests/configs -q: 40 passed, including positive/negative boundaries and zero-seed propagation through both pipeline constructors. UTF-8 mode avoids an existing default-encoding failure in test_pinned_revisions_module_has_no_runtime_imports on this Windows locale.
  • Regenerated both schemas with python -m scripts.generate_json_schema_config; only the optimizer seed bound changed.
  • Ruff lint and format checks pass for the changed Python files.
  • mypy src/autointent/_optimization_config.py tests/configs/test_full_config.py: success, no issues found.
  • Full model-training tests were not run locally.

AI assistance was used to prepare this change and run these checks.

Signed-off-by: Saturday-boyi <2174084306@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OptimizationConfig.seed is PositiveIntseed=0 is rejected while Pipeline(seed=0) accepts it

1 participant