-
Notifications
You must be signed in to change notification settings - Fork 904
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
Put framework logging into LOGGING and fix import resetting logging #1644
Conversation
…utomatic import Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
PACKAGE_NAME = None | ||
LOGGING = None | ||
LOGGING = _ProjectLogging() |
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.
The major success here is that this now acts like pipelines
and settings
, and configure_logging
is much more analogous to configure_project
than it used to be.
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
# We suppress click here to hide tracebacks related to it conversely, | ||
# kedro is not suppressed to show its tracebacks for easier debugging. | ||
# sys.executable is used to get the kedro executable path to hide the top level traceback. | ||
rich_traceback_install( |
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.
https://kedro.readthedocs.io/en/latest/search.html?q=rich&check_keywords=yes&area=default
We have the option to opt out from Rich
logging, but do we have the option to opt out from the Rich traceback?
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.
Yes, though not as easily as with configuring logging. You can do sys.excepthook = sys.__excepthook__
to change the traceback handler back to Python's default one. We haven't documented this anywhere yet because it's a bit obscure and not totally obvious where the best place to put that code would be, so I was planning to wait to see if any user asked it first 😅
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.
Awesome! Amazing work that fixes the very subtle bug and I like the more consistent _ProjectLogging
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.
Awesome work, this looks perfect thank you! 🌟
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
…o fix/parallel-runner-logging Signed-off-by: Antony Milne <[email protected]> Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
…o fix/parallel-runner-logging Signed-off-by: Antony Milne <[email protected]> Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Signed-off-by: Antony Milne <[email protected]>
Description
Fixes #1558. Fixes Windows CI problem in #1592.
Also changed
conf_logging
tologging_config
in a few places for consistency.Development notes
This has been quite a journey, but after many, many different attempts at this I think I've now got a good solution 😬
Before:
LOGGING
global variable was used to pass logging to spawned subprocessesNow:
LOGGING
global variable still exists (there's no good way to get rid of it) but is now set to load framework default logging config initially and then gets overwritten with project logging config. The mechanism for this is a new_ProjectLogging
class, which makes logging configuration much closer to how we configure other things in the same filekedro.config.default_logger
to load setup framework logging configproject.__init__.py
anyway, so I've removed itimport kedro.config.default_logger
, which will no longer work. I checked on #kedro-users and discord and no one is knowingly doing this. The only case I can think of someone doing this would be from copy and pasting our current ipython extension script into a script of their own. This itself is quite unlikely, but if it is the case then it's comparable to very small breaking changes to non-essential workflows that we've put into minor releases before, so both Ivan and I are ok with thisCause of Windows e2e test failures in #1592
This was very subtle and mysterious so let me document it here. The error was nothing to do with rich but actually a result of an import in a plugin!
test_plugin
didfrom kedro.framework.cli.starters import ...
kedro.framework.cli
➡️kedro.framework.main
(due to__init__.py
import) ➡️import kedro.config.default_logger
Now that there's no logging side-effects on file import this is not a problem.
Testing
Tested manually all the following cases:
kedro run
with and without project logging.yml, with and without plugin with importskedro run --runner=ParallelRunner
with and without project logging.yml, with and without plugin with importskedro ipython
andkedro jupyter lab
Checklist
RELEASE.md
file