Skip to content

Commit 5f6d7a3

Browse files
committed
sphinx spacing
1 parent 613743f commit 5f6d7a3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

nmdc_api_utilities/collection_helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def get_record_name_from_id(self, doc_id: str) -> str:
2929
-------
3030
str
3131
The collection name of the document.
32+
3233
Raises
3334
------
3435
RuntimeError
3536
If the API request fails.
37+
3638
"""
3739
url = f"{self.base_url}/nmdcschema/ids/{doc_id}/collection-name"
3840
try:

nmdc_api_utilities/collection_search.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def get_records(
2828
) -> list[dict]:
2929
"""
3030
Get a collection of data from the NMDC API. Generic function to get a collection of data from the NMDC API. Can provide a specific filter if desired.
31+
3132
Parameters
3233
----------
3334
filter: str
@@ -38,14 +39,17 @@ def get_records(
3839
The fields to return. Default is all fields.
3940
all_pages: bool
4041
True to return all pages. False to return the first page. Default is False.
42+
4143
Returns
4244
-------
4345
list[dict]
4446
A list of dictionaries containing the records.
47+
4548
Raises
4649
------
4750
RuntimeError
4851
If the API request fails.
52+
4953
"""
5054
logging.debug(f"get_records Filter: {filter}")
5155
filter = urllib.parse.quote(filter)
@@ -80,6 +84,7 @@ def _get_all_pages(
8084
):
8185
"""
8286
Get all pages of data from the NMDC API. This is a helper function to get all pages of data from the NMDC API.
87+
8388
Parameters
8489
----------
8590
response: requests.models.Response
@@ -90,14 +95,17 @@ def _get_all_pages(
9095
The maximum number of items to return per page. Default is 100.
9196
fields: str
9297
The fields to return. Default is all fields.
98+
9399
Returns
94100
-------
95101
list[dict]
96102
A list of dictionaries containing the records.
103+
97104
Raises
98105
------
99106
RuntimeError
100107
If the API request fails.
108+
101109
"""
102110

103111
results = response.json()
@@ -132,7 +140,6 @@ def get_record_by_filter(
132140
filter: str
133141
The filter to use to query the collection. Must be in MonogDB query format.
134142
Resources found here - https://www.mongodb.com/docs/manual/reference/method/db.collection.find/#std-label-method-find-query
135-
136143
Example: {"name":{"my record name"}}
137144
max_page_size: int
138145
The number of results to return per page. Default is 25.
@@ -205,6 +212,7 @@ def get_record_by_id(
205212
) -> list[dict]:
206213
"""
207214
Get a collection of data from the NMDC API by id.
215+
208216
Parameters
209217
----------
210218
collection_id: str
@@ -213,14 +221,17 @@ def get_record_by_id(
213221
The maximum number of items to return per page. Default is 100.
214222
fields: str
215223
The fields to return. Default is all fields.
224+
216225
Returns
217226
-------
218227
list[dict]
219228
A list of dictionaries containing the records.
229+
220230
Raises
221231
------
222232
RuntimeError
223233
If the API request fails.
234+
224235
"""
225236
url = f"{self.base_url}/nmdcschema/{self.collection_name}/{collection_id}?max_page_size={max_page_size}&projection={fields}"
226237
# get the reponse
@@ -253,10 +264,12 @@ def check_ids_exist(
253264
The number of IDs to check in each query. Default is 100.
254265
return_missing_ids : bool
255266
If True, and if ids are missing in the collection, return the list of IDs that do not exist in the collection. Default is False.
267+
256268
Returns
257269
-------
258270
bool
259271
True if all IDs exist in the collection, False otherwise.
272+
260273
"""
261274
# chunk the input list of IDs into smaller lists of 100 IDs each
262275
# to avoid the maximum URL length limit
@@ -284,6 +297,7 @@ def get_batch_records(
284297
"""
285298
Get a batch of records from the collection by a list of input IDs. This method is used to identify records that include any of the IDs from the input list, matching the search_field.
286299
This is using the MongoDB filter keyword $in to identify other records that include the input IDs.
300+
287301
Parameters
288302
---------
289303
id_list: list
@@ -294,10 +308,12 @@ def get_batch_records(
294308
The number of IDs to get in each query. Default is 100.
295309
fields: str
296310
The fields to return. Default is all fields.
311+
297312
Returns
298313
-------
299314
list[dict]
300315
A list of dictionaries containing the records.
316+
301317
"""
302318
dp = DataProcessing()
303319
results = []

0 commit comments

Comments
 (0)