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

Handle np.bool to JSON NumpyEncoder #3280

Merged
merged 1 commit into from
Mar 21, 2023
Merged

Conversation

abidwael
Copy link
Contributor

@abidwael abidwael commented Mar 21, 2023

Fix for the following failure
RuntimeError: Caught exception during model preprocessing: Object of type bool_ is not JSON serializable
with the following config

{'defaults': {'binary': {'preprocessing': {'missing_value_strategy': 'fill_with_mode'}}},
 'input_features': [{'name': 'binary_1', 'type': 'binary'}],
 'model_type': 'ecd',
 'output_features': [{'decoder': {'idx2str': ['lwrVkpk',
                                              'ztHj',
                                              'dQxBJ',
                                              'mLFhKPHrTn',
                                              'iBjnr',
                                              'Pb',
                                              'qyiL',
                                              'VEQv',
                                              'zLol',
                                              'SBpN'],
                                  'vocab_size': 10},
                      'name': 'category_output_1',
                      'type': 'category'}],
 'trainer': {'train_steps': 1}}

The np.bool_ exists in training_set_metadata after the data has been preprocessed and is being cached.

@github-actions
Copy link

github-actions bot commented Mar 21, 2023

Unit Test Results

  6 files  ±0    6 suites  ±0   22m 49s ⏱️ + 2m 23s
12 tests ±0  10 ✔️ ±0    2 💤 ±0  0 ±0 
60 runs  ±0  48 ✔️ ±0  12 💤 ±0  0 ±0 

Results for commit 1611db9. ± Comparison against base commit 7d959f7.

♻️ This comment has been updated with latest results.

@arnavgarg1
Copy link
Contributor

@abidwael happy to approve, but can you update the PR description to clearly indicate when objects of type bool_ are created? It's not apparent from the config itself since the inference likely comes from the data right?

Copy link
Contributor

@arnavgarg1 arnavgarg1 left a comment

Choose a reason for hiding this comment

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

Ideally would be great if you can also add a small unit test!

@abidwael abidwael merged commit 7276d02 into master Mar 21, 2023
@abidwael abidwael deleted the bool-not-json-serializable branch March 21, 2023 07:34
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

2 participants