feat: generalize config float parsing#488
Open
agitter wants to merge 1 commit into
Open
Conversation
Open
tristan-f-r
reviewed
Jun 14, 2026
| from spras.util import LoosePathLike, NpHashEncoder, hash_params_sha1_base32 | ||
|
|
||
| # Modify YAML float specification when a YAML file is parsed directly | ||
| # Default requires decimal point for scientific notation: https://yaml.org/type/float.html |
Collaborator
There was a problem hiding this comment.
While the YAML specification itself doesn't support this, Pydantic handles coercion of floats from strings just fine, including with scientific notation. This error was instead caused by my assumption that this coercion would happen before any BeforeValidator was run, which is notably the opposite of the characterization of BeforeValidator: I've proposed an alternative fix instead.
Collaborator
There was a problem hiding this comment.
The alternative fix is very clean, I am curious if it will pass the tests Tony set up.
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.
Closes #484
This implements two fixes for the limited syntax supported by the default YAML float specification: https://yaml.org/type/float.html
add_implicit_resolveris used when we load a YAML file directly.sanitize_scientific_notationis used when Snakemake loads the config file because we cannot modify it's YAML loader soon enough.I used Gemini to help plan the patch and draft code.