seanpedrickcase commited on
Commit
c978ec5
·
1 Parent(s): f8f34c2

Allowed for server port, queue size, and file size to be specified by environment variables

Browse files
Files changed (2) hide show
  1. app.py +12 -3
  2. tools/auth.py +2 -2
app.py CHANGED
@@ -249,12 +249,21 @@ with app:
249
 
250
  in_view_table.upload(view_table, inputs=[in_view_table], outputs=[view_table_markdown])
251
 
252
- # Launch the Gradio app
253
  COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '0')
254
  print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
255
 
 
 
 
 
 
 
 
 
 
256
  if __name__ == "__main__":
257
  if os.environ['COGNITO_AUTH'] == "1":
258
- app.queue().launch(show_error=True, auth=authenticate_user, max_file_size='50mb')
259
  else:
260
- app.queue().launch(show_error=True, inbrowser=True, max_file_size='50mb')
 
249
 
250
  in_view_table.upload(view_table, inputs=[in_view_table], outputs=[view_table_markdown])
251
 
252
+ # Get some environment variables and Launch the Gradio app
253
  COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '0')
254
  print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
255
 
256
+ MAX_QUEUE_SIZE = int(get_or_create_env_var('MAX_QUEUE_SIZE', '5'))
257
+ print(f'The value of RUN_DIRECT_MODE is {MAX_QUEUE_SIZE}')
258
+
259
+ MAX_FILE_SIZE = get_or_create_env_var('MAX_FILE_SIZE', '100mb')
260
+ print(f'The value of MAX_FILE_SIZE is {MAX_FILE_SIZE}')
261
+
262
+ GRADIO_SERVER_PORT = int(get_or_create_env_var('GRADIO_SERVER_PORT', '7860'))
263
+ print(f'The value of GRADIO_SERVER_PORT is {GRADIO_SERVER_PORT}')
264
+
265
  if __name__ == "__main__":
266
  if os.environ['COGNITO_AUTH'] == "1":
267
+ 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)
268
  else:
269
+ app.queue(max_size=MAX_QUEUE_SIZE).launch(show_error=True, inbrowser=True, max_file_size=MAX_FILE_SIZE, server_port=GRADIO_SERVER_PORT)
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', 'l762du1rg94e1r2q0ii7ls0ef') # 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', 'eu-west-2_8fCzl8qej')
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', '')
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):