-
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
Open
ElijahAhianyo
wants to merge
15
commits into
main
Choose a base branch
from
elijah/app-in-rxconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+140
−28
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
62f15a4
Allow custom app module in rxconfig
ElijahAhianyo 73416e3
what was that pyscopg mess?
ElijahAhianyo c9d967e
fix another mess
ElijahAhianyo d32033e
get this working with relative imports and hot reload
ElijahAhianyo e5817bc
typing to named tuple
ElijahAhianyo 2838494
minor refactor
ElijahAhianyo c446fa8
revert redis knobs positions
ElijahAhianyo a352424
fix pyright except 1
ElijahAhianyo 9e04be4
fix pyright hopefully
ElijahAhianyo b92720c
use the resolved module path
ElijahAhianyo c9f320f
testing workflow
ElijahAhianyo f80b645
move nba-proxy job to counter job
ElijahAhianyo 839742c
just cast the type
ElijahAhianyo 7f9beed
fix tests for python 3.9
ElijahAhianyo dc34c9a
darglint
ElijahAhianyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,6 +240,19 @@ def run_backend( | |
run_uvicorn_backend(host, port, loglevel) | ||
|
||
|
||
def get_reload_dirs() -> list[str]: | ||
"""Get the reload directories for the backend. | ||
|
||
Returns: | ||
The reload directories for the backend. | ||
""" | ||
config = get_config() | ||
reload_dirs = [config.app_name] | ||
if app_module_path := config.app_module_path: | ||
reload_dirs.append(str(Path(app_module_path).resolve().parent.parent)) | ||
Comment on lines
+251
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
return reload_dirs | ||
|
||
|
||
def run_uvicorn_backend(host, port, loglevel: LogLevel): | ||
"""Run the backend in development mode using Uvicorn. | ||
|
||
|
@@ -256,7 +269,7 @@ def run_uvicorn_backend(host, port, loglevel: LogLevel): | |
port=port, | ||
log_level=loglevel.value, | ||
reload=True, | ||
reload_dirs=[get_config().app_name], | ||
reload_dirs=get_reload_dirs(), | ||
) | ||
|
||
|
||
|
@@ -281,7 +294,7 @@ def run_granian_backend(host, port, loglevel: LogLevel): | |
interface=Interfaces.ASGI, | ||
log_level=LogLevels(loglevel.value), | ||
reload=True, | ||
reload_paths=[Path(get_config().app_name)], | ||
reload_paths=get_reload_dirs(), | ||
reload_ignore_dirs=[".web"], | ||
).serve() | ||
except ImportError: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.