Repository navigation
fix(export): restore console log level after export completes - #7947
DevChiniwala wants to merge 1 commit into
Conversation
[Medium impact] The new test cleanup issue is non-blocking. Findings
SummaryThe PR restores the caller's console log level after export finishes.
Reviews (6) · Last reviewed commit: "fix(export): restore console log level a..." · Reviewed by Greptile |
Merging this PR will degrade performance by 6.41%3 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
0951824 to
fe2e381
Compare
There was a problem hiding this comment.
4 issues found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/units/utils/test_export.py">
<violation number="1" location="tests/units/utils/test_export.py:4">
P2: This import is unused and causes Ruff’s `F401` check to fail; remove it. The import block should retain only the used `pytest` import and project imports.</violation>
<violation number="2" location="tests/units/utils/test_export.py:13">
P2: This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.</violation>
<violation number="3" location="tests/units/utils/test_export.py:21">
P2: These tests do not exercise log-level restoration because the fixture mocks the `console` object used by `export()`. Mock only `console.rule` (or remove this patch) so `set_log_level()` remains real and the assertions can detect a regression.</violation>
</file>
<file name="changes/7947.bugfix.md">
<violation number="1" location="changes/7947.bugfix.md:1">
P2: Towncrier will ignore this fragment because root release notes are read from `news/`, not `changes/`; move it to `news/7947.bugfix.md` so the fix is included in the changelog.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
|
||
| import pytest | ||
| from pytest_mock import MockerFixture | ||
| from unittest.mock import patch, MagicMock |
There was a problem hiding this comment.
P2: This import is unused and causes Ruff’s F401 check to fail; remove it. The import block should retain only the used pytest import and project imports.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 4:
<comment>This import is unused and causes Ruff’s `F401` check to fail; remove it. The import block should retain only the used `pytest` import and project imports.</comment>
<file context>
@@ -1,274 +1,75 @@
import pytest
-from pytest_mock import MockerFixture
+from unittest.mock import patch, MagicMock
from reflex_base import constants
+from reflex_base.utils import console
</file context>
| api_url="https://api.example.com", | ||
| deploy_url="https://app.example.com", | ||
| ) | ||
| def mock_dependencies(mocker): |
There was a problem hiding this comment.
P2: This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 13:
<comment>This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.</comment>
<file context>
@@ -1,274 +1,75 @@
- api_url="https://api.example.com",
- deploy_url="https://app.example.com",
- )
+def mock_dependencies(mocker):
+ """Mock all export dependencies to isolate log level testing."""
+ mocker.patch("reflex.utils.export.get_config")
</file context>
| mocker.patch("reflex.utils.export.prerequisites") | ||
| mocker.patch("reflex.utils.export.build") | ||
| mocker.patch("reflex.utils.export.exec") | ||
| mocker.patch("reflex.utils.export.console") |
There was a problem hiding this comment.
P2: These tests do not exercise log-level restoration because the fixture mocks the console object used by export(). Mock only console.rule (or remove this patch) so set_log_level() remains real and the assertions can detect a regression.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 21:
<comment>These tests do not exercise log-level restoration because the fixture mocks the `console` object used by `export()`. Mock only `console.rule` (or remove this patch) so `set_log_level()` remains real and the assertions can detect a regression.</comment>
<file context>
@@ -1,274 +1,75 @@
+ mocker.patch("reflex.utils.export.prerequisites")
+ mocker.patch("reflex.utils.export.build")
+ mocker.patch("reflex.utils.export.exec")
+ mocker.patch("reflex.utils.export.console")
+ mocker.patch("reflex.utils.export.telemetry")
+ return mocker
</file context>
| mocker.patch("reflex.utils.export.console") | |
| mocker.patch("reflex.utils.export.console.rule") |
| @@ -0,0 +1 @@ | |||
| Fixed console log level not being restored after `reflex export` completes, which caused `reflex deploy` to hide progress messages. | |||
There was a problem hiding this comment.
P2: Towncrier will ignore this fragment because root release notes are read from news/, not changes/; move it to news/7947.bugfix.md so the fix is included in the changelog.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At changes/7947.bugfix.md, line 1:
<comment>Towncrier will ignore this fragment because root release notes are read from `news/`, not `changes/`; move it to `news/7947.bugfix.md` so the fix is included in the changelog.</comment>
<file context>
@@ -0,0 +1 @@
+Fixed console log level not being restored after `reflex export` completes, which caused `reflex deploy` to hide progress messages.
</file context>
fe2e381 to
e60e077
Compare
e60e077 to
709d7f4
Compare
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/units/utils/test_export.py">
<violation number="1" location="tests/units/utils/test_export.py:290">
P2: This test never reaches the configured `get_compiled_app` failure because `frontend=False` skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass `frontend=True` for this failure case.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Re-trigger cubic
| assert _log.get_log_level() == initial_level | ||
|
|
||
| # Call export with a different log level | ||
| export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False) |
There was a problem hiding this comment.
P2: This test never reaches the configured get_compiled_app failure because frontend=False skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass frontend=True for this failure case.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 290:
<comment>This test never reaches the configured `get_compiled_app` failure because `frontend=False` skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass `frontend=True` for this failure case.</comment>
<file context>
@@ -44,46 +287,40 @@ def test_export_restores_log_level_on_success(mock_export_dependencies):
# Call export with a different log level
- export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)
+ export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)
# Verify log level was restored to initial level
</file context>
| export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False) | |
| export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=True, backend=False) |
bb0ccaa to
b41e1fb
Compare
The export() function sets the console to the subprocess log level (WARNING by default) but never restores it, hiding all INFO messages from callers like `reflex deploy` after the export step. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b41e1fb to
9797836
Compare
| initial_level = constants.LogLevel.WARNING | ||
| console.set_log_level(initial_level) |
There was a problem hiding this comment.
Tests leave logging settings behind
The new tests change the process-wide log level without restoring the level they found. The last test leaves _log_level and REFLEX_LOGLEVEL set to WARNING. The shared teardown calls _reset(), which restores neither value, so later tests and their subprocesses inherit this test's settings. Save and restore both values in a fixture.
Closes #7850
Summary
export()sets the console to the subprocess log level (WARNING by default) but never restores itreflex deployafter the export step — deployment progress, scaling-conflict retries, and the success line are all silencedexport()changes it and restore it in the existingfinallyblockChanges
reflex/utils/export.py: saveprev_log_levelvia_log.get_log_level()beforeset_log_level(loglevel), restore it in thefinallyblockTest plan
reflex deployin a non-TTY shell should now show progress and success messages after the export stepfinallyblock, so the level is restored even if export fails🤖 Generated with Claude Code