-
Notifications
You must be signed in to change notification settings - Fork 105
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
reorganize code into submodules #106
Merged
Merged
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
8a78e3e
move api code to submodule
geospatial-jeff c7bb70f
add symlink
geospatial-jeff 07d83f9
fix symlink
geospatial-jeff 8d3904e
fastapi_stac -> stac_fastapi
geospatial-jeff a8c6db1
update symlink
geospatial-jeff 944383b
add app routes, update imports
geospatial-jeff 02f14ff
rename
geospatial-jeff 7dc6836
add backend submodule
geospatial-jeff 5713a5e
add symlink
geospatial-jeff a4e6133
update imports
geospatial-jeff 39452be
add extensions submodule, move core extensions from api
geospatial-jeff 2eec4ad
add extensions symlink
geospatial-jeff cbc839e
move bulk transactions to third party extensions
geospatial-jeff 67cc8a8
move tiles extension to third_party
geospatial-jeff 4e48d07
backend.client -> backend.core
geospatial-jeff 66f80ac
define third party clients next to the extension
geospatial-jeff ed9ebad
remove third party clients from core
geospatial-jeff d46da52
correct package names
geospatial-jeff 778f0fa
create postgres submodule, move the sqlalchemy code
geospatial-jeff a702e0e
move config
geospatial-jeff 7bcc6e8
update extension imports
geospatial-jeff 1ce6f3d
move errors
geospatial-jeff 52304f8
move openapi
geospatial-jeff be1d38e
fix tests
geospatial-jeff 9cafb60
add types submodule for shared types, finish moving db code, save pro…
geospatial-jeff a07e5a8
lint everything, remove mypy for now
geospatial-jeff 57d15a4
update pytest.ini
geospatial-jeff 8f41986
Updates to submodules PR (#109)
lossyrob 4c86cee
lint
geospatial-jeff 7af256e
rename postgres package to sqlalchemy
geospatial-jeff c2f4ae1
rename PostgresSettings to SqlalchemySettings
geospatial-jeff bb211c2
update readme
geospatial-jeff 6fec90d
relock types pipfile
geospatial-jeff 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../stac_fastapi_api/fastapi_stac/api |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
"""route factories.""" | ||
from typing import Callable, Type | ||
|
||
from fastapi import Depends | ||
from pydantic import BaseModel | ||
from starlette.requests import Request | ||
|
||
from stac_fastapi.api.models import APIRequest | ||
|
||
|
||
# TODO: Only use one endpoint factory | ||
def create_endpoint_from_model( | ||
func: Callable, request_model: Type[BaseModel] | ||
) -> Callable: | ||
"""Create a FastAPI endpoint from pydantic model. | ||
|
||
Wrap a callable in a function which uses the desired request model. It is expected | ||
that the signature of the callable matches that of the request model. This is best for validating | ||
request bodies (ex. POST requests). | ||
|
||
Args: | ||
func: the wrapped function. | ||
request_model: a pydantic model. | ||
|
||
Returns: | ||
callable: fastapi route which may be added to a router/application | ||
""" | ||
|
||
def _endpoint( | ||
request: Request, | ||
request_data: request_model, # type:ignore | ||
): | ||
"""Endpoint.""" | ||
resp = func(request_data, request=request) | ||
return resp | ||
|
||
return _endpoint | ||
|
||
|
||
def create_endpoint_with_depends( | ||
func: Callable, | ||
request_model: Type[APIRequest], | ||
) -> Callable: | ||
"""Create a FastAPI endpoint from an `APIRequest` (dataclass). | ||
|
||
Wrap a callable in a function which uses the desired `APIRequest` to define request parameters. It is expected | ||
that the return of `APIRequest.kwargs` matches that of the callable. This works best for validating query/path | ||
parameters (ex. GET request) and allows for dependency injection. | ||
|
||
Args: | ||
func: the wrapped function | ||
request_model: subclass of `APIRequest` | ||
|
||
Returns: | ||
callable: fastapi route which may be added to a router/application | ||
""" | ||
|
||
def _endpoint( | ||
request: Request, | ||
request_data: request_model = Depends(), # type:ignore | ||
): | ||
"""Endpoint.""" | ||
resp = func( | ||
request=request, **request_data.kwargs() # type:ignore | ||
) | ||
return resp | ||
|
||
return _endpoint |
File renamed without changes.
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
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.
It's intentional to still import from both
stac_api
andstac_fastapi
?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'm switching out the imports to
stac_fastapi
as I make the submodules. By the time I'm done everything should bestac_fastapi
.