Skip to content
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

Improve separation of concerns between core and backend libraries #453

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is again not directly related to this refactor, but helped speed up the Docker builds

docker-compose.yml
**/__pycache__
*.pyc
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ services:
dockerfile: Dockerfile
platform: linux/amd64
volumes:
- ./stac_fastapi:/app/stac_fastapi
- ./scripts:/app/scripts
- ./tests:/app/tests
- ./stac_fastapi:/opt/src/stac_fastapi
- ./scripts:/opt/src/scripts
- ./tests:/opt/src/tests
command:
- bash
- -c
Expand Down
20 changes: 12 additions & 8 deletions stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def register_landing_page(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.landing_page, EmptyRequest, self.response_class
self.client.handle_landing_page, EmptyRequest, self.response_class
),
)

Expand All @@ -164,7 +164,7 @@ def register_conformance_classes(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.conformance, EmptyRequest, self.response_class
self.client.handle_conformance, EmptyRequest, self.response_class
),
)

Expand All @@ -183,7 +183,7 @@ def register_get_item(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.get_item, ItemUri, self.response_class
self.client.handle_get_item, ItemUri, self.response_class
),
)

Expand All @@ -205,7 +205,9 @@ def register_post_search(self):
response_model_exclude_none=True,
methods=["POST"],
endpoint=self._create_endpoint(
self.client.post_search, self.search_post_request_model, GeoJSONResponse
self.client.handle_post_search,
self.search_post_request_model,
GeoJSONResponse,
),
)

Expand All @@ -227,7 +229,9 @@ def register_get_search(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.get_search, self.search_get_request_model, GeoJSONResponse
self.client.handle_get_search,
self.search_get_request_model,
GeoJSONResponse,
),
)

Expand All @@ -248,7 +252,7 @@ def register_get_collections(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.all_collections, EmptyRequest, self.response_class
self.client.handle_all_collections, EmptyRequest, self.response_class
),
)

Expand All @@ -267,7 +271,7 @@ def register_get_collection(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.get_collection, CollectionUri, self.response_class
self.client.handle_get_collection, CollectionUri, self.response_class
),
)

Expand Down Expand Up @@ -298,7 +302,7 @@ def register_get_item_collection(self):
response_model_exclude_none=True,
methods=["GET"],
endpoint=self._create_endpoint(
self.client.item_collection, request_model, self.response_class
self.client.handle_collection_items, request_model, self.response_class
),
)

Expand Down
12 changes: 6 additions & 6 deletions stac_fastapi/extensions/core/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def register_create_item(self):
response_model_exclude_unset=True,
response_model_exclude_none=True,
methods=["POST"],
endpoint=self._create_endpoint(self.client.create_item, PostItem),
endpoint=self._create_endpoint(self.client.handle_create_item, PostItem),
)

def register_update_item(self):
Expand All @@ -104,7 +104,7 @@ def register_update_item(self):
response_model_exclude_unset=True,
response_model_exclude_none=True,
methods=["PUT"],
endpoint=self._create_endpoint(self.client.update_item, PutItem),
endpoint=self._create_endpoint(self.client.handle_update_item, PutItem),
)

def register_delete_item(self):
Expand All @@ -117,7 +117,7 @@ def register_delete_item(self):
response_model_exclude_unset=True,
response_model_exclude_none=True,
methods=["DELETE"],
endpoint=self._create_endpoint(self.client.delete_item, ItemUri),
endpoint=self._create_endpoint(self.client.handle_delete_item, ItemUri),
)

def register_create_collection(self):
Expand All @@ -131,7 +131,7 @@ def register_create_collection(self):
response_model_exclude_none=True,
methods=["POST"],
endpoint=self._create_endpoint(
self.client.create_collection, stac_types.Collection
self.client.handle_create_collection, stac_types.Collection
),
)

Expand All @@ -146,7 +146,7 @@ def register_update_collection(self):
response_model_exclude_none=True,
methods=["PUT"],
endpoint=self._create_endpoint(
self.client.update_collection, stac_types.Collection
self.client.handle_update_collection, stac_types.Collection
),
)

Expand All @@ -161,7 +161,7 @@ def register_delete_collection(self):
response_model_exclude_none=True,
methods=["DELETE"],
endpoint=self._create_endpoint(
self.client.delete_collection, CollectionUri
self.client.handle_delete_collection, CollectionUri
),
)

Expand Down
6 changes: 3 additions & 3 deletions stac_fastapi/extensions/third_party/bulk_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _chunks(lst, n):
yield lst[i : i + n]

@abc.abstractmethod
def bulk_item_insert(
def handle_bulk_item_insert(
self, items: Items, chunk_size: Optional[int] = None, **kwargs
) -> str:
"""Bulk creation of items.
Expand All @@ -57,7 +57,7 @@ class AsyncBaseBulkTransactionsClient(abc.ABC):
"""BulkTransactionsClient."""

@abc.abstractmethod
async def bulk_item_insert(self, items: Items, **kwargs) -> str:
async def handle_bulk_item_insert(self, items: Items, **kwargs) -> str:
"""Bulk creation of items.

Args:
Expand Down Expand Up @@ -125,7 +125,7 @@ def register(self, app: FastAPI) -> None:
response_model_exclude_none=True,
methods=["POST"],
endpoint=self._create_endpoint(
self.client.bulk_item_insert, items_request_model
self.client.handle_bulk_item_insert, items_request_model
),
)
app.include_router(router, tags=["Bulk Transaction Extension"])
Loading