-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix module loading in logging config #54555
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
Conversation
- Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports
- Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
- Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports
- Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures
fa2fcce to
f90682c
Compare
|
Hello @jason810496 , |
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for the PR! LGTM overall.
- Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports
- Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures
f90682c to
347f8b1
Compare
Replace `SETTINGS_FILE_NESTED_MODULE` replicate part with string replacement from `SETTINGS_FILE_SIMPLE_MODULE`
Replace manual assertions with `self._verify_basic_logging_config` in fallback test to ensure consistent validation across all logging config tests.
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
- Remove redundant `SETTINGS_FILE_NESTED_MODULE` - Rename `SETTINGS_FILE_SIMPLE_MODULE` to `SETTINGS_FILE_WITH_REMOTE_VARS`
1. remove `SETTING_FILE_NO_REMOTE_VARS` bcz redundant var 2. add return typo with `_verify_basic_logging_config` 3. add unittest.mock `call`
|
I think we're good to merge once CI passes 🙂 |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
* fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * refactor(logging): move `import_module` to the top level * test(logging): optimize test constants to reduce code duplication Replace `SETTINGS_FILE_NESTED_MODULE` replicate part with string replacement from `SETTINGS_FILE_SIMPLE_MODULE` * test(logging): use shared helper method for logging config validation Replace manual assertions with `self._verify_basic_logging_config` in fallback test to ensure consistent validation across all logging config tests. * refactor(logging_config): simplify, improve test config vars - Remove redundant `SETTINGS_FILE_NESTED_MODULE` - Rename `SETTINGS_FILE_SIMPLE_MODULE` to `SETTINGS_FILE_WITH_REMOTE_VARS` * refactor(logging): imporve & simplify logging testing file 1. remove `SETTING_FILE_NO_REMOTE_VARS` bcz redundant var 2. add return typo with `_verify_basic_logging_config` 3. add unittest.mock `call` (cherry picked from commit 462ce9a) Co-authored-by: Vic Wen <99777196+viiccwen@users.noreply.github.com>
* fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * refactor(logging): move `import_module` to the top level * test(logging): optimize test constants to reduce code duplication Replace `SETTINGS_FILE_NESTED_MODULE` replicate part with string replacement from `SETTINGS_FILE_SIMPLE_MODULE` * test(logging): use shared helper method for logging config validation Replace manual assertions with `self._verify_basic_logging_config` in fallback test to ensure consistent validation across all logging config tests. * refactor(logging_config): simplify, improve test config vars - Remove redundant `SETTINGS_FILE_NESTED_MODULE` - Rename `SETTINGS_FILE_SIMPLE_MODULE` to `SETTINGS_FILE_WITH_REMOTE_VARS` * refactor(logging): imporve & simplify logging testing file 1. remove `SETTING_FILE_NO_REMOTE_VARS` bcz redundant var 2. add return typo with `_verify_basic_logging_config` 3. add unittest.mock `call` (cherry picked from commit 462ce9a) Co-authored-by: Vic Wen <99777196+viiccwen@users.noreply.github.com>
* fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * fix(logging): fix module loading by using `import_module()` - Replace `import_string()` with `import_module()` in `load_logging_config()` - Fix issue where simple module paths like `log_config.LOGGING_CONFIG` failed - Add `importlib` import inside function to avoid circular imports * test(logging): add tests for logging config module path handling - Add parametrized test for simple and nested module paths - Add test for graceful fallback when remote logging vars are missing - Create helper method to reduce test code duplication - Test both log_config.LOGGING_CONFIG and nested.module.LOGGING_CONFIG scenarios Ensures logging config works with various module path structures * refactor(logging): move `import_module` to the top level * test(logging): optimize test constants to reduce code duplication Replace `SETTINGS_FILE_NESTED_MODULE` replicate part with string replacement from `SETTINGS_FILE_SIMPLE_MODULE` * test(logging): use shared helper method for logging config validation Replace manual assertions with `self._verify_basic_logging_config` in fallback test to ensure consistent validation across all logging config tests. * refactor(logging_config): simplify, improve test config vars - Remove redundant `SETTINGS_FILE_NESTED_MODULE` - Rename `SETTINGS_FILE_SIMPLE_MODULE` to `SETTINGS_FILE_WITH_REMOTE_VARS` * refactor(logging): imporve & simplify logging testing file 1. remove `SETTING_FILE_NO_REMOTE_VARS` bcz redundant var 2. add return typo with `_verify_basic_logging_config` 3. add unittest.mock `call`
Summary
Fix issue where custom logging configuration with simple module paths (like
log_config.LOGGING_CONFIG) caused triggerer and scheduler to fail during startup.Problem
When users set
logging_config_class = log_config.LOGGING_CONFIGin theirairflow.cfg, theload_logging_config()function would fail because:logging_class_path.rsplit(".", 1)[0]produces"log_config"import_string("log_config")fails because it expects a dot-separated path like"module.submodule.attribute"ImportErrorand preventedREMOTE_TASK_LOGandDEFAULT_REMOTE_CONN_IDfrom being loadedSolution
Replace
import_string()withimportlib.import_module()inload_logging_config()Changes
Code
airflow-core/src/airflow/logging_config.py, withload_logging_config()Test
airflow-core/tests/unit/core/test_logging_config.pyRelated Issues
resolves #54414