Closed jmmshn closed 5 months ago
PS: I think jsanitize(..., enum_values=True) avoids the problem, but I still think having an as_dict
that creates a str
is problematic. Since Enums
are fairly standard in python I think this should me taken care of in monty.
I'm running into a few problems when serializing
TaskDocs
usingdumpfn
.The following seems to be causing the problem:
https://github.com/materialsproject/emmet/blob/cc34208487060e41b7b428adee98d73669e2ad07/emmet-core/emmet/core/utils.py#L310C1-L313C1
When you call
MontyEncoder().encode
on aValueEnum
you end withd = "Hexagonal"
entering this block of monty:https://github.com/materialsvirtuallab/monty/blob/5d37679e1f0cd58a8d165d76f3a095cb71266831/monty/json.py#L417-L420
This leads to an error:
I think the right way to deal with this is to just make sure that monty understands enums which it kinda already does.
https://github.com/materialsvirtuallab/monty/blob/5d37679e1f0cd58a8d165d76f3a095cb71266831/monty/json.py#L194-L195
@munrojm, I can make that PR but I wanna make sure the effects are manageable first.