-
Notifications
You must be signed in to change notification settings - Fork 48
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
Can't serialize to JSON #591
Comments
Ok I see the problem. The |
Diving into this one now. |
@bennybp I see you made a commit that addressed |
I started to fix it in that PR but abandoned it. It is a little more involved than just changing it to a list (there are some places that use the set functionality that have to also be modified. Looking at the database, the database stores this info as JSON. Not entirely sure where this gets converted from a set to a list on the backend... |
Ah cool, thank you for that clarification. Working on a solution that doesn't fail in other places. |
…Collections Addresses #591 Pydantic models support direct JSON serialization; we take advantage of this here to support use of e.g. sets in a model. The `to_json` and `from_json` methods also technically dealt with dicts, not JSON strings; this is a distinction that matters since not all dicts are valid JSON constructs. We resolve that distinction here. Need explicit roundtripping tests for `*_json` and `*_dict` methods yet.
I ran into this again today. For my provenance, the quickest solution is to just pop the history. There's probably a way to map it onto a import json
import qcportal
client = qcportal.FractalClient(verify=False)
dataset = client.get_collection(
"OptimizationDataset",
"OpenFF Iodine Chemistry Optimization Dataset v1.0",
)
with open("dataset.json", "w") as file:
data = dataset.to_json()
data.pop("history")
json.dump(data, file)
with open("dataset.json", "r") as file:
data = json.load(file) |
Superseded by #740 for v0.50 |
Describe the bug
I wanted to save a collection to disk in order to avoid needing to downloads a large dataset every time I ran a test or re-started a notebook.
To Reproduce
raises
TypeError: Object of type set is not JSON serializable
Expected behavior
I expected to be able to save this out to JSON
Additional context
There is data in the collection object:
@loriab suggested on Slack that a
set
may have snuck in somewhere. This is probably a terrible collection to debug on since it includes something like 20,000 records.The text was updated successfully, but these errors were encountered: