Commit 76c1d9e8 authored by Alok Saldanha's avatar Alok Saldanha
Browse files

removed .csv suffix from annotation name

parent 586dc662
......@@ -18,10 +18,11 @@ class FileItem(Item):
The Item superclass expects a 'name' and 'type'.
def __init__(self, subpath: str, *args, **kwargs):
def __init__(self, subpath: str, ext: str = "", *args, **kwargs):
super().__init__(*args, **kwargs)
self.subpath = subpath
self.ext = ext
def descriptor(self) -> str:
return os.path.join(self.subpath,"/")
return os.path.join(self.subpath, + self.ext).strip("/")
......@@ -150,9 +150,16 @@ class FileItemSource(ItemSource):
def make_fileitem_from_path(
self, filename, subpath, is_annotation=False, is_shallow=False
) -> FileItem:
if is_annotation and filename.endswith(self.annotation_file_suffix):
name = filename[: -len(self.annotation_file_suffix)]
ext = self.annotation_file_suffix
name = filename
ext = ""
item = FileItem(
type=ItemType.annotation if is_annotation else ItemType.h5ad,
import tempfile
import unittest
from cellxgene_gateway.items.file.fileitem_source import FileItemSource
class TestFileItemSource(unittest.TestCase):
def test_make_fileitem_from_path_GIVEN_annotation_file_THEN_name_lacks_csv(self):
source = FileItemSource(tempfile.gettempdir(), "local")
item = source.make_fileitem_from_path(
"customanno.csv", "someh5ad_annotations", True
self.assertEqual(, "customanno")
self.assertEqual(item.descriptor, "someh5ad_annotations/customanno.csv")
def test_make_fileitem_from_path_GIVEN_h5ad_file_THEN_returns_name(self):
source = FileItemSource(tempfile.gettempdir(), "local")
item = source.make_fileitem_from_path("someanalysis.h5ad", "studydir")
self.assertEqual(, "someanalysis.h5ad")
self.assertEqual(item.descriptor, "studydir/someanalysis.h5ad")
......@@ -10,7 +10,7 @@ from cellxgene_gateway.items.file.fileitem_source import FileItemSource
from cellxgene_gateway.items.item import ItemType
key = CacheKey(
FileItem("/czi/", "pbmc3k.h5ad", ItemType.h5ad),
FileItem("/czi/", name="pbmc3k.h5ad", type=ItemType.h5ad),
FileItemSource("/tmp", "local"),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment