Skip to content

fix: skip Streamlit apps whose entrypoint directory no longer exists#109

Open
robertlacok wants to merge 4 commits into
mainfrom
fix/streamlit-missing-entrypoint-crash
Open

fix: skip Streamlit apps whose entrypoint directory no longer exists#109
robertlacok wants to merge 4 commits into
mainfrom
fix/streamlit-missing-entrypoint-crash

Conversation

@robertlacok

@robertlacok robertlacok commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes a crash where the installer would exit early if a registered Streamlit app's parent directory had been deleted, preventing all subsequent apps from starting.

Summary by CodeRabbit

  • Bug Fixes
    • Streamlit execution now verifies the computed working/entrypoint directories still exist before starting.
    • If a directory is missing, a warning is logged and that app is skipped, returning a failed execution result without launching a process.
    • Valid remaining apps continue starting normally even after skips.
  • Tests
    • Added unit coverage for missing directory behavior and failure result details.
    • Updated Streamlit/installer executor tests to use temporary directories and confirm warnings, process absence, and correct server start behavior after skips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Two guard clauses prevent Streamlit startup against non-existent directories. In deepnote_core/execution/registry.py, the action executor checks whether the computed cwd exists before spawning the app; if absent, it logs a warning and returns a failed ExecutionResult. In installer/module/streamlit.py, start_streamlit_servers performs the same existence check per app and skips missing ones with a warning. Unit tests in test_action_registry.py and a new TestStartStreamlitServers suite in test_streamlit.py cover both guards; an integration test is refactored to use dynamic paths and updated assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: skipping Streamlit apps with missing entrypoint directories. All modified files implement this exact fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Updates Docs ✅ Passed This PR is a bug fix (prevents crash when Streamlit app directory is deleted), not a new feature. Bug fixes improving robustness don't require documentation updates per the check's "feature" requir...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

📦 Python package built successfully!

  • Version: 2.3.1.dev6+c1ecb2b
  • Wheel: deepnote_toolkit-2.3.1.dev6+c1ecb2b-py3-none-any.whl
  • Install:
    pip install "deepnote-toolkit @ https://deepnote-staging-runtime-artifactory.s3.amazonaws.com/deepnote-toolkit-packages/2.3.1.dev6%2Bc1ecb2b/deepnote_toolkit-2.3.1.dev6%2Bc1ecb2b-py3-none-any.whl"

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
958 1 957 4
View the top 1 failed test(s) by shortest run time
tests/unit/test_installer_executor.py::TestRunActionsInInstallerEnv::test_streamlit_with_directory_path
Stack Traces | 0.002s run time
tests/unit/test_installer_executor.py:486: in test_streamlit_with_directory_path
    assert len(processes) == 1
E   assert 0 == 1
E    +  where 0 = len([])

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@deepnote_core/execution/registry.py`:
- Around line 250-252: The logger.warning call in the Streamlit app skipping
block is using f-string formatting instead of lazy formatting. Convert the
f-string message to use `%r` placeholders for the action.script and cwd
variables, and pass these variables as separate arguments to the logger.warning
method rather than embedding them in the format string. This ensures compliance
with the G004 linting rule for lazy logger formatting.

In `@installer/module/streamlit.py`:
- Around line 96-98: The logger.warning call around line 96-98 currently uses an
f-string to format the message. Replace the f-string with parameterized
formatting by converting it to a format string with %r placeholders for
entrypoint_path and directory_path, then pass these variables as separate
arguments to the logger.warning method instead of embedding them in the message
string. This ensures the log message is lazy-evaluated and maintains lint
compliance.

In `@tests/unit/test_streamlit.py`:
- Around line 50-54: Add explicit type hints to the test helper functions that
are currently missing them. For the `_make_apps` method, add type annotations
for the `*entrypoints` parameter (variable length arguments) and the return type
(a list of dictionaries). For both `exists_side_effect` functions referenced at
lines 62-63 and 81-82, add type hints for their parameters and return types.
Follow the coding guidelines by ensuring all parameters and return values have
explicit type annotations, making the code more maintainable and consistent with
the rest of the test file.
- Around line 65-66: The nested `with` statements for patching
`installer.module.streamlit.fetch_streamlit_apps` and
`installer.module.streamlit.os.path.exists` should be flattened into a single
`with` statement. Combine both patch calls into one context manager using comma
separation on the same line or across multiple lines with proper continuation,
removing the inner `with` statement indentation and bringing the test logic up
one level to maintain code readability and comply with SIM117. Apply this same
change to all occurrences of nested patch contexts in the test file, including
the instances at lines 84-85.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 626216d1-4440-410c-ada1-5a94c8b51067

📥 Commits

Reviewing files that changed from the base of the PR and between 3967dd5 and 086ecc9.

📒 Files selected for processing (4)
  • deepnote_core/execution/registry.py
  • installer/module/streamlit.py
  • tests/unit/test_action_registry.py
  • tests/unit/test_streamlit.py

Comment thread deepnote_core/execution/registry.py
Comment thread installer/module/streamlit.py
Comment thread tests/unit/test_streamlit.py Outdated
Comment thread tests/unit/test_streamlit.py Outdated
- Use lazy %r logger formatting (G004) in registry and streamlit module
- Fix test_streamlit_with_directory_path to create a real tmp dir so the
  new directory-existence guard does not skip the action
- Flatten nested with-patch blocks (SIM117) in test_streamlit.py
- Add type hints to test helpers in test_streamlit.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@deepnote-bot

deepnote-bot commented Jun 17, 2026

Copy link
Copy Markdown

🚀 Review App Deployment Started

📝 Description 🌐 Link / Info
🌍 Review application ra-109
🔑 Sign-in URL Click to sign-in
📊 Application logs View logs
🔄 Actions Click to redeploy
🚀 ArgoCD deployment View deployment
Last deployed 2026-06-17 14:39:46 (UTC)
📜 Deployed commit 432d924480c5893c1b5c0babbf0c4bf49be6d10b
🛠️ Toolkit version c1ecb2b

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/test_streamlit.py`:
- Line 50: The return type annotation for the _make_apps method uses a generic
`-> list` which lacks specificity. Replace this with a more explicit type hint
such as `-> list[dict]` or `-> list[dict[str, str]]` depending on the actual
structure of dictionaries being returned. This provides clearer type information
to users of the method and aligns with the coding guidelines requiring explicit
type hints.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 568650be-d382-4929-ac8c-feb4df908a30

