Unverified Commit 3c0626fb authored by Nikita Rudin's avatar Nikita Rudin Committed by GitHub

Allows loading of initialized configs in `load_cfg_from_registry` (#425)

# Description

Fixed the configuration parsing to give an instanced config instead of
just a non-instanced class.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have run all the tests with `./orbit.sh --test` and they pass
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------
Signed-off-by: 's avatarNikita Rudin <48368649+nikitardn@users.noreply.github.com>
parent 31e42a5c
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.5.4" version = "0.5.6"
# Description # Description
title = "ORBIT Environments" title = "ORBIT Environments"
......
Changelog Changelog
--------- ---------
0.5.6 (2024-02-21)
~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed the configuration parsing to support a pre-initialized configuration object.
0.5.5 (2024-02-05) 0.5.5 (2024-02-05)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
......
...@@ -81,11 +81,13 @@ def load_cfg_from_registry(task_name: str, entry_point_key: str) -> dict | Any: ...@@ -81,11 +81,13 @@ def load_cfg_from_registry(task_name: str, entry_point_key: str) -> dict | Any:
mod_path = inspect.getfile(cfg_entry_point) mod_path = inspect.getfile(cfg_entry_point)
# load the configuration # load the configuration
cfg_cls = cfg_entry_point() cfg_cls = cfg_entry_point()
else: elif isinstance(cfg_entry_point, str):
# resolve path to the module location # resolve path to the module location
mod_name, attr_name = cfg_entry_point.split(":") mod_name, attr_name = cfg_entry_point.split(":")
mod = importlib.import_module(mod_name) mod = importlib.import_module(mod_name)
cfg_cls = getattr(mod, attr_name) cfg_cls = getattr(mod, attr_name)
else:
cfg_cls = cfg_entry_point
# load the configuration # load the configuration
print(f"[INFO]: Parsing configuration from: {cfg_entry_point}") print(f"[INFO]: Parsing configuration from: {cfg_entry_point}")
if callable(cfg_cls): if callable(cfg_cls):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment