mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-08 16:28:12 +08:00
app config bug fix: (#1833)
* app config bug fix: When reading a config file that included per_dataset_config, the dataroot specializations were applied, but not the default config. This PR fixes that and also includes a test for this case.
This commit is contained in:
@@ -100,7 +100,10 @@ class AppConfig(object):
|
|||||||
|
|
||||||
per_dataset_config = config.get("per_dataset_config", {})
|
per_dataset_config = config.get("per_dataset_config", {})
|
||||||
for key, dataroot_config in per_dataset_config.items():
|
for key, dataroot_config in per_dataset_config.items():
|
||||||
self.add_dataroot_config(key, **dataroot_config)
|
# first create and initialize the dataroot with the default config
|
||||||
|
self.add_dataroot_config(key, **config["dataset"])
|
||||||
|
# then apply the per dataset configuration
|
||||||
|
self.dataroot_config[key].update_from_config(dataroot_config, f"per_dataset_config__{key}")
|
||||||
|
|
||||||
self.is_complete = False
|
self.is_complete = False
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@@ -154,3 +155,44 @@ class AppConfigTest(unittest.TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
data_config = response.json()
|
data_config = response.json()
|
||||||
self.assertEqual(data_config["config"]["displayNames"]["dataset"], "pbmc3k")
|
self.assertEqual(data_config["config"]["displayNames"]["dataset"], "pbmc3k")
|
||||||
|
|
||||||
|
def test_configfile_with_specialization(self):
|
||||||
|
# test that per_dataset_config config load the default config, then the specialized config
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
|
configfile = os.path.join(tempdir, "config.yaml")
|
||||||
|
with open(configfile, "w") as fconfig:
|
||||||
|
config = """
|
||||||
|
server:
|
||||||
|
multi_dataset:
|
||||||
|
dataroot:
|
||||||
|
test:
|
||||||
|
base_url: test
|
||||||
|
dataroot: fake_dataroot
|
||||||
|
|
||||||
|
dataset:
|
||||||
|
user_annotations:
|
||||||
|
enable: false
|
||||||
|
type: hosted_tiledb_array
|
||||||
|
hosted_tiledb_array:
|
||||||
|
db_uri: fake_db_uri
|
||||||
|
hosted_file_directory: fake_dir
|
||||||
|
|
||||||
|
per_dataset_config:
|
||||||
|
test:
|
||||||
|
user_annotations:
|
||||||
|
enable: true
|
||||||
|
"""
|
||||||
|
fconfig.write(config)
|
||||||
|
|
||||||
|
app_config = AppConfig()
|
||||||
|
app_config.update_from_config_file(configfile)
|
||||||
|
|
||||||
|
test_config = app_config.dataroot_config["test"]
|
||||||
|
|
||||||
|
# test config from default
|
||||||
|
self.assertEqual(test_config.user_annotations__type, "hosted_tiledb_array")
|
||||||
|
self.assertEqual(test_config.user_annotations__hosted_tiledb_array__db_uri, "fake_db_uri")
|
||||||
|
|
||||||
|
# test config from specialization
|
||||||
|
self.assertTrue(test_config.user_annotations__enable)
|
||||||
|
|||||||
Reference in New Issue
Block a user