From 586dc6623af9f231e9d233a8da777340de92fd55 Mon Sep 17 00:00:00 2001 From: Alok Saldanha Date: Mon, 29 Mar 2021 07:03:05 -0400 Subject: [PATCH] ensure annotation directory for new annotations --- cellxgene_gateway/dir_util.py | 5 +++++ cellxgene_gateway/items/file/fileitem_source.py | 1 + 2 files changed, 6 insertions(+) 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)