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

Remove whitespace indents from large Auspice JSONs #944

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/fix-colorings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ def recurse(node):
adjust_coloring_for_epiweeks(input_json)

with open(args.output, 'w') as f:
json.dump(input_json, f, indent=2)
json.dump(input_json, f, indent=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already have a convention in Augur of controlling indentation with an environment variable named AUGUR_MINIFY_JSON , we could maintain that interface here and allow users to override this default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

Suggested change
json.dump(input_json, f, indent=0)
from augur.utils import write_json # at the top of the file
write_json(input_json, f)

I didn't know that Augur had that option until you pointed that out to me. I also learned that the nextstrain-cli can pass this environment variable (and others) directly to the underlying execution platforms.

If we decide to go with that, I would have to see how big the diffs get. Does having newlines impact the size of the diffs at all?

Copy link
Contributor

@huddlej huddlej May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty close! I think we'd also want to pass an argument to exclude the Augur version from the output like so:

write_json(input_json, f, include_version=False)

Do you want to try this and see how it works for you, @fanninpm?

Regarding diffs, do you mean when storing your Auspice JSONs in version control? If so, newlines will have an effect on diff sizes in the sense that a single-line Auspice JSON will look like a single new line of JSON each time you commit it.