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

Zip archiving the folder #33

Open
fumitoh opened this issue Jun 15, 2020 · 7 comments
Open

Zip archiving the folder #33

fumitoh opened this issue Jun 15, 2020 · 7 comments

Comments

@fumitoh
Copy link
Owner

fumitoh commented Jun 15, 2020

One more thing as we are talking about model saving. Have you thought about zip archiving the folder? It will save space and make it more convenient to send the model around. We save the model on OneDrive cloud and it ends up syncing a hundered files instead of 1.
Using zip archive will be the same as what Excel does with its files.
I can also implement this myself.

Originally posted by @alebaran in #32 (comment)

@fumitoh
Copy link
Owner Author

fumitoh commented Jun 15, 2020

Good idea. Looks easy to implement and practical.

@alebaran
Copy link

import shutil
save_name = 'my_model'
# write model
mx.write_model(model, save_name)
# zip
shutil.make_archive(save_name, 'zip', save_name)
shutil.rmtree(save_name)
# unzip
shutil.unpack_archive(save_name + '.zip', extract_dir='temp')
# read model
model = mx.read_model('temp')
shutil.rmtree('temp')

@fumitoh
Copy link
Owner Author

fumitoh commented Jun 15, 2020

Thanks for the code.

@fumitoh
Copy link
Owner Author

fumitoh commented Jul 6, 2020

@alebaran
Copy link

Thank you for the quick release, very helpful. One question: do you intentionally zip archive without any compression?

@fumitoh
Copy link
Owner Author

fumitoh commented Jul 15, 2020

I wasn’t paying attention to compression. But I did try to write directly to the zip file using zipfile and in-memory files to avoid writing files to the disk.

@alexeybaran
Copy link

ZipFile() seems to have compression parameter, which is defaulted to no compression. Here is one of the options making it compress: compression=zipfile.ZIP_DEFLATED

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

No branches or pull requests

3 participants