-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add more functionality to the Config class #467
Add more functionality to the Config class #467
Conversation
Codecov Report
@@ Coverage Diff @@
## v1.0.0.dev #467 +/- ##
============================================
Coverage 100.00% 100.00%
============================================
Files 14 14
Lines 1159 1180 +21
============================================
+ Hits 1159 1180 +21
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just a few comments about adding some setter methods and not exposing this class to the user
'sdtypes': self.field_sdtypes, | ||
'transformers': self.field_transformers | ||
}) | ||
return self.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question is whether or not we should expose the actual config class to the user. Maybe we just return the dict as it used to be to them, but when they call set_config
we create the special class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return a custom version of the dict (what the config class used to be) that prints nicely. I don't think we want to expose this whole class to them since it might be confusing
rdt/hyper_transformer.py
Outdated
if sdtype in self._default_sdtype_transformers: | ||
self.field_transformers[field] = self._default_sdtype_transformers[sdtype] | ||
default_transformer = self._default_sdtype_transformers[sdtype] | ||
self.config['field_transformers'][field] = default_transformer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of adding methods to let the HyperTransformer
interact with the Config
instead of doing it directly. That way people don't accidently forget to update the _provided
dicts if necessary. So maybe an add_transformer(provided)
method that adds it to config.field_transformers
and if provided
is True
, then also config._provided_transformers
. Same for field_sdtypes
rdt/hyper_transformer.py
Outdated
self['field_transformers'].update(config['transformers']) | ||
|
||
def __init__(self, config=None): | ||
super().__init__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class probably no longer needs to inherit from dict
. It could take a dict in the __init__
and set things up accordingly. This would discourage people from using the class like a dict and encourage them to use the setter methods we create instead
5ce4474
to
33200f9
Compare
column_name_to_transformer(dict): | ||
Dict mapping column names to transformers to be used for that column. | ||
provided_transformer(bool): | ||
Wether or not to add to `self._provided_field_transformers`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: whether
self.field_transformers[field] = transformer | ||
|
||
def update_transformers(self, column_name_to_transformer, provided_transformer=False): | ||
"""Update `self.field_transformers`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we agreed to do double ` characters instead of just one.
self.set_config(config) | ||
|
||
def reset(self): | ||
"""Reset the `field_sdtypes` and `field_transformers`.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use double `
'sdtypes': self.field_sdtypes, | ||
'transformers': self.field_transformers | ||
}) | ||
return self.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return a custom version of the dict (what the config class used to be) that prints nicely. I don't think we want to expose this whole class to them since it might be confusing
We may rework this in the future. |
Resolve #457