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

ktk.load/save: Ability to load and save unzipped JSON files #188

Open
felixchenier opened this issue Jul 27, 2023 Discussed in #92 · 1 comment
Open

ktk.load/save: Ability to load and save unzipped JSON files #188

felixchenier opened this issue Jul 27, 2023 Discussed in #92 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@felixchenier
Copy link
Collaborator

Discussed in #92

Originally posted by felixchenier May 24, 2022
At the moment, ktk.zip files are zipped JSON files for two reasons:

  • Space. JSON files are much smaller once zipped.
  • Ability to have a separate JSON file for metadata, which includes the file version number. This makes it possible to "easily" switch the file format in the future, to an hypothetical non-JSON format, while preserving the metadata in a JSON file.

However :

  • In case someone accidentally unzips the ktk.zip without realizing that the .zip is the expected file format (this is a real-life scenario), it would be practical if ktk.load could load a data JSON file directly.
  • For portability and easiness of sharing data with other programs, it may be useful that ktk.save can save to one data JSON file. This would be a non-default option.

Just an idea.

@felixchenier felixchenier added the enhancement New feature or request label Jul 27, 2023
@felixchenier felixchenier added this to the 1.0 milestone Jul 27, 2023
@felixchenier felixchenier self-assigned this Jul 27, 2023
@felixchenier
Copy link
Collaborator Author

I think it makes sense to flatten it to a single zipped JSON file, as expected by the documentation. This way we would automate the zipping/unzipping but it would be transparent and non required. Using the option zip=True in ktk.save would generate a zipped json file, and zip=False would generate a json file.

At the moment, ktk.zip files are zipped JSON files for two reasons:

  • Space. JSON files are much smaller once zipped
    • This is not affected.
  • Ability to have a separate JSON file for metadata, which includes the file version number. This makes it possible to "easily" switch the file format in the future, to an hypothetical non-JSON format, while preserving the metadata in a JSON file.
    • This is still really affected. We could come back to another format in the future that would not be a JSON file and in this file, supporting a dual metadata/data approach would still make sense. We need to continue supporting this form anyway since KTK has been used in real life now. The method would be simply to check if the unzipped file is a JSON, and if it is, load it including the metadata. If it's a folder, load it using the previous method.

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

No branches or pull requests

1 participant