Skip to content

Conversation

@ogabrielluiz
Copy link
Contributor

@ogabrielluiz ogabrielluiz commented Sep 19, 2025

  • Introduced a new logger module to facilitate compatibility with lfx.logging.
  • The module re-exports configure and logger from lfx.log, ensuring seamless integration.
  • Updated unit tests to validate the new logger functionality and compatibility.

This change enhances the logging capabilities and maintains backward compatibility with existing code.

Summary by CodeRabbit

  • Refactor
    • Streamlined the logging module to align with shared logging utilities, improving compatibility and ensuring a consistent public API while preserving backward compatibility.
  • Tests
    • Expanded coverage for logging import scenarios and cleaned up formatting in unit tests to improve clarity and reliability without changing behavior.

No user-facing functionality changes; this release focuses on compatibility and test robustness.

- Introduced a new logger module to facilitate compatibility with lfx.logging.
- The module re-exports `configure` and `logger` from `lfx.log`, ensuring seamless integration.
- Updated unit tests to validate the new logger functionality and compatibility.

This change enhances the logging capabilities and maintains backward compatibility with existing code.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Walkthrough

Adds a new logging compatibility module that re-exports configure and logger from lfx.log.logger, and updates a unit test to import the re-exported logger while making minor whitespace adjustments.

Changes

Cohort / File(s) Summary of Changes
Logging re-export module
src/backend/base/langflow/logging/logger.py
New module that imports and re-exports configure and logger from lfx.log.logger; sets __all__ = ["configure", "logger"].
Unit tests
src/backend/tests/unit/test_langflow_logging_compatibility.py
Adjusts whitespace between imports; updates embedded test code to also import logger from langflow.logging.logger.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • Cristhianzl
  • jordanrfrazier
  • edwinjosechittilappilly

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat(logging): add logger module for backwards compatibility" succinctly and accurately summarizes the primary change: adding a new logger module to provide backwards compatibility by re-exporting configure and logger; it is concise, follows conventional commit style, and is specific enough for a reviewer scanning history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-logging-imports

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added lgtm This PR has been approved by a maintainer enhancement New feature or request labels Sep 19, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Sep 19, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Sep 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/backend/base/langflow/logging/logger.py (1)

1-3: Add a defensive import and a brief module docstring for clearer failure modes.

If lfx isn’t present, raise a targeted ImportError; also document the shim.

Apply this diff:

-from lfx.log.logger import configure, logger
-
-__all__ = ["configure", "logger"]
+"""Compatibility shim: re-exports `configure` and `logger` from `lfx.log.logger`."""
+try:
+    from lfx.log.logger import configure as configure, logger as logger
+except ImportError as e:
+    raise ImportError(
+        "langflow.logging.logger requires the `lfx` package to be importable."
+    ) from e
+
+__all__ = ["configure", "logger"]
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7df5173 and ac28ebc.

📒 Files selected for processing (2)
  • src/backend/base/langflow/logging/logger.py (1 hunks)
  • src/backend/tests/unit/test_langflow_logging_compatibility.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
{src/backend/**/*.py,tests/**/*.py,Makefile}

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code

Files:

  • src/backend/base/langflow/logging/logger.py
  • src/backend/tests/unit/test_langflow_logging_compatibility.py
src/backend/tests/unit/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Test component integration within flows using create_flow, build_flow, and get_build_events utilities

Files:

  • src/backend/tests/unit/test_langflow_logging_compatibility.py
src/backend/tests/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...

Files:

  • src/backend/tests/unit/test_langflow_logging_compatibility.py
🧠 Learnings (2)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test backward compatibility across Langflow versions in backend Python tests by mapping component files to supported versions using 'VersionComponentMapping'.

Applied to files:

  • src/backend/tests/unit/test_langflow_logging_compatibility.py
📚 Learning: 2025-08-07T20:23:23.569Z
Learnt from: edwinjosechittilappilly
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: Some Langflow starter project files and components still use `from loguru import logger` instead of the centralized structlog logger from `langflow.logging.logger`. These should be updated to ensure consistent structured logging across the entire codebase.

Applied to files:

  • src/backend/tests/unit/test_langflow_logging_compatibility.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Ruff Style Check (3.13)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Test Starter Templates
  • GitHub Check: Optimize new Python code in this PR
  • GitHub Check: Run Ruff Check and Format
  • GitHub Check: Update Starter Projects
  • GitHub Check: Ruff Style Check (3.13)
🔇 Additional comments (2)
src/backend/base/langflow/logging/logger.py (1)

1-3: LGTM: minimal re-export meets the compat goal.

Straightforward pass-through keeps API surface stable.

src/backend/tests/unit/test_langflow_logging_compatibility.py (1)

156-173: Avoid shadowing logger; alias the second import.

File: src/backend/tests/unit/test_langflow_logging_compatibility.py (lines 156–173)

Prevents accidental masking and clarifies intent.

Apply this diff to the embedded code string:

 from langflow.logging import logger, configure
-from langflow.logging.logger import logger
+from langflow.logging.logger import logger as logger_via_module

Manual verification required: the ripgrep run returned no output — confirm no remaining direct from loguru import logger usages.

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 23.24%. Comparing base (7df5173) to head (d8ba800).
⚠️ Report is 2 commits behind head on main.

❌ Your project status has failed because the head coverage (45.52%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9929      +/-   ##
==========================================
- Coverage   23.25%   23.24%   -0.01%     
==========================================
  Files        1090     1091       +1     
  Lines       39837    39839       +2     
  Branches     5530     5530              
==========================================
- Hits         9264     9261       -3     
- Misses      30402    30407       +5     
  Partials      171      171              
Flag Coverage Δ
backend 45.52% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/backend/base/langflow/logging/logger.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ogabrielluiz ogabrielluiz added this pull request to the merge queue Sep 19, 2025
Merged via the queue into main with commit 0b67b6f Sep 19, 2025
32 of 33 checks passed
@ogabrielluiz ogabrielluiz deleted the fix-logging-imports branch September 19, 2025 21:35
@jabiru458-afk
Copy link

Hi how are you doing today

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

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants