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

Hot loading asset folder on development #643

Merged
merged 1 commit into from Mar 8, 2023

Conversation

PeterYusuke
Copy link
Contributor

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to 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.

Copy link
Contributor

@picklelo picklelo left a 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.

@@ -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()
Copy link
Contributor

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?

Copy link
Contributor Author

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.



class AssetFolderHandler(FileSystemEventHandler):
"""Asset folder event handelr."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: handler

self.root = root

def on_modified(self, event: FileSystemEvent):
"""Event hander when a file or folder was modified.
Copy link
Contributor

Choose a reason for hiding this comment

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

handler

This is called every time after a file is created, modified and deleted.

Args:
event: Event infomation.
Copy link
Contributor

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"
Copy link
Contributor

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

@picklelo
Copy link
Contributor

picklelo commented Mar 7, 2023

This also needs to be rebased since we just merged a PR that updated the dependencies.

@PeterYusuke
Copy link
Contributor Author

This also needs to be rebased since we just merged a PR that updated the dependencies.

Ok, I will.

@PeterYusuke
Copy link
Contributor Author

Fix reviews.

Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

awesome!

@picklelo picklelo merged commit 6e74cb0 into reflex-dev:main Mar 8, 2023
@PeterYusuke PeterYusuke deleted the watching-assets branch March 9, 2023 00:03
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.

Assets directory instant refresh
2 participants