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

Molecule.to_file() should support file-like objects #219

Open
jchodera opened this issue Mar 4, 2020 · 1 comment
Open

Molecule.to_file() should support file-like objects #219

jchodera opened this issue Mar 4, 2020 · 1 comment

Comments

@jchodera
Copy link

jchodera commented Mar 4, 2020

Is your feature request related to a problem? Please describe.
Currently, writing many molecules to a file requires (1) conversion to JSON as a string, then (2) writing the string to a file.

Describe the solution you'd like
Molecule supports the from_file() method, but its argument currently only accepts filename strings. Adding support for file-like objects would make it much more flexible in being able to flush its serialized contents to a file that is already open, or gzipped, etc.

Describe alternatives you've considered
This would purely be a convenience feature.

@dgasmith
Copy link
Collaborator

dgasmith commented Mar 5, 2020

Writing many molecules to a JSON file should involve getting the dictionary form of the molecule, appending to a dict or list, and writing the JSON once. Continuous JSON appending doesn’t make sense as it cannot be read back in easily.

We currently do not have any stream based formats so continuous appending would prevent multi molecule reading. I might be misunderstanding, can you provide a small use case snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants