3232from schema import schema_triggers
3333from schema import schema_validators
3434from schema import schema_neo4j_queries
35- from schema .schema_constants import SchemaConstants
35+ from schema .schema_constants import SchemaConstants , ReindexPriorityLevelEnum
3636from schema .schema_constants import DataVisibilityEnum
3737from schema .schema_constants import MetadataScopeEnum
3838from schema .schema_constants import TriggerTypeEnum
@@ -1185,9 +1185,12 @@ def create_entity(entity_type):
11851185
11861186 # Check URL parameters before proceeding to any CRUD operations, halting on validation failures.
11871187 #
1188- # Check if re-indexing is to be suppressed after entity creation.
11891188 try :
1190- supress_reindex = schema_manager .suppress_reindex (request .args )
1189+ # Check if re-indexing is to be suppressed after entity creation.
1190+ suppress_reindex = schema_manager .suppress_reindex (request_args = request .args )
1191+ # Determine valid re-indexing priority using Request parameters.
1192+ reindex_priority = schema_manager .get_reindex_priority (request_args = request .args
1193+ , calc_suppress_reindex = suppress_reindex )
11911194 except Exception as e :
11921195 bad_request_error (e )
11931196
@@ -1312,7 +1315,7 @@ def create_entity(entity_type):
13121315 # Will also filter the result based on schema
13131316 normalized_complete_dict = schema_manager .normalize_entity_result_for_response (complete_dict )
13141317
1315- if supress_reindex :
1318+ if suppress_reindex :
13161319 logger .log (level = logging .INFO
13171320 , msg = f"Re-indexing suppressed during creation of { complete_dict ['entity_type' ]} "
13181321 f" with UUID { complete_dict ['uuid' ]} " )
@@ -1321,7 +1324,9 @@ def create_entity(entity_type):
13211324 logger .log (level = logging .INFO
13221325 , msg = f"Re-indexing for creation of { complete_dict ['entity_type' ]} "
13231326 f" with UUID { complete_dict ['uuid' ]} " )
1324- reindex_entity (complete_dict ['uuid' ], user_token )
1327+ reindex_entity (uuid = complete_dict ['uuid' ]
1328+ , user_token = user_token
1329+ , priority_level = reindex_priority )
13251330
13261331 return jsonify (normalized_complete_dict )
13271332
@@ -1494,9 +1499,12 @@ def update_entity(id):
14941499
14951500 # Check URL parameters before proceeding to any CRUD operations, halting on validation failures.
14961501 #
1497- # Check if re-indexing is to be suppressed after entity creation.
14981502 try :
1499- suppress_reindex = schema_manager .suppress_reindex (request .args )
1503+ # Check if re-indexing is to be suppressed after entity creation.
1504+ suppress_reindex = schema_manager .suppress_reindex (request_args = request .args )
1505+ # Determine valid re-indexing priority using Request parameters.
1506+ reindex_priority = schema_manager .get_reindex_priority (request_args = request .args
1507+ , calc_suppress_reindex = suppress_reindex )
15001508 except Exception as e :
15011509 bad_request_error (e )
15021510
@@ -1594,7 +1602,9 @@ def update_entity(id):
15941602 logger .log (level = logging .INFO
15951603 , msg = f"Re-indexing for modification of { normalized_entity_type } "
15961604 f" with UUID { entity_uuid } " )
1597- reindex_entity (entity_uuid , user_token )
1605+ reindex_entity (uuid = entity_uuid
1606+ , user_token = user_token
1607+ , priority_level = reindex_priority )
15981608
15991609 # Do not return the updated dict to avoid computing overhead - 7/14/2023 by Zhou
16001610 message_returned = f"The update request on { normalized_entity_type } of { id } has been accepted, the backend may still be processing"
@@ -4167,9 +4177,12 @@ def multiple_components():
41674177
41684178 # Check URL parameters before proceeding to any CRUD operations, halting on validation failures.
41694179 #
4170- # Check if re-indexing is to be suppressed after entity creation.
41714180 try :
4172- suppress_reindex = schema_manager .suppress_reindex (request .args )
4181+ # Check if re-indexing is to be suppressed after entity creation.
4182+ suppress_reindex = schema_manager .suppress_reindex (request_args = request .args )
4183+ # Determine valid re-indexing priority using Request parameters.
4184+ reindex_priority = schema_manager .get_reindex_priority (request_args = request .args
4185+ , calc_suppress_reindex = suppress_reindex )
41734186 except Exception as e :
41744187 bad_request_error (e )
41754188
@@ -4215,7 +4228,9 @@ def multiple_components():
42154228 logger .log (level = logging .INFO
42164229 , msg = f"Re-indexing for multiple component creation of { complete_dict ['entity_type' ]} "
42174230 f" with UUID { complete_dict ['uuid' ]} " )
4218- reindex_entity (complete_dict ['uuid' ], user_token )
4231+ reindex_entity (uuid = complete_dict ['uuid' ]
4232+ , user_token = user_token
4233+ , priority_level = reindex_priority )
42194234 # Add back in dataset_link_abs_dir one last time
42204235 normalized_complete_dict ['dataset_link_abs_dir' ] = dataset_link_abs_dir
42214236 normalized_complete_entity_list .append (normalized_complete_dict )
@@ -5426,19 +5441,23 @@ def delete_cache(entity_uuid, entity_type):
54265441
54275442Parameters
54285443----------
5429- uuid : str
5444+ uuid :
54305445 The uuid of the target entity
5431- user_token: str
5446+ user_token:
54325447 The user's globus groups token
5448+ priority_level:
5449+ Value from the enumeration ReindexPriorityLevelEnum
54335450"""
5434- def reindex_entity (uuid , user_token ) :
5451+ def reindex_entity (uuid : str , user_token : str , priority_level : int = ReindexPriorityLevelEnum . HIGH . value ) -> None :
54355452 headers = {
54365453 'Authorization' : f'Bearer { user_token } '
54375454 }
54385455
54395456 logger .info (f"Making a call to search-api to reindex uuid: { uuid } " )
54405457
5441- response = requests .put (f"{ app .config ['SEARCH_API_URL' ]} /reindex/{ uuid } " , headers = headers )
5458+ response = requests .put (f"{ app .config ['SEARCH_API_URL' ]} /reindex/{ uuid } "
5459+ , headers = headers
5460+ , params = {'priority' : priority_level })
54425461
54435462 # The reindex takes time, so 202 Accepted response status code indicates that
54445463 # the request has been accepted for processing, but the processing has not been completed
0 commit comments