Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve autoreload of external packages #6459

Merged
merged 29 commits into from
Mar 13, 2024
Merged

Improve autoreload of external packages #6459

merged 29 commits into from
Mar 13, 2024

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Mar 7, 2024

Currently --autoreload only reloads the app itself and any one module that has changed. In practice this isn't really enough because most modules will be interconnected pretty deeply, so instead of reloading the specific module we are talking about we will reload all modules that were recorded during startup.

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 46.83258% with 235 lines in your changes are missing coverage. Please review.

Project coverage is 71.45%. Comparing base (2a2af56) to head (04bbbf6).

Files Patch % Lines
panel/io/handlers.py 24.83% 115 Missing ⚠️
panel/tests/ui/io/test_reload.py 31.37% 35 Missing ⚠️
panel/io/reload.py 46.03% 34 Missing ⚠️
panel/tests/conftest.py 48.71% 20 Missing ⚠️
panel/io/server.py 46.66% 16 Missing ⚠️
panel/io/application.py 83.05% 10 Missing ⚠️
panel/tests/ui/io/app.py 0.00% 2 Missing ⚠️
panel/command/serve.py 0.00% 1 Missing ⚠️
panel/io/document.py 95.65% 1 Missing ⚠️
panel/io/jupyter_executor.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6459       +/-   ##
===========================================
- Coverage   82.13%   71.45%   -10.68%     
===========================================
  Files         312      314        +2     
  Lines       46122    46309      +187     
===========================================
- Hits        37881    33091     -4790     
- Misses       8241    13218     +4977     
Flag Coverage Δ
ui-tests ?
unitexamples-tests 71.45% <46.83%> (-0.10%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philippjfr philippjfr requested a review from hoxbro March 12, 2024 08:37
Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

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

I have looked at the code. I still want to test it out, but I left some comments.

I don't think we should use Pathlib for this low-level stuff. There is a time penalty for creating each of the objects. I have tried to update some, but please check.

panel/io/reload.py Show resolved Hide resolved
panel/io/server.py Outdated Show resolved Hide resolved
pass
self._servers = {}
if server_id in self._threads:
self._threads[server_id].stop()
Copy link
Member

Choose a reason for hiding this comment

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

Is it ok to raise an error now for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not quite following.

Copy link
Member

@hoxbro hoxbro Mar 12, 2024

Choose a reason for hiding this comment

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

The lines above, was wrapped in try/except.

        for thread in self._threads.values():
            try:
                thread.stop()
            except Exception:
                pass

panel/io/state.py Show resolved Hide resolved
panel/io/handlers.py Show resolved Hide resolved
panel/io/reload.py Outdated Show resolved Hide resolved
panel/io/reload.py Outdated Show resolved Hide resolved
panel/io/reload.py Outdated Show resolved Hide resolved
panel/io/reload.py Outdated Show resolved Hide resolved
panel/io/reload.py Outdated Show resolved Hide resolved
@philippjfr
Copy link
Member Author

Thanks for the review, I'll wait for tests to pass and then apply your suggestions.

@hoxbro
Copy link
Member

hoxbro commented Mar 12, 2024

I just did (light) some testing of the PR, and it seems to work as promised 👍

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
pyproject.toml Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit b43dfe3 into main Mar 13, 2024
11 of 15 checks passed
@philippjfr philippjfr deleted the reload_all_modules branch March 13, 2024 00:24
@hoxbro hoxbro restored the reload_all_modules branch March 13, 2024 19:55
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