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

Make logging.yml read by default #3831

Merged
merged 21 commits into from
May 8, 2024
Merged
Changes from 7 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
21 changes: 17 additions & 4 deletions kedro/framework/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,23 @@ def configure(self, pipelines_module: str | None = None) -> None:
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"
)
environment variable KEDRO_LOGGING_CONFIG (defaults to conf/logging.yml)."""

# Check if a user path is set in the environment variable
user_logging_path = os.environ.get("KEDRO_LOGGING_CONFIG")

# Check if the default logging configuration exists
default_logging_path = Path("conf/logging.yml")
SajidAlamQB marked this conversation as resolved.
Show resolved Hide resolved
if not default_logging_path.exists():
default_logging_path = Path(__file__).parent / "default_logging.yml"

# Use the user path if available, otherwise, use the default path
if user_logging_path and Path(user_logging_path).exists():
path = Path(user_logging_path)
else:
path = default_logging_path

# Load and apply the logging configuration
logging_config = Path(path).read_text(encoding="utf-8")
self.configure(yaml.safe_load(logging_config))

Expand Down