Sohum Sachathamakul
10/30/2023, 3:01 AM%load_ext kedro.ipython and %reload_kedro to run our Kedro pipeline in Databricks environment successfully
Complication:
• When faced a raise Exception in the code, the Kedro pipeline fails, but doesn’t fail the Databricks job — causing the error to be un-raised (and users not knowing the job actually fail)
• It seems to be the %load_ext kedro.ipython magic function which is causing the Exception to be suppressed. Before this function we are able to Raise directly in notebook and it fails the job/but afterwards it gets suppressed.
Help needed:
• Where should we look in the Kedro codebase in order to debug this? Anything that screams out where Exceptions might be getting suppressed?Juan Luis
10/30/2023, 9:27 AMJuan Luis
10/30/2023, 9:58 AM%pip install kedro.
@Sohum Sachathamakul can you share your complete list of dependencies and Kedro plugins?Juan Luis
10/30/2023, 9:59 AM.ipynb I used by the wayKyle Chung
10/30/2023, 11:21 AMJuan Luis
10/30/2023, 11:26 AMkedro.ipython is injecting ipywidgets, but will keep this in mind. @Sohum Sachathamakul and I are debugging, will report back when we know what caused this issueJuan Luis
10/30/2023, 12:30 PMimport kedro.framework.cli.utils ⚠️
• copy-pasting kedro/framework/cli/utils.py into the notebook and executing it didn't break the traceback.
• this behavior appears in Kedro 0.18.8, 0.18.9, 0.18.14. so it's not something we've fixed now.
• sys.excepthook didn't change before and after, it was basically <bound method InteractiveShell.excepthook of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at ...>
we'll continue tomorrow.Nok Lam Chan
11/01/2023, 4:11 PMpip install git+<https://github.com/kedro-org/kedro.git@noklam/tempfix-databricks>
This branch seems to fix the issue. This fork branch suppress the use of rich.pretty.install
I suspect the issue is the older Databricks runtime 9.0 has some strange behavior because this cannot be reproduced on the current databricks version (and it should affect more people if this is a generic issue)Nok Lam Chan
11/01/2023, 4:12 PMrich optionally, it should only install hook when rich is installed so there is an easy way to disable it without too many configuration.datajoely
11/01/2023, 4:12 PMdatajoely
11/01/2023, 4:12 PMNok Lam Chan
11/01/2023, 4:37 PMdatajoely
11/01/2023, 4:42 PMNok Lam Chan
11/01/2023, 4:50 PMSohum Sachathamakul
11/01/2023, 5:01 PMNok Lam Chan
11/02/2023, 12:00 PMfrom unittest.mock import patch
patch("rich.pretty.install")
You can include this at the top of notebook.Juan Luis
11/02/2023, 12:05 PMpatch("kedro.logging.rich.pretty.install")? (always confusing how mock works)Nok Lam Chan
11/02/2023, 2:22 PMkedro.logging is introduce in some 0.18.x series, so I am not sure is this the correct namespace.
The difference is patch("kedro.logging.rich.pretty.install") only affect the scope of Kedro, while patch("rich.pretty.install") affect any use of rich.pretty.installSohum Sachathamakul
11/04/2023, 4:51 AMpatch("kedro.logging.rich.pretty.install") and patch("rich.pretty.install") at the top of the notebook, didn’t work too 😢Nok Lam Chan
11/04/2023, 4:53 AMNok Lam Chan
11/04/2023, 7:26 AMpatch as a context manager - because of that you cannot use the %reload_kedro method because it’s a jupyter magic, you should be able to use reload_kedro as a function.
The code should looks like this
from unittest.mock import patch
import rich.pretty
with patch("rich.pretty.install"):
from kedro.ipython import reload_kedro
session.run()Olivia Lihn
01/19/2024, 1:45 PMValueError: Cannot resolve 'kedro.logging.RichHandler': No module named 'kedro.logging'
below i can see another error:
ValueError: Unable to configure handler 'rich'Olivia Lihn
01/19/2024, 1:45 PMNok Lam Chan
01/19/2024, 1:46 PMNok Lam Chan
01/19/2024, 1:46 PMNok Lam Chan
01/19/2024, 1:47 PM• Added. This replaces the defaultkedro.logging.RichHandlerand is more flexible, user can turn off therich.logging.RichHandlertraceback if needed.rich
https://github.com/kedro-org/kedro/blob/main/RELEASE.md#release-0189
Nok Lam Chan
01/19/2024, 1:47 PMNok Lam Chan
01/19/2024, 1:48 PMlogging.yml?Olivia Lihn
01/19/2024, 1:48 PMOlivia Lihn
01/19/2024, 1:48 PMOlivia Lihn
01/19/2024, 2:35 PMNok Lam Chan
01/19/2024, 2:44 PM