-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix(standalone): fix api path when embedding front-end #2136
fix(standalone): fix api path when embedding front-end #2136
Conversation
Signed-off-by: Sylvain Leclerc <[email protected]>
The way we build the standalone version is completely reviewed, because it does not work anymore with recent versions of starlette. The existing code was not correctly using root_path. Actually, adding a prefix to the API requires to explicitly add it to routes. It's a new configuration property "api_prefix" (using fastapi sub-application could be an alternative solution). Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Enable the use of pytest-xdist to run tests in parallel, in CI or developer env. Following issues with parallel execution of tests are solved : - some checks depended on the consistency at 2 moments in time of the result of disk_usage, which was anyway not a good idea (dependent on what happens elsewhere on the machine). It's now replaced with mocking - some parameterized tests had random sort order, which is not allowed by pytest-xdist (all workers must have exactly the same tests in the same order) - the command_factory test checked something in its teardown, assuming all tests were executed in the same process, which is not the case anymore. The same check is done as a separate unit tests. Possible remaining issue which could cause some timeouts: some services hold FileLock which have the same identifier accross multiple tests. Signed-off-by: Sylvain Leclerc <[email protected]>
431bb60
to
722629b
Compare
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 like the fact that you eliminated a lot of duplicate code.
@@ -58,4 +60,5 @@ def camel_case_model(model: t.Type[BaseModel]) -> t.Type[BaseModel]: | |||
field.alias = new_alias | |||
field.validation_alias = new_alias | |||
field.serialization_alias = new_alias | |||
field.alias_priority = 2 |
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 prefer defining constants like these as global variables for the module.
This enforces maintainability and gives an explicit documentation for the variable using via the naming.
Example:
DEFAULT_ALIAS_PRIORITY=2
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.
Indeed! Actually I just removed the line, I left it by mistake, this change is not needed.
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
669ce11
into
feature/1724-upgrade-python-dependencies
Context
When including the front-end application in the python server (standalone or "desktop" mode),
we want to be able to append a /api prefix to backend URLs.
So far, this has not been correctly done:
root_path
has been used, whereas it does not actually change the URLs, its only purposeis for the server to know that it's behind a proxy which exposes this prefix to the client,
see fastapi doc about this.
This has more or less worked so far because of a bug in starlette: the server indeed served
the services at both URLs: with a without the prefix.
With newer fastapi and starlette versions, this does not work anymore: the desktop application
is broken. We need to clean up the implementation to actually serve the services with a prefix.
Implementation
Another configuration property
api_prefix
is introduced, which is used to prefix allbackend routes (through a "root"
APIRouter
).All front related logic is moved to a dedicated module
antarest.front
.