seanpedrickcase commited on
Commit
043d5fc
β€’
1 Parent(s): aaca445

Gradio update. Remove queue when running on AWS Lambda

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +10 -6
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🌍
4
  colorFrom: purple
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 4.32.2
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
4
  colorFrom: purple
5
  colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 4.33.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py CHANGED
@@ -23,8 +23,6 @@ today_rev = datetime.now().strftime("%Y%m%d")
23
  base_folder = Path(os.getcwd())
24
  # output_folder = "output/" # This is now defined in constants
25
 
26
-
27
-
28
  ensure_output_folder_exists(output_folder)
29
 
30
  # Create the gradio interface
@@ -102,11 +100,17 @@ with block:
102
  match_btn.click(fn = run_matcher, inputs=[in_text, in_file, in_ref, data_state, results_data_state, ref_data_state, in_colnames, in_refcol, in_joincol, in_existing, in_api, in_api_key],
103
  outputs=[output_summary, output_file], api_name="address")
104
 
105
- # Simple run for HF spaces or local on your computer
106
- #block.queue().launch(debug=True) # root_path="/address-match", debug=True, server_name="0.0.0.0",
107
 
108
- # Simple run for AWS server
109
- block.queue().launch(ssl_verify=False) # root_path="/address-match", debug=True, server_name="0.0.0.0", server_port=7861
 
 
 
 
 
 
 
 
110
 
111
  # Download OpenSSL from here:
112
  # Running on local server with https: https://discuss.huggingface.co/t/how-to-run-gradio-with-0-0-0-0-and-https/38003 or https://dev.to/rajshirolkar/fastapi-over-https-for-development-on-windows-2p7d
 
23
  base_folder = Path(os.getcwd())
24
  # output_folder = "output/" # This is now defined in constants
25
 
 
 
26
  ensure_output_folder_exists(output_folder)
27
 
28
  # Create the gradio interface
 
100
  match_btn.click(fn = run_matcher, inputs=[in_text, in_file, in_ref, data_state, results_data_state, ref_data_state, in_colnames, in_refcol, in_joincol, in_existing, in_api, in_api_key],
101
  outputs=[output_summary, output_file], api_name="address")
102
 
 
 
103
 
104
+ # Run app
105
+ # If GRADIO_OUTPUT_FOLDER exists and is set to /tmp/ it means that the app is running on AWS Lambda and the queue should not be enabled.
106
+
107
+ if 'GRADIO_OUTPUT_FOLDER' in os.environ:
108
+ if os.environ['GRADIO_OUTPUT_FOLDER'] == '/tmp/':
109
+ block.launch(ssl_verify=False)
110
+ else:
111
+ block.queue().launch(ssl_verify=False)
112
+
113
+ block.queue().launch(ssl_verify=False)
114
 
115
  # Download OpenSSL from here:
116
  # Running on local server with https: https://discuss.huggingface.co/t/how-to-run-gradio-with-0-0-0-0-and-https/38003 or https://dev.to/rajshirolkar/fastapi-over-https-for-development-on-windows-2p7d
requirements.txt CHANGED
@@ -7,6 +7,6 @@ pyap==0.3.1
7
  pytest==7.4.3
8
  pyarrow==14.0.1
9
  openpyxl==3.1.2
10
- gradio==4.31.0
11
  boto3==1.34.103
12
  polars==0.20.19
 
7
  pytest==7.4.3
8
  pyarrow==14.0.1
9
  openpyxl==3.1.2
10
+ gradio==4.33.0
11
  boto3==1.34.103
12
  polars==0.20.19