Skip to content
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

[Draft] - logging #3657

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions kedro/framework/cli/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ def package(metadata: ProjectMetadata) -> None:
help=PARAMS_ARG_HELP,
callback=_split_params,
)
@click.option(
"-v",
"verbose",
type=click.UNPROCESSED,
is_flag=True,
default="",
)
def run( # noqa: PLR0913
tags: str,
env: str,
Expand All @@ -212,8 +219,13 @@ def run( # noqa: PLR0913
conf_source: str,
params: dict[str, Any],
namespace: str,
verbose: bool,
) -> None:
"""Run the pipeline."""
if verbose:
from kedro.framework.project import LOGGING
LOGGING.data["root"]["level"] = "DEBUG"
LOGGING.configure(LOGGING.data)

runner_obj = load_obj(runner or "SequentialRunner", "kedro.runner")
tuple_tags = tuple(tags)
Expand Down
15 changes: 10 additions & 5 deletions kedro/framework/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,14 @@ class _ProjectLogging(UserDict):
def __init__(self) -> None:
"""Initialise project logging. The path to logging configuration is given in
environment variable KEDRO_LOGGING_CONFIG (defaults to default_logging.yml)."""
path = os.environ.get(
"KEDRO_LOGGING_CONFIG", Path(__file__).parent / "default_logging.yml"
)
user_logging_path = os.environ.get("KEDRO_LOGGING_CONFIG")
if not user_logging_path and Path("conf/logging.yml").exists():
user_logging_path = Path("conf/logging.yml")

default_logging_path = Path(__file__).parent / "default_logging.yml"
path = user_logging_path if user_logging_path else default_logging_path
print(f"DEBUG: {path=}")

logging_config = Path(path).read_text(encoding="utf-8")
self.configure(yaml.safe_load(logging_config))

Expand Down Expand Up @@ -265,8 +270,8 @@ def configure_project(package_name: str) -> None:
global PACKAGE_NAME # noqa: PLW0603
PACKAGE_NAME = package_name

if PACKAGE_NAME:
LOGGING.set_project_logging(PACKAGE_NAME)
# if PACKAGE_NAME:
# LOGGING.set_project_logging(PACKAGE_NAME)


def configure_logging(logging_config: dict[str, Any]) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ formatters:
handlers:
console:
class: logging.StreamHandler
level: INFO
formatter: simple
stream: ext://sys.stdout

Expand All @@ -32,12 +31,13 @@ handlers:
# See https://docs.kedro.org/en/stable/logging/logging.html#project-side-logging-configuration
# tracebacks_show_locals: False

loggers:
kedro:
level: INFO
# loggers:
# kedro:
# level: INFO

{{ cookiecutter.python_package }}:
level: INFO
# {{ cookiecutter.python_package }}:
# level: INFO

root:
handlers: [rich, info_file_handler]
level: INFO
Loading