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

Dumping without defaults #1

Closed
yairf11 opened this issue Jan 18, 2022 · 2 comments · Fixed by #2
Closed

Dumping without defaults #1

yairf11 opened this issue Jan 18, 2022 · 2 comments · Fixed by #2
Assignees
Labels
enhancement New feature or request

Comments

@yairf11
Copy link
Collaborator

yairf11 commented Jan 18, 2022

Hi,

When serializing a dataclass, there are cases in which we would like the output to be as concise as possible, and omit config entries if their value is the default one.

What do you think about adding a parameter to the encode/dump functions so that this behavior could be toggled on/off by the user?

@yairf11 yairf11 added the enhancement New feature or request label Jan 18, 2022
@eladrich
Copy link
Owner

Hi Yair,
Great suggestion, let me give it a try and see how it goes

@eladrich
Copy link
Owner

Added an option to pyrallis.dump as suggested.

pyrallis.dump(cfg, omit_defaults=True)

The main downside is that, while concise, saving the partial config means that changing the default in your dataclass might have unexpected results on older configs.

Will merge into the master alongside some other planned changes.

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

Successfully merging a pull request may close this issue.

2 participants