📥 Commits

Reviewing files that changed from the base of the PR and between 086ecc9 and 7e46b57.

📒 Files selected for processing (4)
  • deepnote_core/execution/registry.py
  • installer/module/streamlit.py
  • tests/unit/test_installer_executor.py
  • tests/unit/test_streamlit.py

Comment thread tests/unit/test_streamlit.py
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 17, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 17, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unit/test_streamlit.py (1)

75-79: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use unittest assertions instead of bare assert in TestCase methods.

Lines 75-79 and 98-99 use bare asserts; switch to self.assert* for clearer failures and to avoid optimization-mode pitfalls.

Suggested patch
-        assert any("deleted_folder" in str(a) for a in mock_logger.warning.call_args[0])
-        assert mock_venv.start_server.call_count == 1
+        self.assertTrue(
+            any("deleted_folder" in str(a) for a in mock_logger.warning.call_args[0])
+        )
+        self.assertEqual(mock_venv.start_server.call_count, 1)
         started_cmd = mock_venv.start_server.call_args[0][0]
-        assert "existing_folder/app.py" in started_cmd
+        self.assertIn("existing_folder/app.py", started_cmd)
@@
-        assert mock_logger.warning.call_count == 2
-        assert mock_venv.start_server.call_count == 1
+        self.assertEqual(mock_logger.warning.call_count, 2)
+        self.assertEqual(mock_venv.start_server.call_count, 1)

Also applies to: 98-99

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_streamlit.py` around lines 75 - 79, Replace bare assert
statements with unittest assertion methods throughout the test file.
Specifically, change the bare asserts on lines 75-79 and 98-99 to use
self.assert* methods: convert assert conditions to self.assertTrue(condition),
assert equality comparisons to self.assertEqual(expected, actual), and assert
membership checks like "x in y" to self.assertIn(x, y). This provides clearer
failure messages and avoids potential issues with Python optimization modes that
can disable bare asserts.
♻️ Duplicate comments (1)
tests/unit/test_streamlit.py (1)

50-50: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Tighten type annotations on newly added test methods.

Line 50 uses a generic -> list, and Lines 56 and 80 omit return annotations. Prefer explicit types, e.g. -> list[dict[str, str]] for _make_apps and -> None for test methods.

As per coding guidelines, use “type hints consistently” and “explicit type hints for function parameters and return values.”

Suggested patch
 class TestStartStreamlitServers(unittest.TestCase):
-    def _make_apps(self, *entrypoints: str) -> list:
+    def _make_apps(self, *entrypoints: str) -> list[dict[str, str]]:
         return [
             {"id": f"id-{i}", "entrypoint": ep, "port": str(8501 + i), "projectId": "p"}
             for i, ep in enumerate(entrypoints)
         ]
 
-    def test_skips_app_when_directory_missing(self):
+    def test_skips_app_when_directory_missing(self) -> None:
@@
-    def test_continues_after_skipped_app(self):
+    def test_continues_after_skipped_app(self) -> None:

Also applies to: 56-56, 80-80

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_streamlit.py` at line 50, The test methods in this file have
insufficient type annotations that need to be tightened according to coding
guidelines. Update the return type annotation for the _make_apps method on line
50 from the generic `-> list` to a more explicit type such as `-> list[dict[str,
str]]` to clearly indicate what the list contains. Additionally, add missing
return type annotations of `-> None` to the test methods at lines 56 and 80, as
test methods do not return values and should have explicit type hints for
consistency with the coding guidelines.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/unit/test_streamlit.py`:
- Around line 75-79: Replace bare assert statements with unittest assertion
methods throughout the test file. Specifically, change the bare asserts on lines
75-79 and 98-99 to use self.assert* methods: convert assert conditions to
self.assertTrue(condition), assert equality comparisons to
self.assertEqual(expected, actual), and assert membership checks like "x in y"
to self.assertIn(x, y). This provides clearer failure messages and avoids
potential issues with Python optimization modes that can disable bare asserts.

---

Duplicate comments:
In `@tests/unit/test_streamlit.py`:
- Line 50: The test methods in this file have insufficient type annotations that
need to be tightened according to coding guidelines. Update the return type
annotation for the _make_apps method on line 50 from the generic `-> list` to a
more explicit type such as `-> list[dict[str, str]]` to clearly indicate what
the list contains. Additionally, add missing return type annotations of `->
None` to the test methods at lines 56 and 80, as test methods do not return
values and should have explicit type hints for consistency with the coding
guidelines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6499c163-f6d9-4063-9c1c-5e79d773af24

📥 Commits

Reviewing files that changed from the base of the PR and between cc17e44 and c140e7b.

📒 Files selected for processing (1)
  • tests/unit/test_streamlit.py

@robertlacok robertlacok marked this pull request as ready for review June 19, 2026 12:05
@robertlacok robertlacok requested a review from a team as a code owner June 19, 2026 12:05
@robertlacok robertlacok requested a review from m1so June 19, 2026 12:05
@robertlacok robertlacok enabled auto-merge (squash) June 19, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants