Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow certain config parameters from accepting null as a value #3079

Merged
merged 12 commits into from
Feb 14, 2023

Conversation

abidwael
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Feb 11, 2023

Unit Test Results

         6 files  +    1           6 suites  +1   5h 28m 7s ⏱️ + 1h 45m 46s
  3 930 tests ±    0    3 892 ✔️  -     1    37 💤 ±  0  1 +1 
11 787 runs  +202  11 675 ✔️ +177  111 💤 +24  1 +1 

For more details on these failures, see this check.

Results for commit b0543ce. ± Comparison against base commit 1f83833.

♻️ This comment has been updated with latest results.

ludwig/schema/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@tgaddair tgaddair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General feedback is that it's confusing to both have None be the default and allow_none=False. I would suggest either:

  • Making allow_none=True the default
  • Making default a required param

@abidwael abidwael requested a review from tgaddair February 13, 2023 07:21
@abidwael
Copy link
Contributor Author

Makes sense @tgaddair.

I made default a required param and kept allow_none=False so we don't run into the same problem when for other parameters in the config or when we add new parameters. I did this for most of the config parameter types (all except Dict, List, and DictList). I kept the rest as they are because it seems like lots of them (if not all) have default=None in the schema. These could be schemafied and that way the default values could live in the schema instead of the model initialization code.

description: str = "",
max: Optional[float] = None,
parameter_metadata: ParameterMetadata = None,
):
"""Returns a dataclass field with marshmallow metadata enforcing numeric inputs must be nonnegative."""
val = validate.Range(min=0.0, max=max)
allow_none = allow_none or default is None
# allow_none = allow_none or default is None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code.

@@ -605,7 +603,7 @@ def FloatRange(
"""Returns a dataclass field with marshmallow metadata enforcing numeric inputs must be in range set by
relevant keyword args."""
val = validate.Range(min=min, max=max, min_inclusive=min_inclusive, max_inclusive=max_inclusive)
allow_none = allow_none or default is None
# allow_none = allow_none or default is None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

assert train_losses[last_entry - 1] <= train_losses[0]
# ensure train loss for last entry is less than to the first entry.
np.testing.assert_array_less(train_losses[last_entry - 1], train_losses[0])
# assert train_losses[last_entry - 1] <= train_losses[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Copy link
Collaborator

@tgaddair tgaddair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only nit is to remove the dead code you commented out.

@abidwael abidwael merged commit ebc81bd into master Feb 14, 2023
@abidwael abidwael deleted the disallow-null branch February 14, 2023 21:52
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.

3 participants