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

Schemafy merge_fixed_preprocessing_params #3223

Merged
merged 11 commits into from
Mar 8, 2023
Merged

Schemafy merge_fixed_preprocessing_params #3223

merged 11 commits into from
Mar 8, 2023

Conversation

tgaddair
Copy link
Collaborator

@tgaddair tgaddair commented Mar 8, 2023

Also removes checks on config dict that are covered by existing marshmallow schema validation. These checks were only needed for the merge logic.

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

Unit Test Results

         6 files           6 suites   6h 21m 24s ⏱️
  4 045 tests   4 002 ✔️   43 💤 0
12 134 runs  12 002 ✔️ 132 💤 0

Results for commit 5fc840d.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@connor-mccorm connor-mccorm left a comment

Choose a reason for hiding this comment

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

LGTM! Just one comment regarding adding Optional typing spec to image feature preproc params.

@@ -37,7 +37,7 @@ class ImagePreprocessingConfig(BasePreprocessingConfig):
parameter_metadata=FEATURE_METADATA[IMAGE][PREPROCESSING]["computed_fill_value"],
)

height: int = schema_utils.PositiveInteger(
height: Optional[int] = schema_utils.PositiveInteger(
Copy link
Collaborator

Choose a reason for hiding this comment

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

So in the past, we've refrained from putting optional on parameters since it already has a default of None - so if a user doesn't specify a value here, it will just stay as None. This makes adding the Optional typing sort of redundant. Curious if you had a specific reason for adding this in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not redundant, because the Optional here is primarily useful for static analysis when the config is being used in the Ludwig code. If it's possible for the value to be None, but the type is int, then the expectation from the API user should be that they can treat the value as an int without needing to do any checks for None. But this will lead to them getting NoneType exceptions. Does that make sense?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1. Even if it's redundant, should be marked with Optional or Union[..., None]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see, that makes sense! In that case, I think there's probably a handful of places in the schema where we would want to add in some Optional typing. Obviously out of scope for this PR but that's good to know going forward. Thanks for the detailed explanation!

@tgaddair tgaddair merged commit 635ca8f into master Mar 8, 2023
@tgaddair tgaddair deleted the schema-merge branch March 8, 2023 22:51
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.

None yet

3 participants