Skip to content

Commit

Permalink
make dir when dumping to pickle
Browse files Browse the repository at this point in the history
  • Loading branch information
estshorter committed Aug 4, 2021
1 parent 4cf42e6 commit fbc0414
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lwpipe/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def load_pickle(filepath: str | PurePath):


def dump_pickle(data, filepath: str | PurePath):
_make_dir(Path(filepath).parent)
with open(filepath, "wb") as f:
pickle.dump(data, f)

Expand All @@ -50,6 +51,7 @@ def load_dict_pickle(filepath: str | PurePath, datalabels):
def dump_dict_pickle(datalist, filepath: str | PurePath, datalabels):
_assert_same_length(datalabels, datalist, "datalabels", "datalist")
datadict = {label: data for label, data in zip(datalabels, datalist)}
_make_dir(Path(filepath).parent)
with open(filepath, "wb") as f:
pickle.dump(datadict, f)

Expand Down

0 comments on commit fbc0414

Please sign in to comment.