From 62a71c7fa69660f65043073baae19da2d005a7ff Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 13 Aug 2024 15:25:51 -0400 Subject: [PATCH] Create intermediate directories if they don't exist. From https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python#answer-600612 --- nlpgnn/datas/graphloader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nlpgnn/datas/graphloader.py b/nlpgnn/datas/graphloader.py index 20e983e..01d1007 100644 --- a/nlpgnn/datas/graphloader.py +++ b/nlpgnn/datas/graphloader.py @@ -1,6 +1,7 @@ #! encoding:utf-8 import glob import os +import pathlib import pickle as pkl import sys from collections import defaultdict @@ -664,7 +665,7 @@ def raw_file(self, data): def download(self): data_dir = os.path.join(self.data_dir, self.data) if not os.path.exists(data_dir): - os.mkdir(data_dir) + pathlib.Path(data_dir).mkdir(parents=True, exist_ok=True) for name in self.raw_file(self.data.lower()): url = "{}/{}".format(self.url, name) outpath = "{}/{}".format(data_dir, name)