diff --git a/cellxgene_gateway/dir_util.py b/cellxgene_gateway/dir_util.py index 3ca9957..84aa9b0 100644 --- a/cellxgene_gateway/dir_util.py +++ b/cellxgene_gateway/dir_util.py @@ -62,3 +62,8 @@ def make_h5ad(el): def make_annotations(el): return el[:-5] + annotations_suffix + + +def ensure_dir_exists(file_path): + if not os.path.exists(file_path): + os.makedirs(file_path) diff --git a/cellxgene_gateway/items/file/fileitem_source.py b/cellxgene_gateway/items/file/fileitem_source.py index d7e44f5..073425c 100644 --- a/cellxgene_gateway/items/file/fileitem_source.py +++ b/cellxgene_gateway/items/file/fileitem_source.py @@ -130,6 +130,7 @@ class FileItemSource(ItemSource): ) item = self.lookup_item(h5ad_descriptor) if item is not None: + dir_util.ensure_dir_exists(self.full_path(annotation_item.subpath)) return LookupResult(item, annotation_item) else: item = self.lookup_item(descriptor)