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

User-Controlled Module Reloading for Enhanced Development Workflow #7288

Closed
DavidHJong opened this issue Mar 5, 2024 · 2 comments
Closed
Milestone

Comments

@DavidHJong
Copy link

Problem

I'm always frustrated when I make updates to a custom Python package during development in Jupyter Notebook and have to restart the entire kernel for changes to take effect. This process disrupts the flow of development, especially for testing minor changes in the code. The use of importlib.reload() is a workaround but can lead to inconsistent states within the notebook for complex modules or those with nested dependencies.

Proposed Solution

Introduce a built-in feature or command in Jupyter Notebook that allows users to explicitly reload a specific package or module without restarting the kernel. This could be implemented as a simple notebook magic command (e.g., %reload my_module) that would ensure the module is reloaded from disk, reflecting any changes made. This command should handle the re-import and refresh of the module in a way that ensures consistency across the notebook, providing a seamless development experience.

Additional context

Introducing a feature for explicit module reloading in Jupyter Notebook addresses a key workflow challenge: the inability to reflect module changes without restarting the kernel. This limitation stems from Python's module caching mechanism, which doesn't automatically refresh imported modules after they're modified. Other development environments, such as Visual Studio Code and PyCharm, offer solutions like manual reload commands or automatic "reload on save" features for certain applications, significantly enhancing developer efficiency. By enabling similar functionality in Jupyter Notebook, we can streamline the development process, making it more efficient and aligned with modern coding practices.

@DavidHJong DavidHJong added enhancement status:Needs Triage Applied to issues that need triage labels Mar 5, 2024
@RRosio RRosio removed the status:Needs Triage Applied to issues that need triage label Mar 5, 2024
@jtpio
Copy link
Member

jtpio commented Mar 5, 2024

(e.g., %reload my_module)

This one maybe? https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html

@DavidHJong
Copy link
Author

Thank you @jtpio. It's exactly what I want.

@jtpio jtpio added this to the Reference milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants