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

added a json converter class in json_encoder.py to pyscan/general. Th… #184

Merged
merged 13 commits into from
Jun 18, 2024

Conversation

rsbrost
Copy link
Contributor

@rsbrost rsbrost commented Jun 11, 2024

…is is now implemented in the save_metadata method of abstract_experiment.py which enables numpy values to be used as data inputs before saving. The converter changes the numpy values to standard python values and no longer throws the same type error as before.

Copy link
Collaborator

@i-am-mounce i-am-mounce left a comment

Choose a reason for hiding this comment

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

This needs to replace the recursive_to_dict method. Also, we need to decode on load_experiment.

…general. This is now implemented in the save_metadata method of abstract_experiment.py which enables numpy values to be used as data inputs before saving. The converter changes the numpy values to standard python values and no longer throws the same type error as before.
…mpy data types and consolidated the json converter added in the last commit to the pre existing recursive_to_dict function which can now handle numpy data types for saving.
@rsbrost rsbrost closed this Jun 16, 2024
@rsbrost
Copy link
Contributor Author

rsbrost commented Jun 16, 2024

Got it working sufficiently, but Andy says he wants it as a json-converter in place of the recursive_to_dict function. I had issues when trying this at first; however, I will try to solve them exhaustively before reopening this pull request.

@rsbrost
Copy link
Contributor Author

rsbrost commented Jun 16, 2024

The specific type error issue from before was: "TypeError: Object of type wrapper_descriptor is not JSON serializable." Looking into overcoming this now. I think it has to do with not properly omitting certain keys from the converter data, such as those with keys: ['logger', 'expt_thread', 'data_path', 'instrument', 'module_id_string', 'spec']. Not sure how to best handle this yet, although again, the original issue detailing how numpy values were not saveable by json has been addressed and is currently working with recursive_to_dict as mentioned above.

@rsbrost
Copy link
Contributor Author

rsbrost commented Jun 18, 2024

encoder has been added to replace recursive_to_dict, as well as encoder to replace recursive_to_item_attribute.

@rsbrost rsbrost reopened this Jun 18, 2024
@i-am-mounce i-am-mounce merged commit 415139c into main Jun 18, 2024
4 checks passed
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.

2 participants