How to use the dallinger.config.Configuration function in dallinger

To help you get started, we’ve selected a few dallinger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_register_duplicate_variable_raises(self):
        config = Configuration()
        config.register("num_participants", int)
        with pytest.raises(KeyError):
            config.register("num_participants", int)
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_setting_unknown_key_is_ignored(self):
        config = Configuration()
        config.ready = True
        config.extend({"num_participants": 1})
        config.get("num_participants", None)
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_type_mismatch_with_cast_types(self):
        config = Configuration()
        config.register("num_participants", int)
        config.ready = True
        config.extend({"num_participants": 1.0}, cast_types=True)
        assert config.get("num_participants", 1) == 1
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_get_before_ready_is_not_possible(self):
        config = Configuration()
        config.register("num_participants", int)
        config.extend({"num_participants": 1})
        with pytest.raises(RuntimeError):
            config.get("num_participants", 1)
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_layering_of_configs(self):
        config = Configuration()
        config.register("num_participants", int)
        config.extend({"num_participants": 1})
        config.ready = True
        assert config.get("num_participants", 1) == 1
        config.extend({"num_participants": 2})
        assert config.get("num_participants", 1) == 2
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_setting_values_supports_synonyms(self):
        config = Configuration()
        config.register("num_participants", int, synonyms={"n"})
        config.ready = True
        config.extend({"n": 1})
        assert config.get("num_participants") == 1
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_attribute_access(self):
        config = Configuration()
        config.register("num_participants", int)
        config.ready = True
        config.extend({"num_participants": 1})
        assert config.num_participants == 1
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_loading_keys_from_environment_variables(self):
        config = Configuration()
        config.register("num_participants", int, synonyms={"n"})
        os.environ["num_participants"] = "1"
        try:
            config.load_from_environment()
        finally:
            del os.environ["num_participants"]
        config.ready = True
        assert config.get("num_participants") == 1
github Dallinger / Dallinger / tests / test_config.py View on Github external
def test_get_without_default_raises(self):
        config = Configuration()
        config.register("num_participants", int)
        config.ready = True
        with pytest.raises(KeyError):
            config.get("num_participants")
github Dallinger / Dallinger / dallinger / config.py View on Github external
def get_config():
    global config

    if config is None:
        config = Configuration()
        for registration in default_keys:
            config.register(*registration)

    return config