mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 04:08:12 +08:00
remove AppFeature and all references to it in the code/tests (#1893)
* remove AppFeature and all references to it in the code/tests Co-authored-by: bmccandless <bmccandless@chanzuckerberg.com>
This commit is contained in:
co-authored by
bmccandless
parent
4aabb8e092
commit
2ffe5ffcae
@@ -17,9 +17,6 @@ def get_client_config(app_config, data_adaptor):
|
|||||||
# make sure the configuration has been checked.
|
# make sure the configuration has been checked.
|
||||||
app_config.check_config()
|
app_config.check_config()
|
||||||
|
|
||||||
# features
|
|
||||||
features = [f.todict() for f in data_adaptor.get_features(annotation)]
|
|
||||||
|
|
||||||
# display_names
|
# display_names
|
||||||
title = app_config.get_title(data_adaptor)
|
title = app_config.get_title(data_adaptor)
|
||||||
about = app_config.get_about(data_adaptor)
|
about = app_config.get_about(data_adaptor)
|
||||||
@@ -75,7 +72,6 @@ def get_client_config(app_config, data_adaptor):
|
|||||||
# gather it all together
|
# gather it all together
|
||||||
client_config = {}
|
client_config = {}
|
||||||
config = client_config["config"] = {}
|
config = client_config["config"] = {}
|
||||||
config["features"] = features
|
|
||||||
config["displayNames"] = display_names
|
config["displayNames"] = display_names
|
||||||
config["library_versions"] = library_versions
|
config["library_versions"] = library_versions
|
||||||
config["links"] = links
|
config["links"] = links
|
||||||
|
|||||||
@@ -155,17 +155,6 @@ class DataAdaptor(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_features(self, annotations=None):
|
|
||||||
"""Return list of features, to return as part of the config route"""
|
|
||||||
features = [
|
|
||||||
AppFeature("/cluster/", method="POST", available=False),
|
|
||||||
AppFeature("/layout/obs", method="GET", available=self.get_embedding_names() is not None),
|
|
||||||
AppFeature("/layout/obs", method="PUT", available=self.dataset_config.embeddings__enable_reembedding),
|
|
||||||
AppFeature("/diffexp/", method="POST", available=self.dataset_config.diffexp__enable),
|
|
||||||
AppFeature("/annotations/obs", method="PUT", available=annotations is not None),
|
|
||||||
]
|
|
||||||
return features
|
|
||||||
|
|
||||||
def update_parameters(self, parameters):
|
def update_parameters(self, parameters):
|
||||||
parameters.update(self.parameters)
|
parameters.update(self.parameters)
|
||||||
|
|
||||||
@@ -388,17 +377,3 @@ class DataAdaptor(metaclass=ABCMeta):
|
|||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
lastmod = None
|
lastmod = None
|
||||||
return lastmod
|
return lastmod
|
||||||
|
|
||||||
|
|
||||||
class AppFeature(object):
|
|
||||||
def __init__(self, path, available=False, method="POST", extra={}):
|
|
||||||
self.path = path
|
|
||||||
self.available = available
|
|
||||||
self.method = method
|
|
||||||
self.extra = extra
|
|
||||||
[setattr(self, key, value) for key, value in extra.items()]
|
|
||||||
|
|
||||||
def todict(self):
|
|
||||||
d = dict(available=self.available, method=self.method, path=self.path)
|
|
||||||
d.update(self.extra)
|
|
||||||
return d
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ class AppConfigTest(ConfigTests):
|
|||||||
|
|
||||||
expected_config = yaml.load(default_config, Loader=yaml.Loader)
|
expected_config = yaml.load(default_config, Loader=yaml.Loader)
|
||||||
|
|
||||||
server_config = app_default_config['server']
|
server_config = app_default_config["server"]
|
||||||
dataset_config = app_default_config['dataset']
|
dataset_config = app_default_config["dataset"]
|
||||||
|
|
||||||
expected_server_config = expected_config['server']
|
expected_server_config = expected_config["server"]
|
||||||
expected_dataset_config = expected_config['dataset']
|
expected_dataset_config = expected_config["dataset"]
|
||||||
|
|
||||||
self.assertDictEqual(app_default_config, expected_config)
|
self.assertDictEqual(app_default_config, expected_config)
|
||||||
self.assertDictEqual(server_config, expected_server_config)
|
self.assertDictEqual(server_config, expected_server_config)
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class EndPoints(object):
|
|||||||
result_data = result.json()
|
result_data = result.json()
|
||||||
self.assertIn("library_versions", result_data["config"])
|
self.assertIn("library_versions", result_data["config"])
|
||||||
self.assertEqual(result_data["config"]["displayNames"]["dataset"], "pbmc3k")
|
self.assertEqual(result_data["config"]["displayNames"]["dataset"], "pbmc3k")
|
||||||
self.assertEqual(len(result_data["config"]["features"]), 5)
|
|
||||||
|
|
||||||
def test_get_layout_fbs(self):
|
def test_get_layout_fbs(self):
|
||||||
endpoint = "layout/obs"
|
endpoint = "layout/obs"
|
||||||
|
|||||||
@@ -268,20 +268,3 @@ class WritableAnnotationTest(unittest.TestCase):
|
|||||||
all_col_schema["cat_B"],
|
all_col_schema["cat_B"],
|
||||||
{"name": "cat_B", "type": "categorical", "categories": ["label_B"], "writable": True},
|
{"name": "cat_B", "type": "categorical", "categories": ["label_B"], "writable": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_config(self):
|
|
||||||
features = self.data.get_features(self.annotations)
|
|
||||||
|
|
||||||
# test each for singular presence and accuracy of available flag
|
|
||||||
def check_feature(method, path, available):
|
|
||||||
feature = list(
|
|
||||||
filter(lambda f: f.method == method and f.path == path and f.available == available, features)
|
|
||||||
)
|
|
||||||
self.assertIsNotNone(feature)
|
|
||||||
self.assertEqual(len(feature), 1)
|
|
||||||
|
|
||||||
check_feature("POST", "/cluster/", False)
|
|
||||||
check_feature("POST", "/diffexp/", self.data.dataset_config.diffexp__enable)
|
|
||||||
check_feature("GET", "/layout/obs", True)
|
|
||||||
check_feature("PUT", "/layout/obs", self.data.dataset_config.embeddings__enable_reembedding)
|
|
||||||
check_feature("PUT", "/annotations/obs", True)
|
|
||||||
|
|||||||
@@ -94,23 +94,6 @@ class AdaptorTest(unittest.TestCase):
|
|||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
self.data._create_schema()
|
self.data._create_schema()
|
||||||
|
|
||||||
def test_config(self):
|
|
||||||
features = self.data.get_features(annotations=None)
|
|
||||||
|
|
||||||
# test each for singular presence and accuracy of available flag
|
|
||||||
def check_feature(method, path, available):
|
|
||||||
feature = list(
|
|
||||||
filter(lambda f: f.method == method and f.path == path and f.available == available, features)
|
|
||||||
)
|
|
||||||
self.assertIsNotNone(feature)
|
|
||||||
self.assertEqual(len(feature), 1)
|
|
||||||
|
|
||||||
check_feature("POST", "/cluster/", False)
|
|
||||||
check_feature("POST", "/diffexp/", self.data.dataset_config.diffexp__enable)
|
|
||||||
check_feature("GET", "/layout/obs", True)
|
|
||||||
check_feature("PUT", "/layout/obs", self.data.dataset_config.embeddings__enable_reembedding)
|
|
||||||
check_feature("PUT", "/annotations/obs", False)
|
|
||||||
|
|
||||||
def test_layout(self):
|
def test_layout(self):
|
||||||
fbs = self.data.layout_to_fbs_matrix(fields=None)
|
fbs = self.data.layout_to_fbs_matrix(fields=None)
|
||||||
layout = decode_fbs.decode_matrix_FBS(fbs)
|
layout = decode_fbs.decode_matrix_FBS(fbs)
|
||||||
|
|||||||
Reference in New Issue
Block a user