Commit
·
2e71433
1
Parent(s):
04d80a1
logs should only be updated once per file run now
Browse files- app.py +1 -1
- tools/file_redaction.py +7 -3
app.py
CHANGED
@@ -353,7 +353,7 @@ with app:
|
|
353 |
# Log processing time/token usage when making a query
|
354 |
usage_callback = gr.CSVLogger(dataset_file_name=log_file_name)
|
355 |
usage_callback.setup([session_hash_textbox, doc_file_name_textbox, data_file_name_textbox, estimated_time_taken_number, textract_metadata_textbox, pii_identification_method_drop, comprehend_query_number], usage_logs_folder)
|
356 |
-
|
357 |
then(fn = upload_file_to_s3, inputs=[usage_logs_state, usage_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
|
358 |
|
359 |
# Launch the Gradio app
|
|
|
353 |
# Log processing time/token usage when making a query
|
354 |
usage_callback = gr.CSVLogger(dataset_file_name=log_file_name)
|
355 |
usage_callback.setup([session_hash_textbox, doc_file_name_textbox, data_file_name_textbox, estimated_time_taken_number, textract_metadata_textbox, pii_identification_method_drop, comprehend_query_number], usage_logs_folder)
|
356 |
+
latest_file_completed_text.change(lambda *args: usage_callback.flag(list(args)), [session_hash_textbox, doc_file_name_textbox, data_file_name_textbox, estimated_time_taken_number, textract_metadata_textbox, pii_identification_method_drop, comprehend_query_number], None, preprocess=False).\
|
357 |
then(fn = upload_file_to_s3, inputs=[usage_logs_state, usage_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
|
358 |
|
359 |
# Launch the Gradio app
|
tools/file_redaction.py
CHANGED
@@ -41,7 +41,7 @@ from tools.presidio_analyzer_custom import recognizer_result_from_dict
|
|
41 |
page_break_value = get_or_create_env_var('page_break_value', '500')
|
42 |
print(f'The value of page_break_value is {page_break_value}')
|
43 |
|
44 |
-
max_time_value = get_or_create_env_var('max_time_value', '
|
45 |
print(f'The value of max_time_value is {max_time_value}')
|
46 |
|
47 |
|
@@ -160,9 +160,9 @@ def choose_and_run_redactor(file_paths:List[str],
|
|
160 |
# If we have already redacted the last file, return the input out_message and file list to the relevant components
|
161 |
if latest_file_completed >= number_of_files:
|
162 |
|
163 |
-
print("
|
164 |
# Set to a very high number so as not to mix up with subsequent file processing by the user
|
165 |
-
latest_file_completed = 99
|
166 |
current_loop_page = 0
|
167 |
|
168 |
if isinstance(out_message, list):
|
@@ -383,6 +383,10 @@ def choose_and_run_redactor(file_paths:List[str],
|
|
383 |
|
384 |
# if isinstance(out_message, list):
|
385 |
# out_message.append(out_message_new) # Ensure out_message is a list of strings
|
|
|
|
|
|
|
|
|
386 |
|
387 |
|
388 |
# If textract requests made, write to logging file
|
|
|
41 |
page_break_value = get_or_create_env_var('page_break_value', '500')
|
42 |
print(f'The value of page_break_value is {page_break_value}')
|
43 |
|
44 |
+
max_time_value = get_or_create_env_var('max_time_value', '30')
|
45 |
print(f'The value of max_time_value is {max_time_value}')
|
46 |
|
47 |
|
|
|
160 |
# If we have already redacted the last file, return the input out_message and file list to the relevant components
|
161 |
if latest_file_completed >= number_of_files:
|
162 |
|
163 |
+
print("Completed last file")
|
164 |
# Set to a very high number so as not to mix up with subsequent file processing by the user
|
165 |
+
# latest_file_completed = 99
|
166 |
current_loop_page = 0
|
167 |
|
168 |
if isinstance(out_message, list):
|
|
|
383 |
|
384 |
# if isinstance(out_message, list):
|
385 |
# out_message.append(out_message_new) # Ensure out_message is a list of strings
|
386 |
+
else:
|
387 |
+
toc = time.perf_counter()
|
388 |
+
time_taken = toc - tic
|
389 |
+
estimated_time_taken_state = estimated_time_taken_state + time_taken
|
390 |
|
391 |
|
392 |
# If textract requests made, write to logging file
|