refactor: explicit Config.load() + lazy catalog config initialization#3083
refactor: explicit Config.load() + lazy catalog config initialization#3083jx2lee wants to merge 3 commits intoapache:mainfrom
Conversation
|
@kevinjqliu
Direction I used is:
Would you mind taking a quick look and sharing any guidance on:
Thanks — happy to adjust the approach based on your feedback. 👍🏽 |
|
@kevinjqliu gentle ping. |
kevinjqliu
left a comment
There was a problem hiding this comment.
Thanks for the PR! I think we should mark Config() as deprecated so folks can migrate to .load() instead
| def test_config_does_not_load_implicitly() -> None: | ||
| with ( | ||
| mock.patch.object(Config, "_from_configuration_files") as from_files_mock, | ||
| mock.patch.object(Config, "_from_environment_variables") as from_env_mock, | ||
| ): | ||
| Config() | ||
|
|
||
| from_files_mock.assert_not_called() | ||
| from_env_mock.assert_not_called() |
tests/catalog/test_base.py
Outdated
| ) | ||
|
|
||
|
|
||
| def test_get_env_config_is_lazy_and_cached(mocker: MockFixture) -> None: |
There was a problem hiding this comment.
nit move this to test_config?
tests/catalog/test_rest.py
Outdated
| json={"defaults": {}, "overrides": {}}, | ||
| status_code=200, | ||
| ) | ||
| env_config: RecursiveDict = Config._from_environment_variables({}) |
There was a problem hiding this comment.
nit i think we can clean up this test to use Config.load() instead
Thinking about this again. Changing the signature from
could you split up the |
|
Thanks for the review, @kevinjqliu !
it makes sense. I agreed that, It's so complext for users.
I agree with that direction overall !
I can split that into a follow-up issue ! |
Closes #3028
Rationale for this change
This PR refactors config loading to avoid implicit IO and import-time config initialization.
Changes
Config()a pure container (no implicit file/env reads)Config.load()to load from config files + environment variables_ENV_CONFIGwith a lazy cached getter inpyiceberg.catalogConfig.load()where runtime config reads are intendedAre these changes tested?
Yes!
Are there any user-facing changes?
No! (Maybe.. ?)