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

Feature Request: Serialization for other file types #485

Open
sdrobert opened this issue Jun 9, 2021 · 1 comment
Open

Feature Request: Serialization for other file types #485

sdrobert opened this issue Jun 9, 2021 · 1 comment
Milestone

Comments

@sdrobert
Copy link
Contributor

sdrobert commented Jun 9, 2021

Is your feature request related to a problem? Please describe.

My use case involves

  1. Writing configuration files by hand specifying the values of various Parameters in some easy-to-read format.
  2. Deserializing the values stored in those files into a set of Parameterized instances.

Currently, the only file type that can be (de)serialized by param is JSON. It works, but is not very readable. It also does not support comments. It would be nice if param supported alternatives to JSON. If given the choice, I almost never pick JSON.

Describe the solution you'd like

Additional Serialization subclasses in serialization.py.

In particular, TOML is a dictionary-like structure similar to JSON. The library toml that has loads and dumps (de)serialization that functions similarly to JSON. I believe it wouldn't be particularly complicated.

YAML is another common type with (de)serialization between file and dictionary. It's a bit more complicated than TOML since the go-to library, PyYAML, is limited to YAML 1.1. There's a better library called ruamel.yaml that supports YAML 1.2. However, it hasn't hit a major version yet.

Describe alternatives you've considered

I've handled INI, JSON, and YAML (de)serialization in my personal repository.

Additional context

This request follows my discussion with @jbednar and @jlstevens. In addition to #482, I plan on writing two more feature requests: one for populating parameterized instances with deserialized dictionaries and another for integration with argparse.

I am happy to write the PR for this feature request, but wanted confirmation that this was indeed desirable functionality from the devs.

Thanks for your time,
Sean

@sdrobert
Copy link
Contributor Author

Ugh, it looks like TOML compliance is more confusing than I thought. Some care ought to be taken to pick an appropriate backend there as well.

@ablythed ablythed added this to the 2.0 milestone Jun 28, 2021
@maximlt maximlt modified the milestones: 2.0, v2.x Apr 5, 2023
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

3 participants