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

Fix bug with loading data labeler from disk #665

Merged
merged 2 commits into from
Sep 28, 2022

Conversation

tonywu315
Copy link
Contributor

When DataLabeler is passed in a dirpath parameter, it loads from the disk and calls _load_parameters in base_data_labeler.py. However, there is a bug when the code checks if the model, preprocessor, or postprocessor matches the one specified in the saved DataLabeler.

from dataprofiler.labelers import DataLabeler, CharPreprocessor, CharPostprocessor
from dataprofiler.labelers.character_level_cnn_model import CharacterLevelCnnModel

data_labeler = DataLabeler(labeler_type="unstructured")
data_labeler.save_to_disk("temp")

label_mapping = {"PAD": 0, "CITY": 1, "UNKNOWN": 1, "ADDRESS": 2}
load_options = {
    "model_class": CharacterLevelCnnModel(label_mapping=label_mapping),
    "preprocessor_class": CharPreprocessor(),
    "postprocessor_class": CharPostprocessor(),
}

new_data_labeler = DataLabeler(labeler_type='unstructured', dirpath="temp", load_options=load_options)

This code generates the error: 'CharacterLevelCNNModel' object has no attribute '__name__'. This is because instances do not have this attribute. The class does however, so all occurrences in the code should be replaced with __class__.__name__. After changing this, the example code works.

@JGSweets JGSweets enabled auto-merge (squash) September 28, 2022 13:40
Copy link
Contributor

@taylorfturner taylorfturner left a comment

Choose a reason for hiding this comment

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

LGTM ... great fix!

@JGSweets JGSweets merged commit 9414bfc into capitalone:main Sep 28, 2022
@tonywu315 tonywu315 deleted the labeler_load_parameter_bug branch September 28, 2022 15:10
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