-
Notifications
You must be signed in to change notification settings - Fork 954
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
Hot loading asset folder on development #643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, we really needed this!
Just have 2 main questions and some minor typo comments.
pynecone/utils.py
Outdated
@@ -622,6 +623,10 @@ def run_frontend(app: App, root: Path, port: str): | |||
# Set up the frontend. | |||
setup_frontend(root) | |||
|
|||
# start watching asset folder | |||
asset_watch = AssetFolderWatch(root) | |||
asset_watch.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to stop the watch? For example when they ctrl+c, will this still be watching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to do that.
This is a daemon thread so will be killed when the main thread is exited even if it is caused with ctrl+c.
pynecone/watch.py
Outdated
|
||
|
||
class AssetFolderHandler(FileSystemEventHandler): | ||
"""Asset folder event handelr.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: handler
pynecone/watch.py
Outdated
self.root = root | ||
|
||
def on_modified(self, event: FileSystemEvent): | ||
"""Event hander when a file or folder was modified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handler
pynecone/watch.py
Outdated
This is called every time after a file is created, modified and deleted. | ||
|
||
Args: | ||
event: Event infomation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: information
pyproject.toml
Outdated
@@ -49,6 +49,7 @@ toml = "^0.10.2" | |||
pytest-asyncio = "^0.20.1" | |||
black = "^22.10.0" | |||
ruff = "^0.0.244" | |||
watchdog = "^2.3.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we need this in the main dependencies since we need it to be installed in pip install pynecone
This also needs to be rebased since we just merged a PR that updated the dependencies. |
Ok, I will. |
4c1a24f
to
ed88f0d
Compare
Fix reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Description
Add feature for watching
assets
folder changes, and do same changes on.web/public
folder.To work this just execute
pc run
with development, but not production.Close #540.