crabbly commited on
Commit
8aa0d3e
·
1 Parent(s): bffefa0

Fix scheduling

Browse files
Files changed (1) hide show
  1. main.py +7 -3
main.py CHANGED
@@ -23,6 +23,7 @@ DEV_URL = "https://PPAL-SongLab-UGA-fruit-analyzer-dev.hf.space"
23
  PROD_URL = "https://PPAL-SongLab-UGA-fruit-analyzer.hf.space"
24
  HF_RATE_LIMIT_STATUS = 429
25
  HF_TRANSIENT_STATUS = {429, 502, 503, 504}
 
26
 
27
 
28
  def request_with_hf_backoff(method, url, *, max_retries=3, **kwargs):
@@ -121,10 +122,11 @@ async def proxy_process(request: Request, file: UploadFile = File(...), password
121
  return request_with_hf_backoff(
122
  requests.post,
123
  target_url,
 
124
  headers=headers,
125
  files=files,
126
  data=data,
127
- timeout=120,
128
  )
129
 
130
  try:
@@ -159,10 +161,11 @@ async def proxy_compatibility(request: Request, password: str = Form(""), userna
159
  return request_with_hf_backoff(
160
  requests.post,
161
  target_url,
 
162
  headers=headers,
163
  files=files,
164
  data=data,
165
- timeout=120,
166
  )
167
 
168
  try:
@@ -186,9 +189,10 @@ async def proxy_batch_stage(payload: dict = Body(...)):
186
  return request_with_hf_backoff(
187
  requests.post,
188
  target_url,
 
189
  headers=headers,
190
  json=payload,
191
- timeout=120,
192
  )
193
 
194
  try:
 
23
  PROD_URL = "https://PPAL-SongLab-UGA-fruit-analyzer.hf.space"
24
  HF_RATE_LIMIT_STATUS = 429
25
  HF_TRANSIENT_STATUS = {429, 502, 503, 504}
26
+ PROCESS_PROXY_TIMEOUT_SECONDS = 40
27
 
28
 
29
  def request_with_hf_backoff(method, url, *, max_retries=3, **kwargs):
 
122
  return request_with_hf_backoff(
123
  requests.post,
124
  target_url,
125
+ max_retries=0,
126
  headers=headers,
127
  files=files,
128
  data=data,
129
+ timeout=PROCESS_PROXY_TIMEOUT_SECONDS,
130
  )
131
 
132
  try:
 
161
  return request_with_hf_backoff(
162
  requests.post,
163
  target_url,
164
+ max_retries=0,
165
  headers=headers,
166
  files=files,
167
  data=data,
168
+ timeout=PROCESS_PROXY_TIMEOUT_SECONDS,
169
  )
170
 
171
  try:
 
189
  return request_with_hf_backoff(
190
  requests.post,
191
  target_url,
192
+ max_retries=0,
193
  headers=headers,
194
  json=payload,
195
+ timeout=PROCESS_PROXY_TIMEOUT_SECONDS,
196
  )
197
 
198
  try: