Join the Kedro community

Updated 2 months ago

Kedro logging configuration for Databricks notebooks

At a glance

Hello everyone

I'm using kedro inside a notebook on Databricks (unfortunately I need to use notebooks and I don't have authorization to use the new kedro-databricks plugin yet). It turns out that I'm having a very bad experience with the logs. The notebook cell is constantly blinking and freezing, so I can't view the logs. Below is my log configuration file. Could anyone suggest a better log configuration for Databricks notebooks?

version: 1

disable_existing_loggers: False

formatters:
  simple:
    format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

handlers:
  console:
    class: logging.StreamHandler
    level: INFO
    formatter: simple
    stream: <a target="_blank" rel="noopener noreferrer" href="ext://sys.stdout">ext://sys.stdout</a>

  info_file_handler:
    class: logging.handlers.RotatingFileHandler
    level: INFO
    formatter: simple
    filename: info.log
    maxBytes: 10485760 # 10MB
    backupCount: 20
    encoding: utf8
    delay: True

  rich:
    class: kedro.logging.RichHandler
    rich_tracebacks: True

loggers:
  kedro:
    level: INFO

  grp_global:
    level: INFO

root:
  handlers: [console]

L
J
Y
14 comments

Does changing the logging levels to WARNING improve the blinking/freezing issue? I'm thinking maybe the logging messages being sent too fast after each other might be contributing to this problem.

Yes, I think so. But I'd like to keep the info logs too 🙁

print() messages also works well

I'm thinking if there's any way to stagger the logging messages without having to write a custom handler. Does disabling rich logging improve anything?

https://docs.kedro.org/en/stable/logging/index.html#how-to-use-logging-without-the-rich-library

Is it using rich logging? The handler is set to console only

Right, it shouldn't.

I have just found out that the KEDRO_LOGGING_CONFIG variable was not defined for my project. I will try to define it and evaluate again.

Thanks, Laura.

Let me know how it goes!

That worked. Now this is actually using the console handler, which no longer freezes the notebook.

But it's a bit weird. Do you know how to remove the [dark_orange] flag?

Eg:
INFO 2024-10-29 17:35:12,027: Loading data from [dark_orange]params:HMC[/dark_orange] (MemoryDataset)... - kedro.io.data_catalog

What version of Kedro are you using? This issue was solved on 0.19.8.

I will upgrade it. Thanks, Laura!

unfortunately I need to use notebooks

I feel you...

Add a reply
Sign up and join the conversation on Slack