I have a directory containing mostly text and json files, and one binary file (output of MXNet.Block.save_parameters
neural network).
I wanted to zip this folder and then pickle it. Say I have a zip file object:
from zipfile import ZipFile
import os, pickle, itertools
files = list(itertools.chain(*[
map(lambda x: os.path.join(root, x), files)
for root, directories, files in os.walk('model-artifacts/')
]))
zfile = ZipFile('mymode.l.zip', 'w')
for file in file_paths:
zfile.write(file)
I cannot really pickle it:
pickle.dumps(zfile)
# TypeError: cannot serialize '_io.BufferedRandom' object
I was wondering if there is a way to pickle zipfiles or any way to pickle contents of a directory.
WHY?
I am not doing the pickling myself, but using a library Metaflow
which pickles objects in it, so I want to find a way to store my model with Metaflow