dabla commented on PR #69859: URL: https://github.com/apache/airflow/pull/69859#issuecomment-6187271885
@VladaZakharova thanks, you were right: `GitDagBundle.__init__` logged through `self._log`, which built and cached the logger from `_get_log_context()` before a subclass had set its own attributes, so the subclass got an `AttributeError` or an incomplete context it kept for good. Fixed in 438284d9e1 by taking your first option, not calling the overridable hook from the constructor: the three construction messages now go through a logger bound with `GitDagBundle._get_log_context(self)`, which calls `GitDagBundle`'s own context by class name instead of dispatching to the override. `self._log` is therefore first built after construction and includes the subclass's fields. I did not take the "finalize after construction" route, because knowing when the most-derived `__init__` has returned would need a metaclass on `BaseDagBundle`, a public extension point, for a problem only constructors that log have. `test_subclass_log_context_uses_attributes_set_after_construction` subclasses `GitDagBundle` with an attribute set after `super().__init__()` and checks it ends up in the bound context; it fails with `AttributeError: 'TeamGitDagBundle' object has no attribute 'team'` without the fix. The branch is also rebased on the latest `main` (conflicts in `git.py` and the amazon `pyproject.toml`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
