seanpedrickcase commited on
Commit
dc17f6e
1 Parent(s): 7c7fd7c

Can now define queue size, max file size, and server port in environment variables

Browse files
Files changed (3) hide show
  1. Dockerfile +0 -2
  2. app.py +11 -5
  3. tools/aws_functions.py +0 -2
Dockerfile CHANGED
@@ -88,8 +88,6 @@ WORKDIR $HOME/app
88
  # Copy the app code to the container
89
  COPY --chown=user . $HOME/app
90
 
91
-
92
-
93
  ENTRYPOINT [ "/entrypoint.sh" ]
94
 
95
  # Default command for Lambda mode
 
88
  # Copy the app code to the container
89
  COPY --chown=user . $HOME/app
90
 
 
 
91
  ENTRYPOINT [ "/entrypoint.sh" ]
92
 
93
  # Default command for Lambda mode
app.py CHANGED
@@ -395,24 +395,30 @@ with app:
395
  latest_file_completed_text.change(lambda *args: usage_callback.flag(list(args)), [session_hash_textbox, doc_file_name_no_extension_textbox, data_file_name_textbox, estimated_time_taken_number, textract_metadata_textbox, pii_identification_method_drop, comprehend_query_number], None, preprocess=False).\
396
  then(fn = upload_file_to_s3, inputs=[usage_logs_state, usage_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
397
 
398
- # Launch the Gradio app
399
  COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '1')
400
  print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
401
 
402
  RUN_DIRECT_MODE = get_or_create_env_var('RUN_DIRECT_MODE', '0')
403
  print(f'The value of RUN_DIRECT_MODE is {RUN_DIRECT_MODE}')
404
 
405
- max_queue_size = 5
406
- max_file_size = '100mb'
 
 
 
 
 
 
407
 
408
  if __name__ == "__main__":
409
 
410
  if RUN_DIRECT_MODE == "0":
411
 
412
  if os.environ['COGNITO_AUTH'] == "1":
413
- app.queue(max_size=max_queue_size).launch(show_error=True, auth=authenticate_user, max_file_size=max_file_size, show_api=False)
414
  else:
415
- app.queue(max_size=max_queue_size).launch(show_error=True, inbrowser=True, max_file_size=max_file_size)
416
 
417
  else:
418
  from tools.cli_redact import main
 
395
  latest_file_completed_text.change(lambda *args: usage_callback.flag(list(args)), [session_hash_textbox, doc_file_name_no_extension_textbox, data_file_name_textbox, estimated_time_taken_number, textract_metadata_textbox, pii_identification_method_drop, comprehend_query_number], None, preprocess=False).\
396
  then(fn = upload_file_to_s3, inputs=[usage_logs_state, usage_s3_logs_loc_state], outputs=[s3_logs_output_textbox])
397
 
398
+ # Get some environment variables and Launch the Gradio app
399
  COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '1')
400
  print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
401
 
402
  RUN_DIRECT_MODE = get_or_create_env_var('RUN_DIRECT_MODE', '0')
403
  print(f'The value of RUN_DIRECT_MODE is {RUN_DIRECT_MODE}')
404
 
405
+ MAX_QUEUE_SIZE = int(get_or_create_env_var('MAX_QUEUE_SIZE', '5'))
406
+ print(f'The value of RUN_DIRECT_MODE is {MAX_QUEUE_SIZE}')
407
+
408
+ MAX_FILE_SIZE = get_or_create_env_var('MAX_FILE_SIZE', '100mb')
409
+ print(f'The value of MAX_FILE_SIZE is {MAX_FILE_SIZE}')
410
+
411
+ GRADIO_SERVER_PORT = int(get_or_create_env_var('GRADIO_SERVER_PORT', '7860'))
412
+ print(f'The value of GRADIO_SERVER_PORT is {GRADIO_SERVER_PORT}')
413
 
414
  if __name__ == "__main__":
415
 
416
  if RUN_DIRECT_MODE == "0":
417
 
418
  if os.environ['COGNITO_AUTH'] == "1":
419
+ app.queue(max_size=MAX_QUEUE_SIZE).launch(show_error=True, auth=authenticate_user, max_file_size=MAX_FILE_SIZE, server_port=GRADIO_SERVER_PORT)
420
  else:
421
+ app.queue(max_size=MAX_QUEUE_SIZE).launch(show_error=True, inbrowser=True, max_file_size=MAX_FILE_SIZE, server_port=GRADIO_SERVER_PORT)
422
 
423
  else:
424
  from tools.cli_redact import main
tools/aws_functions.py CHANGED
@@ -207,5 +207,3 @@ def upload_file_to_s3(local_file_paths:List[str], s3_key:str, s3_bucket:str=buck
207
  else: final_out_message_str = "Could not connect to AWS."
208
 
209
  return final_out_message_str
210
-
211
-
 
207
  else: final_out_message_str = "Could not connect to AWS."
208
 
209
  return final_out_message_str