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: set DucktapeJSONEncoder as default encoder in reports. #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ivandasch
Copy link
Contributor

Fix #250

Copy link
Contributor

@ewencp ewencp left a comment

Choose a reason for hiding this comment

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

Did one of the cases not using DucktapeJSONEncoder cause a problem?

imo we should really only go one of two ways here. The current approach is that cases where we expect complex data structures that the json module won't handle them naturally provide the override. This is used for cases where, e.g., we know we have a TestResult which is a "real" class rather than just a dumb data container. The danger is that we might miss a case, but to date, I haven't heard of any issues with this.

The second would be to be very defensive and support the to_json extension everywhere. If we wanted to do that, we should make it fully comprehensive -- in json_serializable.py we should provide the type of wrapper you have here and use it universally, probably banning direct imports of json everywhere else. That guarantees we cover not only the reporter, but also, e.g., result.py, vagrant.py, etc.

@ivandasch
Copy link
Contributor Author

ivandasch commented Sep 14, 2020

@ewencp Hi, Ewen

Did one of the cases not using DucktapeJSONEncoder cause a problem?

Currently, if you try to use object in @parametrize, test will fail. Namely, we use subclass of LooseVersion and we always should convert it to str in our project.
Also, we created custom pararemetrization and pass it from --globals (run all suite against specific version or against version vs version in compatibility suite).

I suppose that it is possible to remove this restriction and add ability to user pass object with to_json overriden method to parameter.

The second would be to be very defensive and support the to_json extension everywhere.

So you suggests to move my helper function to distinct module and use it everywhere? Ok, sounds good for me.

@ivandasch
Copy link
Contributor Author

@ewencp Hi, I changed my PR as you suggested (second variant). Could you please look at it again?

@stan-is-hate stan-is-hate requested a review from a team January 16, 2021 04:51
@stan-is-hate stan-is-hate reopened this Jan 21, 2021
@stan-is-hate
Copy link
Member

pardon my trigger finger :)

@stan-is-hate
Copy link
Member

stan-is-hate commented Jan 21, 2021

I'm not super familiar with all of ducktape yet, can you please clarify how using DucktapeJSONEncoder helps with this:

Currently, if you try to use object in @parametrize, test will fail. Namely, we use subclass of LooseVersion and we always should convert it to str in our project.

?

Overall I don't have a strong opinion yet, but don't see much harm in using our own load(s) and dump(s) methods.

@cla-assistant
Copy link

cla-assistant bot commented Aug 16, 2023

CLA assistant check
All committers have signed the CLA.

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.

Set DucktapeJSONEncoder as default in reports generator.
3 participants