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

Add more functionality to the Config class #467

Conversation

pvk-developer
Copy link
Member

@pvk-developer pvk-developer commented Apr 1, 2022

Resolve #457

@codecov-commenter
Copy link

codecov-commenter commented Apr 6, 2022

Codecov Report

Merging #467 (2b30d0a) into v1.0.0.dev (bb4c29a) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##           v1.0.0.dev      #467   +/-   ##
============================================
  Coverage      100.00%   100.00%           
============================================
  Files              14        14           
  Lines            1159      1180   +21     
============================================
+ Hits             1159      1180   +21     
Impacted Files Coverage Δ
rdt/hyper_transformer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb4c29a...2b30d0a. Read the comment docs.

@pvk-developer pvk-developer marked this pull request as ready for review April 6, 2022 15:47
@pvk-developer pvk-developer requested a review from a team as a code owner April 6, 2022 15:47
@pvk-developer pvk-developer requested review from amontanez24 and removed request for a team April 6, 2022 15:47
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.

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
Copy link
Contributor

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.

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 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

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
Copy link
Contributor

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

self['field_transformers'].update(config['transformers'])

def __init__(self, config=None):
super().__init__()
Copy link
Contributor

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

@pvk-developer pvk-developer force-pushed the issue_457_add_more_functionality_to_config_class branch from 5ce4474 to 33200f9 Compare April 8, 2022 15:25
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`.
Copy link
Contributor

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`.
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 agreed to do double ` characters instead of just one.

self.set_config(config)

def reset(self):
"""Reset the `field_sdtypes` and `field_transformers`."""
Copy link
Contributor

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
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 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

@pvk-developer pvk-developer marked this pull request as draft April 11, 2022 06:06
@pvk-developer
Copy link
Member Author

We may rework this in the future.

@amontanez24 amontanez24 deleted the issue_457_add_more_functionality_to_config_class branch August 10, 2022 23:16
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