Skip to content

fix: honor zero values in Dataset.reset_seeds - #9906

Merged
isaacbmiller merged 2 commits into
stanfordnlp:mainfrom
alvinttang:fix/dataset-reset-seeds-zero
Aug 15, 2026
Merged

isaacbmiller merged 2 commits into
stanfordnlp:mainfrom
alvinttang:fix/dataset-reset-seeds-zero

Conversation

@alvinttang

Copy link
Copy Markdown
Contributor

Dataset.reset_seeds updates each seed/size with value or self.value. Since 0 is falsy, passing a valid 0 is silently dropped and the previous value is kept.

Repro:

from dspy.datasets.dataset import Dataset
d = Dataset(train_seed=5, train_size=10)
d.reset_seeds(train_seed=0, train_size=0)
print(d.train_seed, d.train_size)  # prints "5 10", expected "0 0"

This affects anyone resetting to seed 0 (a common default) or requesting an empty split with size 0.

Fix: replace the or fallbacks with explicit is not None checks so 0 is applied while omitted (None) arguments still leave the existing value untouched. Added tests covering both the zero case and the omitted-argument behavior.

reset_seeds used `x or self.x` to decide whether to apply each argument,
so passing 0 (a valid seed or size) was treated as falsy and silently
dropped, keeping the previous value instead. Use an explicit None check
so 0 is honored.
@greptile-apps

greptile-apps Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This update correctly accepts explicit zero values for dataset seeds and split sizes, while preserving existing settings when arguments are omitted. Runtime checks confirmed that both evaluation-derived split seeds remain unchanged when eval_seed is not provided.

Confidence Score: 5/5

No blocking failure remains.

Focused runtime checks verified zero-value overrides, cached split invalidation, and preservation of both development and test seeds when evaluation settings are omitted.

T-Rex T-Rex Logs

What T-Rex did

  • Reproduced the historical regression by running the dataset-reset-seeds-regression verifier with the legacy implementation, which exited with code 1.
  • Verified the current implementation by running the same verifier with --implementation current, which exited with code 0 and confirmed that six zero-valued arguments apply, cached splits resample to length zero, and omitting eval_seed preserves dev_seed and test_seed.
  • No tracked source files were modified, and the authored verifier and its command captures were saved as artifacts.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "Apply suggestion from @greptile-apps[bot..." | Re-trigger Greptile

Comment thread tests/datasets/test_dataset.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: Isaac Miller <17116851+isaacbmiller@users.noreply.github.com>
@isaacbmiller

Copy link
Copy Markdown
Collaborator

lgtm

@isaacbmiller
isaacbmiller merged commit 15c62d4 into stanfordnlp:main Aug 15, 2026
20 checks passed
marcodelpin pushed a commit to marcodelpin/dspy that referenced this pull request Aug 15, 2026
… PythonInterpreter request-handling hardening stanfordnlp#10208, Dataset.reset_seeds zero-values stanfordnlp#9906)
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.

2 participants