seanpedrickcase commited on
Commit
7aa4d5f
·
1 Parent(s): f8700a5

Updated default AWS_FUNCTION value. Logs seconds values from outputs correctly.

Browse files
Files changed (2) hide show
  1. tools/aws_functions.py +1 -1
  2. tools/file_redaction.py +14 -11
tools/aws_functions.py CHANGED
@@ -10,7 +10,7 @@ PandasDataFrame = Type[pd.DataFrame]
10
  # Get AWS credentials if required
11
  bucket_name=""
12
  aws_var = "RUN_AWS_FUNCTIONS"
13
- aws_var_default = "1"
14
  aws_var_val = get_or_create_env_var(aws_var, aws_var_default)
15
  print(f'The value of {aws_var} is {aws_var_val}')
16
 
 
10
  # Get AWS credentials if required
11
  bucket_name=""
12
  aws_var = "RUN_AWS_FUNCTIONS"
13
+ aws_var_default = "0"
14
  aws_var_val = get_or_create_env_var(aws_var, aws_var_default)
15
  print(f'The value of {aws_var} is {aws_var_val}')
16
 
tools/file_redaction.py CHANGED
@@ -46,25 +46,28 @@ def choose_and_run_redactor(file_paths:List[str], image_paths:List[str], languag
46
  final_out_message = '\n'.join(out_message)
47
  #final_out_message = final_out_message + "\n\nGo to to the Redaction settings tab to see redaction logs. Please give feedback on the results below to help improve this app."
48
 
49
- def sum_numbers_from_string(string):
50
- """Extracts all numbers from a string and adds them up, including numbers with decimals.
51
 
52
  Args:
53
  string: The input string.
54
 
55
- Returns:s
56
- The sum of all numbers extracted from the string.
57
  """
58
 
59
- # Extract all numbers using regular expression, allowing for decimals
60
- numbers = re.findall(r'\d+(\.\d+)?', string)
61
 
62
- # Convert the numbers to floats and sum them up
63
- sum_of_numbers = sum(float(num) for num in numbers)
 
 
 
64
 
65
  return sum_of_numbers
66
 
67
- estimate_total_processing_time = sum_numbers_from_string(final_out_message)
68
  print("Estimated total processing time:", str(estimate_total_processing_time))
69
 
70
  return final_out_message, out_file_paths, out_file_paths, latest_file_completed, log_files_output_paths, log_files_output_paths, estimate_total_processing_time
@@ -150,8 +153,8 @@ def choose_and_run_redactor(file_paths:List[str], image_paths:List[str], languag
150
 
151
  if latest_file_completed != len(file_paths):
152
  print("Completed file number:", str(latest_file_completed), "more files to do")
153
- latest_file_completed += 1
154
-
155
  else:
156
  out_message = "No redaction method selected"
157
  print(out_message)
 
46
  final_out_message = '\n'.join(out_message)
47
  #final_out_message = final_out_message + "\n\nGo to to the Redaction settings tab to see redaction logs. Please give feedback on the results below to help improve this app."
48
 
49
+ def sum_numbers_before_seconds(string):
50
+ """Extracts numbers that precede the word 'seconds' from a string and adds them up.
51
 
52
  Args:
53
  string: The input string.
54
 
55
+ Returns:
56
+ The sum of all numbers before 'seconds' in the string.
57
  """
58
 
59
+ # Extract numbers before 'seconds' using regular expression
60
+ numbers = re.findall(r'\d+(\.\d+)?\s*seconds', string)
61
 
62
+ # Extract the numbers from the matches
63
+ numbers = [float(num.split()[0]) for num in numbers]
64
+
65
+ # Sum up the extracted numbers
66
+ sum_of_numbers = sum(numbers)
67
 
68
  return sum_of_numbers
69
 
70
+ estimate_total_processing_time = sum_numbers_before_seconds(final_out_message)
71
  print("Estimated total processing time:", str(estimate_total_processing_time))
72
 
73
  return final_out_message, out_file_paths, out_file_paths, latest_file_completed, log_files_output_paths, log_files_output_paths, estimate_total_processing_time
 
153
 
154
  if latest_file_completed != len(file_paths):
155
  print("Completed file number:", str(latest_file_completed), "more files to do")
156
+ latest_file_completed += 1
157
+
158
  else:
159
  out_message = "No redaction method selected"
160
  print(out_message)