@@ -63,14 +63,13 @@ def main(ctx: click.Context, url: str, *, verbose: bool) -> None:
6363 ctx .obj ["CLIENT" ] = tim_os .configure_opensearch_client (url )
6464 logger .info ("OpenSearch client configured for endpoint '%s'" , url )
6565
66+ def _log_command_elapsed_time () -> None :
67+ elapsed_time = perf_counter () - ctx .obj ["start_time" ]
68+ logger .info (
69+ "Total time to complete process: %s" , str (timedelta (seconds = elapsed_time ))
70+ )
6671
67- @main .result_callback ()
68- @click .pass_context
69- def log_process_time (ctx : click .Context , _result : object , ** _kwargs : dict ) -> None :
70- elapsed_time = perf_counter () - ctx .obj ["START_TIME" ]
71- logger .info (
72- "Total time to complete process: %s" , str (timedelta (seconds = elapsed_time ))
73- )
72+ ctx .call_on_close (_log_command_elapsed_time )
7473
7574
7675# Cluster commands
@@ -310,7 +309,7 @@ def bulk_update(
310309 try :
311310 index_results .update (tim_os .bulk_index (client , index , records_to_index ))
312311 except BulkIndexingError as exception :
313- logger .info (f"Bulk indexing failed: { exception } " )
312+ logger .error (f"Bulk indexing failed: { exception } " ) # noqa: TRY400
314313
315314 # bulk delete records
316315 records_to_delete = td .read_dicts_iter (
@@ -343,7 +342,7 @@ def bulk_update(
343342 "records with embeddings."
344343 ),
345344)
346- @click .option ("-rid" , "--run-id" , help = "Run ID." )
345+ @click .option ("-rid" , "--run-id" , required = True , help = "Run ID." )
347346@click .argument ("dataset_path" , type = click .Path ())
348347@click .pass_context
349348def bulk_update_embeddings (
@@ -391,7 +390,8 @@ def bulk_update_embeddings(
391390 try :
392391 update_results .update (tim_os .bulk_update (client , index , embeddings_to_index ))
393392 except BulkOperationError as exception :
394- logger .info (f"Bulk update with embeddings failed: { exception } " )
393+ logger .error (f"Bulk update with embeddings failed: { exception } " ) # noqa: TRY400
394+ ctx .exit (1 )
395395
396396 logger .info (f"Bulk update with embeddings complete: { json .dumps (update_results )} " )
397397
@@ -471,7 +471,3 @@ def reindex_source(
471471
472472 summary_results = {"index" : index_results }
473473 logger .info (f"Reindex source complete: { json .dumps (summary_results )} " )
474-
475-
476- if __name__ == "__main__" :
477- main ()
0 commit comments