Skip to content

Commit 0d68298

Browse files
committed
update docstrings
1 parent bf6470d commit 0d68298

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

stac_fastapi/core/stac_fastapi/core/utilities.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def resolve_refresh(refresh: str) -> str:
4848
4949
Returns:
5050
str: The resolved value of the `refresh` parameter, which can be "true", "false", or "wait_for".
51+
52+
Raises:
53+
ValueError: If the `refresh` value is not one of "true", "false", or "wait_for".
5154
"""
5255
logger = logging.getLogger(__name__)
5356

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ async def create_item(
855855
item (Item): The item to be created.
856856
base_url (str, optional): The base URL for the item. Defaults to an empty string.
857857
exist_ok (bool, optional): Whether to allow the item to exist already. Defaults to False.
858-
refresh (bool, optional): Refresh the index after performing the operation. Defaults to False.
858+
**kwargs: Additional keyword arguments.
859+
- refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
860+
- refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
859861
860862
Raises:
861863
ConflictError: If the item already exists in the database.
@@ -898,10 +900,15 @@ async def delete_item(self, item_id: str, collection_id: str, **kwargs: Any):
898900
Args:
899901
item_id (str): The id of the Item to be deleted.
900902
collection_id (str): The id of the Collection that the Item belongs to.
901-
refresh (bool, optional): Whether to refresh the index after the deletion. Default is False.
903+
**kwargs: Additional keyword arguments.
904+
- refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
905+
- refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
902906
903907
Raises:
904908
NotFoundError: If the Item does not exist in the database.
909+
910+
Returns:
911+
None
905912
"""
906913
# Ensure kwargs is a dictionary
907914
kwargs = kwargs or {}
@@ -951,11 +958,16 @@ async def create_collection(self, collection: Collection, **kwargs: Any):
951958
952959
Args:
953960
collection (Collection): The Collection object to be created.
954-
refresh (str, optional): Whether to refresh the index after the creation. Can be "true", "false", or "wait_for".
961+
**kwargs: Additional keyword arguments.
962+
- refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
963+
- refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
955964
956965
Raises:
957966
ConflictError: If a Collection with the same id already exists in the database.
958967
968+
Returns:
969+
None
970+
959971
Notes:
960972
A new index is created for the items in the Collection using the `create_item_index` function.
961973
"""
@@ -1020,7 +1032,11 @@ async def update_collection(
10201032
Args:
10211033
collection_id (str): The ID of the collection to be updated.
10221034
collection (Collection): The Collection object to be used for the update.
1023-
kwargs (Any, optional): Additional keyword arguments, including `refresh`.
1035+
**kwargs: Additional keyword arguments.
1036+
- refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
1037+
- refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
1038+
Returns:
1039+
None
10241040
10251041
Raises:
10261042
NotFoundError: If the collection with the given `collection_id` is not found in the database.
@@ -1086,10 +1102,15 @@ async def delete_collection(self, collection_id: str, **kwargs: Any):
10861102
Parameters:
10871103
collection_id (str): The ID of the collection to be deleted.
10881104
kwargs (Any, optional): Additional keyword arguments, including `refresh`.
1105+
- refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
1106+
- refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
10891107
10901108
Raises:
10911109
NotFoundError: If the collection with the given `collection_id` is not found in the database.
10921110
1111+
Returns:
1112+
None
1113+
10931114
Notes:
10941115
This function first verifies that the collection with the specified `collection_id` exists in the database, and then
10951116
deletes the collection. If `refresh` is set to "true", "false", or "wait_for", the index is refreshed accordingly after
@@ -1133,7 +1154,12 @@ async def bulk_async(
11331154
Args:
11341155
collection_id (str): The ID of the collection to which the items belong.
11351156
processed_items (List[Item]): A list of `Item` objects to be inserted into the database.
1136-
refresh (bool): Whether to refresh the index after the bulk insert (default: False).
1157+
**kwargs (Any): Additional keyword arguments, including:
1158+
- refresh (str, optional): Whether to refresh the index after the bulk insert.
1159+
Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1160+
- refresh (bool, optional): Whether to refresh the index after the bulk insert.
1161+
- raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1162+
Defaults to the value of `self.async_settings.raise_on_bulk_error`.
11371163
11381164
Returns:
11391165
Tuple[int, List[Dict[str, Any]]]: A tuple containing:
@@ -1142,9 +1168,12 @@ async def bulk_async(
11421168
11431169
Notes:
11441170
This function performs a bulk insert of `processed_items` into the database using the specified `collection_id`.
1145-
The insert is performed asynchronously, and the event loop is used to run the operation in a separate executor.
1146-
The `mk_actions` function is called to generate a list of actions for the bulk insert. If `refresh` is set to True,
1147-
the index is refreshed after the bulk insert.
1171+
The insert is performed synchronously and blocking, meaning that the function does not return until the insert has
1172+
completed. The `mk_actions` function is called to generate a list of actions for the bulk insert. The `refresh`
1173+
parameter determines whether the index is refreshed after the bulk insert:
1174+
- "true": Forces an immediate refresh of the index.
1175+
- "false": Does not refresh the index immediately (default behavior).
1176+
- "wait_for": Waits for the next refresh cycle to make the changes visible.
11481177
"""
11491178
# Ensure kwargs is a dictionary
11501179
kwargs = kwargs or {}
@@ -1194,6 +1223,9 @@ def bulk_sync(
11941223
**kwargs (Any): Additional keyword arguments, including:
11951224
- refresh (str, optional): Whether to refresh the index after the bulk insert.
11961225
Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1226+
- refresh (bool, optional): Whether to refresh the index after the bulk insert.
1227+
- raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1228+
Defaults to the value of `self.async_settings.raise_on_bulk_error`.
11971229
11981230
Returns:
11991231
Tuple[int, List[Dict[str, Any]]]: A tuple containing:

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,9 @@ async def bulk_async(
11321132
**kwargs (Any): Additional keyword arguments, including:
11331133
- refresh (str, optional): Whether to refresh the index after the bulk insert.
11341134
Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1135+
- refresh (bool, optional): Whether to refresh the index after the bulk insert.
1136+
- raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1137+
Defaults to the value of `self.async_settings.raise_on_bulk_error`.
11351138
11361139
Returns:
11371140
Tuple[int, List[Dict[str, Any]]]: A tuple containing:
@@ -1184,14 +1187,17 @@ def bulk_sync(
11841187
**kwargs: Any,
11851188
) -> Tuple[int, List[Dict[str, Any]]]:
11861189
"""
1187-
Perform a bulk insert of items into the database synchronously.
1190+
Perform a bulk insert of items into the database asynchronously.
11881191
11891192
Args:
11901193
collection_id (str): The ID of the collection to which the items belong.
11911194
processed_items (List[Item]): A list of `Item` objects to be inserted into the database.
11921195
**kwargs (Any): Additional keyword arguments, including:
11931196
- refresh (str, optional): Whether to refresh the index after the bulk insert.
11941197
Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1198+
- refresh (bool, optional): Whether to refresh the index after the bulk insert.
1199+
- raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1200+
Defaults to the value of `self.async_settings.raise_on_bulk_error`.
11951201
11961202
Returns:
11971203
Tuple[int, List[Dict[str, Any]]]: A tuple containing:

0 commit comments

Comments
 (0)