-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ENG-4134]Allow specifying custom app module in rxconfig #4556
base: main
Are you sure you want to change the base?
Conversation
reflex/config.py
Outdated
@property | ||
def module(self) -> str: | ||
"""Get the module name of the app. | ||
|
||
Returns: | ||
The module name. | ||
""" | ||
if self.app_module: | ||
return f"{Path(self.app_module.__file__).parent.name}.{Path(self.app_module.__file__).stem}" |
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.
wondering if this is what we should be doing. Or should we return the absolute path here? Im trying to think of where doing it like this could pose a real problem
2bbdb4c
to
c9d967e
Compare
integration tests need reflex-dev/reflex-examples#291 to pass |
""" | ||
module_name = Path(path).stem | ||
module_path = Path(path).resolve() | ||
sys.path.insert(0, str(module_path.parent.parent)) |
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.
i don't like the assumption that the pythonpath entry is module_path.parent.parent
.
i think a better approach would make the caller responsible for setting their sys.path
/ PYTHONPATH
, and then providing an importable name.
That would save us this complicated import machinery that makes assumptions that would be hard to undo later, we could just use __import__
, like we have been.
if app_module_path := config.app_module_path: | ||
reload_dirs.append(str(Path(app_module_path).resolve().parent.parent)) |
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.
i think for this one, we should go up the parent directories until we don't find an __init__.py
, this should be the root of the reload dir for an out-of-tree app module.
updated by comment from before. i realize we can't actually instantiate an |
@ElijahAhianyo i opened a PR into your branch #4644 for your review |
Example app: reflex-dev/reflex-examples#291