Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Remove order dependency #40

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ jobs:
- name: Test with pytest
run: |
cd ./tests
export EXCORE_DEBUG=1
poetry run python init.py
poetry run pytest --cov=../excore
poetry run pytest test_config.py
poetry run pytest test_config.py
poetry run pytest test_config.py
poetry run pytest test_config.py


- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
7 changes: 4 additions & 3 deletions excore/config/lazy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, config: ConfigDict) -> None:
config.registered_fields = list(Registry._registry_pool.keys())
config.all_fields = set([*config.registered_fields, *config.primary_fields])
self._config = deepcopy(config)
self._origin_config = deepcopy(config)
self._original_config = deepcopy(config)
self.__is_parsed__ = False

def parse(self):
Expand All @@ -27,10 +27,11 @@ def parse(self):
self._config.parse()
logger.success("Config parsing cost {:.4f}s!", time.time() - st)
self.__is_parsed__ = True
logger.ex(self._config)

@property
def config(self):
return self._origin_config
return self._original_config

def update(self, cfg: "LazyConfig"):
self._config.update(cfg._config)
Expand Down Expand Up @@ -75,7 +76,7 @@ def build_all(self) -> Tuple[ModuleWrapper, Dict]:
return module_dict, isolated_dict

def dump(self, dump_path: str) -> None:
self._origin_config.dump(dump_path)
self._original_config.dump(dump_path)

def __str__(self):
return str(self._config)
6 changes: 6 additions & 0 deletions excore/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _str_to_target(module_name):
class ModuleNode(dict):
cls: Any
_no_call: bool = field(default=False, repr=False)
priority: int = field(default=0, repr=False)

def _get_params(self, **kwargs):
params = {}
Expand Down Expand Up @@ -153,6 +154,7 @@ def from_node(cls, _other: "ModuleNode") -> "ModuleNode":


class InterNode(ModuleNode):
priority = 2
pass


Expand All @@ -165,12 +167,16 @@ def __call__(self, **kwargs):


class ReusedNode(InterNode):
priority: int = 3

@CacheOut()
def __call__(self, **kwargs):
return super().__call__(**kwargs)


class ClassNode(InterNode):
priority: int = 1

def __call__(self):
return self.cls

Expand Down
Loading
Loading