-
Notifications
You must be signed in to change notification settings - Fork 70
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
Revive ValueEnum.as_dict
method
#974
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #974 +/- ##
=======================================
Coverage 90.01% 90.02%
=======================================
Files 138 138
Lines 13226 13228 +2
=======================================
+ Hits 11906 11908 +2
Misses 1320 1320 ☔ View full report in Codecov by Sentry. |
This is all fair. I think it is worth us strongly considering adding a deprecation warning on this class, however, and committing to getting rid of it. We can be generous with the deprecation warning (e.g. 6 months). I'll still stand by my original point that the downstream codes relying on this hack should handle things in a better way. Namely, that means switching to Reviving the |
Hi @Andrew-S-Rosen, thanks for your thoughts. I still have concerns about deprecating this class entirely. There is a desire to support both enum value and enum dict serialisation at the same time in atomate2/jobflow. I believe that means having A couple of thoughts going forward:
Either way, I think merging this for now would be helpful for atomate2 and we can explore alternatives in the meantime. |
Thanks @munrojm ! |
@utf: Thanks for the follow-up!
The misleading name for the method is certainly one reason, although not the major one. The major issue is that, by adding in this non-dictionary
Indeed, this is a separate but also important point. There are several times where there is no need to be using |
A bug was reported in atomate2 where during a call to
monty.json.jsanitize
(specifically withstrict=True
andenum_values = False
), an error was thrown during deserialization ofVaspObject
because it lacks anas_dict
method. I reproduced this with versions of emmet-core > 0.77.1Since
VaspObject
inherits fromemmet.core.utils.ValueEnum
, and itsas_dict
method was removed in PR #944, this is the source of the errorTL;DR: This PR adds back the kludgey
as_dict -> str
method ofValueEnum
. Explainer below, I think these points merit discussion:Discussion / resolution (???):
as_dict
method because anas_dict
should not return astr
and because the correct deserialization of anEnum
can occur with changingenum_values = True
in jsanitizeas_dict
fromValueEnum
can have many downstream consequences because this method, while a kludge, has existed for a long time. @utf has raised the issue of downstream consequences from removingas_dict
and I also agree with theseValueEnum
should make it clear to users.