seanpedrickcase
commited on
Commit
•
e1c402a
1
Parent(s):
7aa4d5f
Updated time sum function to sum correctly
Browse files- app.py +3 -3
- tools/auth.py +2 -2
- tools/file_redaction.py +2 -2
- tools/helper_functions.py +0 -3
app.py
CHANGED
@@ -178,9 +178,9 @@ with app:
|
|
178 |
app.load(get_connection_params, inputs=None, outputs=[session_hash_state, s3_output_folder_state, session_hash_textbox])
|
179 |
|
180 |
# Log usernames and times of access to file (to know who is using the app when running on AWS)
|
181 |
-
|
182 |
-
|
183 |
-
session_hash_textbox.change(lambda *args:
|
184 |
then(fn = upload_file_to_s3, inputs=[access_logs_state, access_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
|
185 |
|
186 |
# User submitted feedback for pdf redactions
|
|
|
178 |
app.load(get_connection_params, inputs=None, outputs=[session_hash_state, s3_output_folder_state, session_hash_textbox])
|
179 |
|
180 |
# Log usernames and times of access to file (to know who is using the app when running on AWS)
|
181 |
+
access_callback = gr.CSVLogger()
|
182 |
+
access_callback.setup([session_hash_textbox], access_logs_folder)
|
183 |
+
session_hash_textbox.change(lambda *args: access_callback.flag(list(args)), [session_hash_textbox], None, preprocess=False).\
|
184 |
then(fn = upload_file_to_s3, inputs=[access_logs_state, access_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
|
185 |
|
186 |
# User submitted feedback for pdf redactions
|
tools/auth.py
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
import boto3
|
3 |
from tools.helper_functions import get_or_create_env_var
|
4 |
|
5 |
-
client_id = get_or_create_env_var('AWS_CLIENT_ID', '
|
6 |
print(f'The value of AWS_CLIENT_ID is {client_id}')
|
7 |
|
8 |
-
user_pool_id = get_or_create_env_var('AWS_USER_POOL_ID', '
|
9 |
print(f'The value of AWS_USER_POOL_ID is {user_pool_id}')
|
10 |
|
11 |
def authenticate_user(username, password, user_pool_id=user_pool_id, client_id=client_id):
|
|
|
2 |
import boto3
|
3 |
from tools.helper_functions import get_or_create_env_var
|
4 |
|
5 |
+
client_id = get_or_create_env_var('AWS_CLIENT_ID', '') # This client id is borrowed from async gradio app client
|
6 |
print(f'The value of AWS_CLIENT_ID is {client_id}')
|
7 |
|
8 |
+
user_pool_id = get_or_create_env_var('AWS_USER_POOL_ID', '')
|
9 |
print(f'The value of AWS_USER_POOL_ID is {user_pool_id}')
|
10 |
|
11 |
def authenticate_user(username, password, user_pool_id=user_pool_id, client_id=client_id):
|
tools/file_redaction.py
CHANGED
@@ -57,13 +57,13 @@ def choose_and_run_redactor(file_paths:List[str], image_paths:List[str], languag
|
|
57 |
"""
|
58 |
|
59 |
# Extract numbers before 'seconds' using regular expression
|
60 |
-
numbers = re.findall(r'\d
|
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 |
|
|
|
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 = round(sum(numbers),1)
|
67 |
|
68 |
return sum_of_numbers
|
69 |
|
tools/helper_functions.py
CHANGED
@@ -153,9 +153,6 @@ def wipe_logs(feedback_logs_loc, usage_logs_loc):
|
|
153 |
except Exception as e:
|
154 |
print("Could not remove usage logs file", e)
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
async def get_connection_params(request: gr.Request):
|
160 |
base_folder = ""
|
161 |
|
|
|
153 |
except Exception as e:
|
154 |
print("Could not remove usage logs file", e)
|
155 |
|
|
|
|
|
|
|
156 |
async def get_connection_params(request: gr.Request):
|
157 |
base_folder = ""
|
158 |
|