Skip to content

Commit 5dfedd6

Browse files
authored
Merge pull request #1014 from hubmapconsortium/Derek-Furst/new-reindex-optimization
added error handling for when the ancestors-info or descendants-info …
2 parents d827f64 + f796b84 commit 5dfedd6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

‎src/app.py‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,24 @@ def get_entities_by_type(entity_type):
11141114
# Response with the final result
11151115
return jsonify(final_result)
11161116

1117+
1118+
"""
1119+
Retrieve the document info needed for a given entity's ancestors. Result filtering for this
1120+
endpoint is required and is given by the required parameter 'include'.
1121+
For example /ancestors-info?include=uuid,status,entity_type
1122+
1123+
1124+
Parameters
1125+
----------
1126+
include : str
1127+
A comma delimited string of all the properties to be retrieved by the endpoint
1128+
1129+
Returns
1130+
-------
1131+
json
1132+
A list of dicts where each dict contains the requested fields for the given ancestor.
1133+
"""
1134+
11171135
@app.route('/ancestors-info/<uuid>', methods=['GET'])
11181136
def get_ancestors_info(uuid):
11191137
validate_token_if_auth_header_exists(request)
@@ -1130,6 +1148,10 @@ def get_ancestors_info(uuid):
11301148
invalid = [f for f in include_fields if f not in valid_fields]
11311149
if invalid:
11321150
return bad_request_error(f"Invalid include fields: {invalid}")
1151+
else:
1152+
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
1153+
else:
1154+
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
11331155
result = app_neo4j_queries.get_ancestors_trimmed(neo4j_driver_instance, uuid, included_fields=include_fields)
11341156
if result is None:
11351157
return not_found_error(f"Entity {uuid} not found")
@@ -1139,6 +1161,22 @@ def get_ancestors_info(uuid):
11391161
return jsonify(ordered_response)
11401162

11411163

1164+
"""
1165+
Retrieve the document info needed for a given entity's descendant. Result filtering for this
1166+
endpoint is required and is given by the required parameter 'include'.
1167+
For example /descendants-info?include=uuid,status,entity_type
1168+
1169+
1170+
Parameters
1171+
----------
1172+
include : str
1173+
A comma delimited string of all the properties to be retrieved by the endpoint
1174+
1175+
Returns
1176+
-------
1177+
json
1178+
A list of dicts where each dict contains the requested fields for the given descendant.
1179+
"""
11421180
@app.route('/descendants-info/<uuid>', methods=['GET'])
11431181
def get_descendants_info(uuid):
11441182
validate_token_if_auth_header_exists(request)
@@ -1155,6 +1193,10 @@ def get_descendants_info(uuid):
11551193
invalid = [f for f in include_fields if f not in valid_fields]
11561194
if invalid:
11571195
return bad_request_error(f"Invalid include fields: {invalid}")
1196+
else:
1197+
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
1198+
else:
1199+
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
11581200
result = app_neo4j_queries.get_descendants_trimmed(neo4j_driver_instance, uuid, included_fields=include_fields)
11591201
if result is None:
11601202
return not_found_error(f"Entity {uuid} not found")
@@ -1163,6 +1205,23 @@ def get_descendants_info(uuid):
11631205
ordered_response = [alphabetize_dict_recursive(entity) for entity in complete]
11641206
return jsonify(ordered_response)
11651207

1208+
1209+
"""
1210+
Retrieve the document info needed for a given entity's parents (immediate ancestors). Result filtering for this
1211+
endpoint is allowed and is given by the required parameter 'include'.
1212+
For example /parents-info?include=uuid,status,entity_type
1213+
1214+
1215+
Parameters
1216+
----------
1217+
include : str
1218+
A comma delimited string of all the properties to be retrieved by the endpoint
1219+
1220+
Returns
1221+
-------
1222+
json
1223+
A list of dicts where each dict contains the requested fields for the given parent.
1224+
"""
11661225
@app.route('/parents-info/<uuid>', methods=['GET'])
11671226
def get_parents_info(uuid):
11681227
validate_token_if_auth_header_exists(request)
@@ -1188,6 +1247,22 @@ def get_parents_info(uuid):
11881247
return jsonify(ordered_response)
11891248

11901249

1250+
"""
1251+
Retrieve the document info needed for a given entity's children (immediate descendants). Result filtering for this
1252+
endpoint is allowed and is given by the required parameter 'include'.
1253+
For example /children-info?include=uuid,status,entity_type
1254+
1255+
1256+
Parameters
1257+
----------
1258+
include : str
1259+
A comma delimited string of all the properties to be retrieved by the endpoint
1260+
1261+
Returns
1262+
-------
1263+
json
1264+
A list of dicts where each dict contains the requested fields for the given child.
1265+
"""
11911266
@app.route('/children-info/<uuid>', methods=['GET'])
11921267
def get_children_info(uuid):
11931268
validate_token_if_auth_header_exists(request)

0 commit comments

Comments
 (0)