Skip to content

Commit

Permalink
Update hot reloading logic in execute_module.py
Browse files Browse the repository at this point in the history
This change separates the hot reloading logic for the mesop module and external app modules.

Before this fix, if the app module is outside of the mesop module, then changes to code in labs would not be reflected in the hot reload.
  • Loading branch information
richard-to committed Apr 18, 2024
1 parent 11c8d36 commit ba5343d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mesop/cli/execute_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ def get_app_modules(

submodules: set[str] = set()
for module in loaded_module_names:
module_segments = module.split(".")

# Special case for mesop/example_index.py, which would normally consider
# everything in `mesop` a sub-package/sub-module, however reloading modules
# like runtime causes weird bugs. Thus, we only reload "app" modules and
# not any core framework modules.
module_segments = module.split(".")
if (
module_segments[0] == "mesop"
and not (
if module_segments[0] == "mesop":
if (
module_segments[:2] == ["mesop", "example_index"]
or module_segments[:2] == ["mesop", "examples"]
# Reset labs (b/c io.py needs to re-register stateclass)
or module_segments[:2] == ["mesop", "labs"]
or "e2e" in module_segments
)
):
continue
if (
):
submodules.add(module)
# We also want to hot reload user "app" modules.
elif (
module.split(".")[: len(main_module_prefix_segments)]
== main_module_prefix_segments
):
Expand Down

0 comments on commit ba5343d

Please sign in to comment.