-
-
Notifications
You must be signed in to change notification settings - Fork 291
feat: live reloading when running as a module #858
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
base: main
Are you sure you want to change the base?
Conversation
@VishnuSanal is attempting to deploy a commit to the sparckles Team on Vercel. A member of the Team first needs to authorize it. |
CodSpeed Performance ReportMerging #858 will not alter performanceComparing Summary
|
Hey @VishnuSanal 👋 I am unable to understand the changes. Could you add an example on why we need the new parameters? And how you'd invoke the changes? |
9dce07a
to
e72f14a
Compare
Hey @VishnuSanal , |
uh, oh. my previous comment never got sent.
I have changed the implementation, PTAL. removed the need for new params.
running as a module usually, like please CMIIW. |
@VishnuSanal , I just saw your description. That is not what we want to solve for 😄 We want to allow the dev mode to work like where src
The --dev flag should rerender based on app changes. |
e72f14a
to
78b9dda
Compare
thank you for the review, Sanskar! this currently works as expected in my testing, PTAL & LMK what you think. :) |
Hey @VishnuSanal 👋 Thanks for the PR, I have some comments 😄 |
Hey @VishnuSanal 👋 Thanks for the update. I have some follow up comments |
robyn/reloader.py
Outdated
env=new_env, | ||
start_new_session=False, | ||
) | ||
if self.config.dev and self.config.file_path is not None: |
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.
Can we not use self.file_path
?
Then we don't need to pass in config
.
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 also need config.dev
. should I pass it as a variable?
edit: we also need running_as_module
now.
current issues:
(will edit & update this comment as I fix them...) |
# Conflicts: # robyn/reloader.py
note to self: the flow of control is like: cli#run => cli#start_dev_server => reloader#setup_reloader => EventHandler#reload => Robyn#start and, we are getting the file object at the last stage. my current implementation starts a new dev server from there. we need a way to bypass it the first time (inorder to reach as of now, I am getting an infinite loop! will address. :) |
07f28de
to
0b766c9
Compare
|
|
||
# find something that ends with .py in unknown_args | ||
for arg in unknown_args: | ||
if arg.endswith(".py"): | ||
self.file_path = arg | ||
break | ||
else: | ||
self.file_path = sys.argv[0] |
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.
Unsafe access to sys.argv[0] without checking if sys.argv is empty. This can raise an IndexError when Python is run in environments where sys.argv is an empty list (e.g., certain Python interpreters or when running through specific APIs). The code should check sys.argv length before accessing the first element. A safer approach would be: self.file_path = sys.argv[0] if len(sys.argv) > 0 else ''
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
from .argument_parser import Config | ||
from .reloader import create_rust_file, setup_reloader | ||
|
||
from robyn.dev_server import start_dev_server |
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.
The import changes introduce a breaking change in dependency initialization. The old code imported and used setup_reloader directly from reloader.py, but the new dev_server.py only imports the reloader module without importing setup_reloader. This will cause a NameError when the dev server tries to use setup_reloader since it's not properly imported in dev_server.py.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
if file_path is None: | ||
return | ||
|
||
absolute_file_path = (Path.cwd() / file_path).resolve() |
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.
Unsafe path resolution: Using resolve() on a potentially non-existent path without error handling can raise FileNotFoundError or other path-related exceptions. This could crash the server when given invalid paths. Should wrap the path resolution in a try-catch block to handle potential path-related exceptions gracefully.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
😱 Found 3 issues. Time to roll up your sleeves! 😱 |
Description
This PR fixes #654
how to run:
python3 -m app --dev