mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-16 21:37:59 +08:00
* Add server plugin system Plugins are optional modules loaded at runtime. Specification: * Plugins are loaded from the server.plugins module (directory server/plugins) * The import_plugins method is run as part of the initialization of the server module in __init__.py * Add plugins to the EB build process * Remove bit of dead code * Respond to feedback from @bmccandless
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import shutil
|
|
import unittest
|
|
|
|
import anndata
|
|
|
|
from server.common.data_locator import DataLocator
|
|
from server.converters.cxgtool import write_cxg
|
|
from server.data_cxg.cxg_adaptor import CxgAdaptor
|
|
from server.test import PROJECT_ROOT, app_config, random_string
|
|
from server.test.test_datasets.fixtures import pbmc3k_colors
|
|
|
|
|
|
class TestCxgAdaptor(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.fixtures = []
|
|
|
|
def tearDown(self) -> None:
|
|
try:
|
|
for data_locator in self.fixtures:
|
|
print("REMOVING ", data_locator)
|
|
shutil.rmtree(data_locator)
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
def test_cxg_category_colors(self):
|
|
data = self.convert_pbmc3k(extract_colors=True)
|
|
self.assertEqual(data.get_colors(), pbmc3k_colors)
|
|
data = self.convert_pbmc3k(extract_colors=False)
|
|
self.assertEqual(data.get_colors(), {})
|
|
|
|
def convert_pbmc3k(self, **kwargs):
|
|
rand_str = random_string(8)
|
|
data_locator = f"/tmp/test_{rand_str}.cxg"
|
|
self.fixtures.append(data_locator)
|
|
source_h5ad = anndata.read_h5ad(f"{PROJECT_ROOT}/example-dataset/pbmc3k.h5ad")
|
|
write_cxg(adata=source_h5ad, container=data_locator, title="pbmc3k", **kwargs)
|
|
config = app_config(data_locator)
|
|
return CxgAdaptor(DataLocator(data_locator), config)
|