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

Explicit molecule component "to_json" does not have the same behaviour as GufeTokenizable "to_json" #458

Open
IAlibay opened this issue Jan 15, 2025 · 2 comments · May be fixed by #460
Open
Assignees
Milestone

Comments

@IAlibay
Copy link
Member

IAlibay commented Jan 15, 2025

I'm not sure if we picked up on this in #368 (sorry if it's a known issue!).

I just realised that calling to_json on an explicit molecule component (SmallMoleculeComponent) actually is a different behaviour than the GufeTokenizable to_json.

The former takes no arguments and only returns a json string whilst the latter can take a filepath and write the string directly there.

I know we rely a lot on the "to/from_json" utility for Components, but my understanding is that we could just directly remove the class method in explicit molecule and it should just give us the same behaviour?

A more immediate / short term concern

I noticed that the explicit molecule component to_json and from_json have no docstring 🙀 ! So they just inherit it from GufeTokenizable which has teh different behaviour.

@dotsdl
Copy link
Member

dotsdl commented Jan 16, 2025

Ah, this was certainly an oversight on our part in #368! As you suggest, I believe we could drop these methods from ExplicitMoleculeComponent and add in the ability to read previously-generated to_dict JSON dumps to the GufeTokenizable.from_json implementation as a fallback on failure.

Although, it looks like the ExplicitMoleculeComponent methods don't use our JSON_HANDLER encoder/decoder, which may mean they never worked right in the first place. 😅

@dotsdl dotsdl added this to the Release 1.3 milestone Jan 16, 2025
@IAlibay
Copy link
Member Author

IAlibay commented Jan 16, 2025

they never worked right in the first place

I am able to write an SMC with to_json and manually load it back in (not sure if I just got lucky though!)

@dotsdl dotsdl self-assigned this Jan 16, 2025
@dotsdl dotsdl moved this to Sprint - Available in gufe : advancement sprints Jan 16, 2025
@dotsdl dotsdl moved this from Sprint - Available to Sprint - In Progress in gufe : advancement sprints Jan 16, 2025
dotsdl added a commit that referenced this issue Jan 16, 2025
…itMoleculeComponent.to_json/from_json

Closes #375, #458.

Also allows us to read `GufeTokenizable`s serialized previously in
`dict` representation via `.from_json`.
@dotsdl dotsdl moved this from Sprint - In Progress to Sprint - In Review in gufe : advancement sprints Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Sprint - In Review
2 participants