-
-
Notifications
You must be signed in to change notification settings - Fork 190
Watch mode to rebuild all files & restart everything on file changes #16
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
Comments
Hot reloading is more than on the list of TODOs, there's a work in progress PR: plotly/dash#362 that has seen substantial development. Read through the discussion to find the latest release candidate that you can pip install to try out. |
If the py files are regenerated with changes and used by the running code, it will be picked up by the reloader in plotly/dash#362 2a: Why would it touch Also, this repo is being transformed in a cookiecutter #14. |
Well werkzeug's default auto-reloader dash-component-boilerplate/my_dash_component/__init__.py Lines 46 to 47 in eaceef1
Which is why werkzeug's reloader will never listen to them. Of course, touching One solution would be to add the imported module to --- a/my_dash_component/__init__.py
+++ b/my_dash_component/__init__.py
@@ -6,6 +6,9 @@ import json
import dash as _dash
+import types
+from os import path
+
if not hasattr(_dash, 'development'):
print('Dash was not successfully imported. '
'Make sure you don\'t have a file '
@@ -47,3 +50,7 @@ for _component in _components:
setattr(_this_module, _component.__name__, _component)
setattr(_component, '_js_dist', _js_dist)
setattr(_component, '_css_dist', _css_dist)
+ module_name = "%s.%s" % (__name__, _component.__name__)
+ fake_module = types.ModuleType(module_name)
+ setattr(fake_module, "__file__", path.join(path.dirname(path.abspath(_this_module.__file__)), "%s.py" % _component.__name__))
+ _sys.modules[module_name] = fake_module
That's pretty cool and works nicely (awesome work!), but as long as the generated components aren't imported to Python's global |
You looking at the outdated It doesn't need to touch |
Hot reload now reloads when the bundle is rebuilt. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
So I am a big fan of tooling that auto-reloads everything on a change.
Thus I'm currently using this simple setup to automatically rebuild the JS and Python bundles + restart the web server.
1) Running webpack in
watch
mode2) Rebuilding the meta information on every change
gunicorn
supports this partially out of the box, e.g.Though of course this won't refresh your browser.
Ideas
While for many users the
webpack-serve
(as part ofnpm run start
) will do just fine, I think the user experience could be improved with:npm run app
in an easy way.2a)
build:py
could touchusage.py
, s.t. even an out of the box Flask does a reload when a new meta extraction has been run2b) Alternatively, one could pass the generated Python modules in
my_dash_component
to Flask asextra_files
, s.t. its built-in reloader takes notice of them (see e.g. http://werkzeug.pocoo.org/docs/0.14/serving and http://flask.pocoo.org/docs/1.0/api/#flask.Flask.run)What are your thoughts on this? (1) and (2) are easy and I would be happy to send quick PRs for this.
The text was updated successfully, but these errors were encountered: