Skip to content

feat: add structured and configurable logging support to Kubeflow SDK#311

Open
MansiSingh17 wants to merge 3 commits intokubeflow:mainfrom
MansiSingh17:feature/structured-logging
Open

feat: add structured and configurable logging support to Kubeflow SDK#311
MansiSingh17 wants to merge 3 commits intokubeflow:mainfrom
MansiSingh17:feature/structured-logging

Conversation

@MansiSingh17
Copy link
Contributor

Summary

Fixes #85

Changes

  • Added kubeflow/common/logging.py with a get_logger() utility function
  • Supports configurable log levels via KUBEFLOW_LOG_LEVEL environment variable (defaults to INFO)
  • Replaced print() calls with logger.info() in production code:
    • kubeflow/trainer/backends/kubernetes/backend.py
    • kubeflow/trainer/backends/container/backend.py

How to test

Set log level via environment variable:

import os
os.environ["KUBEFLOW_LOG_LEVEL"] = "DEBUG"
from kubeflow.common.logging import get_logger
logger = get_logger(__name__)
logger.info("test")  # 2025-02-21 - __main__ - INFO - test

Notes

  • print() calls inside print_packages() were intentionally left as-is since they run inside the training container
  • print() calls in docstring examples were also left unchanged

Copilot AI review requested due to automatic review settings February 22, 2026 01:14
@google-oss-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kramaranya for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions
Copy link
Contributor

🎉 Welcome to the Kubeflow SDK! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards
  • Our team will review your PR soon! cc @kubeflow/kubeflow-sdk-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds structured logging support to the Kubeflow SDK by introducing a get_logger() utility function in kubeflow/common/logging.py that supports configurable log levels via the KUBEFLOW_LOG_LEVEL environment variable. The PR also replaces print() calls with logger.info() calls in two backend files to improve debugging and observability.

Changes:

  • Added kubeflow/common/logging.py with a get_logger() function that provides custom formatting and environment variable-based log level configuration
  • Replaced print() with logger.info() in get_runtime_packages() methods of kubernetes and container backends

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
kubeflow/common/logging.py New logging utility with configurable log levels via KUBEFLOW_LOG_LEVEL environment variable
kubeflow/trainer/backends/kubernetes/backend.py Changed print() to logger.info() for job logs output
kubeflow/trainer/backends/container/backend.py Changed print() to logger.info() for runtime package logs output

@MansiSingh17 MansiSingh17 force-pushed the feature/structured-logging branch 3 times, most recently from 9403274 to c8efd98 Compare February 22, 2026 01:27
- Add kubeflow/common/logging.py with get_logger() utility
- Support configurable log levels via KUBEFLOW_LOG_LEVEL env variable
- Replace print() calls with logger.info() in production code
- Fixes kubeflow#85

Signed-off-by: Mansi Singh <singh.m1@northeastern.edu>
Signed-off-by: Mansi Singh <singh.m1@northeastern.edu>
@MansiSingh17 MansiSingh17 force-pushed the feature/structured-logging branch from c8efd98 to 99c60c8 Compare February 22, 2026 01:28
Copy link
Contributor

@astefanutti astefanutti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ok-to-test

@MansiSingh17
Copy link
Contributor Author

It looks like the e2e test failure is related to a CI infrastructure issue with loading the deepspeed-runtime image into KinD, not related to the logging changes in this PR. Could a maintainer re-run the tests or confirm?

@astefanutti
Copy link
Contributor

@MansiSingh17 you're right. It should have been fixed in trainer now.

/retest

Signed-off-by: Mansi Singh <singh.m1@northeastern.edu>
@MansiSingh17
Copy link
Contributor Author

@astefanutti, Fixed the ruff formatting and import ordering issues — all 14 checks are now passing. The only pending one is tide, which is waiting on lgtm/approved labels. Happy to address any other feedback!

@astefanutti
Copy link
Contributor

@MansiSingh17 thanks.

/assign @szaher @kramaranya @andreyvelich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured and configurable logging support to Kubeflow SDK

6 participants