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:
Madison Dunitz
2020-09-29 18:31:59 -05:00
committed by GitHub
parent 4aabb8e092
commit 2ffe5ffcae
6 changed files with 4 additions and 68 deletions

View File

@@ -17,9 +17,6 @@ def get_client_config(app_config, data_adaptor):
# make sure the configuration has been checked.
app_config.check_config()
# features
features = [f.todict() for f in data_adaptor.get_features(annotation)]
# display_names
title = app_config.get_title(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
client_config = {}
config = client_config["config"] = {}
config["features"] = features
config["displayNames"] = display_names
config["library_versions"] = library_versions
config["links"] = links

View File

@@ -155,17 +155,6 @@ class DataAdaptor(metaclass=ABCMeta):
"""
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):
parameters.update(self.parameters)
@@ -388,17 +377,3 @@ class DataAdaptor(metaclass=ABCMeta):
except RuntimeError:
lastmod = None
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

View File

@@ -40,11 +40,11 @@ class AppConfigTest(ConfigTests):
expected_config = yaml.load(default_config, Loader=yaml.Loader)
server_config = app_default_config['server']
dataset_config = app_default_config['dataset']
server_config = app_default_config["server"]
dataset_config = app_default_config["dataset"]
expected_server_config = expected_config['server']
expected_dataset_config = expected_config['dataset']
expected_server_config = expected_config["server"]
expected_dataset_config = expected_config["dataset"]
self.assertDictEqual(app_default_config, expected_config)
self.assertDictEqual(server_config, expected_server_config)

View File

@@ -49,7 +49,6 @@ class EndPoints(object):
result_data = result.json()
self.assertIn("library_versions", result_data["config"])
self.assertEqual(result_data["config"]["displayNames"]["dataset"], "pbmc3k")
self.assertEqual(len(result_data["config"]["features"]), 5)
def test_get_layout_fbs(self):
endpoint = "layout/obs"

View File

@@ -268,20 +268,3 @@ class WritableAnnotationTest(unittest.TestCase):
all_col_schema["cat_B"],
{"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)

View File

@@ -94,23 +94,6 @@ class AdaptorTest(unittest.TestCase):
with pytest.raises(TypeError):
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):
fbs = self.data.layout_to_fbs_matrix(fields=None)
layout = decode_fbs.decode_matrix_FBS(fbs)