question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hot load doesn't work in a package setting

See original GitHub issue

Summary

When changing an imported module/function’s code, streamlit won’t reload properly.

Steps to reproduce

Setting

Code

Assume the following tree structure:

.
├── mymod
│   ├── __init__.py
│   ├── dashboard
│   │   ├── __init__.py
│   │   └── app.py
│   └── foo.py
└── setup.py

with the following code:

# setup.py
from setuptools import setup

setup(name="mymod", version="0.1", packages=["mymod"], zip_safe=False)
# foo.py
def combine_numbers(a, b):
    return a+b
# app.py
import streamlit as st
from mymod.foo import combine_numbers

print(combine_numbers(2, 3))
st.write(combine_numbers(2, 3))

Environment

Create a conda environment with Python 3.7 and install streamlit using pip. In addition install the package using pip install -e ..

What next?

  • Run the application streamlit run mymod/dashboard/app.py.
  • As expected, 5 is rendered.
  • Edit the file foo.py and replace + with *
  • go back to the app.
  • 6 is not rendered. Rerunning the app doesn’t help. Only killing the app and restarting it picks up the change in foo.py.

Expected behavior:

I would hope that streamlit will pick up changes in depending files

Actual behavior:

In order for the app to reflect changes in the imported code, the app has to be restarted.

Is this a regression?

no

Debug info

  • Streamlit version: 0.56.0
  • Python version: 3.7.6
  • Using conda
  • OS version: macOS 10.14.6
  • Browser version: Chrome 80.0.3987.106

Additional information

Related to #358 as per @tconkling request.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

2reactions
monchiercommented, Feb 28, 2020

Hi @drorata, by default, we only watch modules contained in the current directory of the main app module. This means that in your case, foo.py is not tracked.

You can change the default behavior by adding the parent directory of the module you want to track to the PYTHONPATH. Let me know if this helps. We implemented this here.

matteo

1reaction
droratacommented, Feb 27, 2020

I would be happy to provide more information about this problem. At the moment, I can only say this is really slowing down the work with streamlit 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload is not working in my React App - Stack Overflow
If your page is not loading automatically then you have to do these ... Go to package.json and replace react, react-dom and react-scripts ......
Read more >
Hot reload - Flutter documentation
Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn't rerun main() or initState()...
Read more >
Module Methods - webpack
This section covers all methods available in code compiled with webpack. When using webpack to bundle your application, you can pick from a...
Read more >
Troubleshoot connecting to the app during setup - Google Help
Troubleshoot connecting to the app during setup · 1. Check your camera's distance to the router · 2. Restart your camera · 3....
Read more >
webpack-dev-server - npm
TypeScript icon, indicating that this package has built-in type ... Note: While you can install and run webpack-dev-server globally, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found