Skip to content

fix(reload): exclude marimo package from modulefinder crawl#10249

Merged
mscolnick merged 1 commit into
marimo-team:mainfrom
Bartok9:top10/fix-exclude-marimo-namespace-modulefinder
Jul 23, 2026
Merged

fix(reload): exclude marimo package from modulefinder crawl#10249
mscolnick merged 1 commit into
marimo-team:mainfrom
Bartok9:top10/fix-exclude-marimo-namespace-modulefinder

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This pull request was authored by a coding agent.

AI-assisted; human-reviewed line-by-line. Submitted under Daniel's standing Top10 merge-culture campaign instruction for Bartok9.

Summary

Closes #10225.

modulefinder.ModuleFinder cannot walk namespace packages. marimo ships several (marimo/_dependencies, etc.). Pip installs hide this because marimo lives under site-packages and is already excluded as third-party; editable installs do not, so dependency analysis fails quietly and autoreload misses chains.

Change

  • _is_marimo_internal_module_name for marimo / marimo.*
  • _get_excluded_modules always adds "marimo" and filters internal names
  • Unit tests for exclusion behavior (including empty-module map baseline)

Tests

pytest tests/_runtime/reload/test_module_watcher.py::TestGetExcludedModules

Pre-Review Checklist

Merge Checklist

  • CONTRIBUTING read
  • Tests added
  • Docs N/A (internal reload)

@Bartok9

Bartok9 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 22, 2026 4:37pm

Request Review

@Bartok9

Bartok9 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@Bartok9
Bartok9 marked this pull request as ready for review July 20, 2026 22:53
@dmadisetti

Copy link
Copy Markdown
Member

Thanks! Can you clean up the comments to be more general? Aside from that LGTM

@Bartok9

Bartok9 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Cleaned up the comments to be more general — dropped the issue-specific detail and namespace-package explanation, kept the docstring to a one-liner and trimmed the root-package note. Ready for another look.

Copilot AI 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.

Pull request overview

This PR addresses autoreload dependency discovery failing for editable installs when modulefinder.ModuleFinder encounters marimo’s namespace-package layout, by ensuring marimo modules are excluded from the dependency crawl (issue #10225).

Changes:

  • Add _is_marimo_internal_module_name() to identify marimo / marimo.* module names.
  • Update _get_excluded_modules() to exclude marimo internal modules (in addition to site-packages modules).
  • Add unit tests covering marimo exclusion behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
marimo/_runtime/reload/module_watcher.py Adds marimo-internal module detection and expands excluded-module computation to prevent modulefinder crashes on marimo’s package tree.
tests/_runtime/reload/test_module_watcher.py Adds tests validating marimo exclusion behavior for editable-install scenarios.
Comments suppressed due to low confidence (1)

marimo/_runtime/reload/module_watcher.py:127

  • _get_excluded_modules() now unconditionally adds "marimo", which makes the function return a non-empty set even when the provided modules dict contains only user modules (this breaks the existing test_get_excluded_modules_empty expectation and changes the semantics from "exclude third-party/marimo modules present" to "always exclude marimo"). If the intent is only to avoid crawling marimo when it's actually loaded (the production call passes sys.modules, where marimo will be present), gate this addition on whether any marimo module names are present in modules.
    sys_modules: dict[str, types.ModuleType],
) -> dict[str, types.ModuleType]:
    """Returns the set of modules used by the graph that have been modified"""

mscolnick
mscolnick previously approved these changes Jul 22, 2026
@Light2Dark Light2Dark added the bug Something isn't working label Jul 22, 2026
stdlib modulefinder crashes on marimo namespace packages (dirs without
__init__.py). Editable installs are not under site-packages, so marimo
was never excluded and autoreload silently lost dependency chains.

Always exclude marimo and marimo.* module names from the finder excludes
set, and update the local-only unit expectation accordingly.

Closes marimo-team#10225.

Signed-off-by: Bartok9 <danielrpike9@gmail.com>
@Bartok9
Bartok9 force-pushed the top10/fix-exclude-marimo-namespace-modulefinder branch from abe02f1 to 2d89acf Compare July 22, 2026 16:36
@Bartok9

Bartok9 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @mscolnick — and sorry the approval got dismissed.

CI red was real: TestGetExcludedModules::test_get_excluded_modules_empty still expected set() while _get_excluded_modules now always adds bare "marimo" for modulefinder. Fixed the unit expectation and rebased onto current main (2d89acf63) so the matrix can go green again. Ready when you have a moment for a re-check.

@Bartok9

Bartok9 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@mscolnick
mscolnick merged commit 89d25f5 into marimo-team:main Jul 23, 2026
39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.15-dev63

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modulefinder crashes on marimo's own namespace packages (breaks autoreload for editable installs)

5 participants