-
Notifications
You must be signed in to change notification settings - Fork 99
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
ValueEnum
conflict between emmet and jobflow
#1002
Comments
Sorry, I forgot to mention that the behaviour can be made uniform if selecting
|
There has already been some discussion on related issues:
I advised on not removing Personally, I think the fix is to add back |
That said, I feel like I'm fighting a losing battle. If moving over to the emmet ValueEnum and using @janosh would you have any time to look into this? |
I see, I apologize for not searching further for previous discussions. I had found the last PR and assumed it was just a recent update. Just to give a bit more context, I got to this point, since a user reported having the I should add that I have also realized that In general, I understand the idea behind the |
No need to appologise. I didn't expect you to be familiar with the previous discussions, I was just putting them for the complete history of this problem. Thanks for digging into this @gpetretto. I think one can imagine a use case for having both ValueEnum (e.g., something which serialises to a string, can be compared to a string, but which is an enum object) vs a normal Enum (something which is MSONable in that you can recover the original object) be present in jobflow. I thought this is what we had but I'm now lost with the changes to monty/emmet/jobflow as to what is still possible. There doesn't seem to be consistent use of In that case, I'm happy to switch over emmet |
@utf sorry, not immediately. would have to be inserted fairly low on the todo list.
@utf that already exists actually. big fan of standard lib's import json
from enum import StrEnum
class State(StrEnum):
completed = "completed"
failed = "failed"
waiting = "waiting"
submitted = "submitted"
running = "running"
assert State.completed == "completed" # no need for .value
assert json.dumps(State.completed) == '"completed"' # no need for special serialization logic only downside is it's 3.11+. but there's a backport package on pypi or you could just copy-paste the |
I have noticed that the behaviour of
ValueEnum
, whose use is widespread in atomate2 for all the codes, is incosistent between emme-core and jobflow. The former now does not have an as_dict that returns a string, while the latter still has that.The
TaskState
is aValueEnum
for all the codes, but for VASP, it is the emmet version, for most of the other is the jobflow version.The code below demonstrates the potential consequences of the problem:
When using the latest version of emmet-core and jobflow the output is:
Where the two lead to different results.
Trying to use
dumpfn
(that relies on the MontyEncoder) will be even worse, since the
dumpfn(p, "p.json")` leads to the error:Which is the same reported in materialsproject/emmet#1051
In general, I would probably support the option of not having the
as_dict
method return a string, as this breaks theMSONable
API. Maybe just switching all to the emmet version of the object, if it should stay like this for jobflow? However I am not sure about all the implications of dropping that method in jobflow as well. In any case, this will change the structure of the data in the DB.@utf @janosh
The text was updated successfully, but these errors were encountered: