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

Update update_transformers validation #563

Merged
merged 5 commits into from
Oct 13, 2022
Merged

Update update_transformers validation #563

merged 5 commits into from
Oct 13, 2022

Conversation

fealho
Copy link
Member

@fealho fealho commented Oct 7, 2022

Update update_transformers so an error is raised when the sdtype is not supported by the transformer, instead of raising an error.

@fealho fealho marked this pull request as ready for review October 7, 2022 16:40
@fealho fealho requested a review from a team as a code owner October 7, 2022 16:40
incompatible_sdtypes.append(column_name)
raise InvalidSdtypeForTransformerError(
f"Column '{column_name}' is a {current_sdtype} column, which is "
f"incompatible with the '{type(transformer).__name__}' transformer."
Copy link
Member

Choose a reason for hiding this comment

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

🤔 Should we add a get_name method to the BaseTransformer and use that whenever we want to get the __name__ ?

Comment on lines 258 to 262
hypertransformer.detect_initial_config(input_data)
hypertransformer.update_transformers(field_transformers)
try:
hypertransformer.update_transformers(field_transformers)
except InvalidSdtypeForTransformerError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead we could use the set_config method and avoid having this error get raised altogether

Copy link
Member Author

Choose a reason for hiding this comment

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

It will still run into an error, since we have a version of it validating set_config as well:

if mismatched_columns:
raise Error(
"Some transformers you've assigned are not compatible with the sdtypes. "
f'Please change the following columns: {mismatched_columns}'
)

Copy link
Contributor

Choose a reason for hiding this comment

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

When we set the config can't we force the sdtype to match?

rdt/errors.py Outdated
@@ -7,3 +7,7 @@ class NotFittedError(Exception):

class Error(Exception):
"""Error to raise when ``HyperTransformer`` produces a controlled error message."""


class InvalidSdtypeForTransformerError(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should change this error name to match the ones we created in the doc. You won't need to catch this error anymore in the integration tests if you do the other change

@fealho fealho requested a review from amontanez24 October 12, 2022 19:54
rdt/errors.py Outdated
@@ -9,5 +9,5 @@ class Error(Exception):
"""Error to raise when ``HyperTransformer`` produces a controlled error message."""


class InvalidSdtypeForTransformerError(Exception):
"""Error to raise when the sdtype is not supported by the transformer."""
class SynthesizerInputError(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be TransformerInputError. The synthesizer prefixes will only be for SDV

Comment on lines 258 to 262
hypertransformer.detect_initial_config(input_data)
hypertransformer.update_transformers(field_transformers)
try:
hypertransformer.update_transformers(field_transformers)
except InvalidSdtypeForTransformerError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

When we set the config can't we force the sdtype to match?

@fealho fealho requested a review from amontanez24 October 13, 2022 15:21
@codecov-commenter
Copy link

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (9093465) compared to base (52ed8a0).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #563   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1523      1524    +1     
=========================================
+ Hits          1523      1524    +1     
Impacted Files Coverage Δ
rdt/errors.py 100.00% <100.00%> (ø)
rdt/hyper_transformer.py 100.00% <100.00%> (ø)
rdt/transformers/__init__.py 100.00% <100.00%> (ø)
rdt/transformers/base.py 100.00% <100.00%> (ø)
rdt/transformers/pii/anonymizer.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

'sdtypes': sdtypes,
'transformers': field_transformers
}
hypertransformer.detect_initial_config(input_data)
Copy link
Contributor

@amontanez24 amontanez24 Oct 13, 2022

Choose a reason for hiding this comment

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

you can just delete this line now. You only need to detect if you don't set it

Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

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

One last comment, but then it should be good to go!

@fealho fealho merged commit 9b89282 into master Oct 13, 2022
@fealho fealho deleted the add-sdtype-validation branch October 13, 2022 17:04
@amontanez24 amontanez24 added this to the 1.3.0 milestone Jan 18, 2023
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.

4 participants