Skip to content

fix: allow OptimizationConfig.seed=0 - #359

Closed
HarshRajSinghania wants to merge 1 commit into
deeppavlov:devfrom
HarshRajSinghania:fix/optimization-config-seed-zero
Closed

HarshRajSinghania wants to merge 1 commit into
deeppavlov:devfrom
HarshRajSinghania:fix/optimization-config-seed-zero

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Summary

OptimizationConfig.seed was typed as PositiveInt, so seed=0 raised a validation error. Pipeline(seed=0) and Pipeline.from_search_space(..., seed=0) already accept 0 (int | None). Pipeline.from_preset and Pipeline.from_optimization_config failed because they construct an OptimizationConfig.

Motivation

Fixes #352.

Zero is a valid RNG seed and is the first value of a typical seed grid. Rejecting it forced workarounds such as setting pipeline._seed = 0 after construction.

Implementation

  • Change OptimizationConfig.seed from PositiveInt to NonNegativeInt (still default 42).
  • Negative seeds remain invalid.
  • No other fields or control flow changed.

Testing

Added in tests/configs/test_full_config.py:

  • test_optimization_config_accepts_seed_zero
  • test_optimization_config_rejects_negative_seed

Locally verified Pydantic NonNegativeInt accepts 0 and rejects -1.
The full AutoIntent test suite was not run here (heavy optional deps). The new tests follow the existing config-validation style and should pass with the project's usual pytest tests/configs/test_full_config.py.

Use NonNegativeInt so seed=0 is accepted, matching Pipeline(seed=0).
Negative seeds remain invalid.

Fixes deeppavlov#352
@voorhs

voorhs commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

duplicate of #358

@voorhs voorhs closed this Sep 20, 2026
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

2 participants