fffiloni commited on
Commit
070c3b5
·
verified ·
1 Parent(s): b666497

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -36,12 +36,16 @@ def swap_hardware(hf_token, hardware="cpu-basic"):
36
  body = {'flavor': hardware}
37
  requests.post(hardware_url, json = body, headers=headers)
38
 
 
 
 
39
  def swap_sleep_time(hf_token,sleep_time):
40
  sleep_time_url = f"https://huggingface.co/api/spaces/{os.environ['SPACE_ID']}/sleeptime"
41
  headers = { "authorization" : f"Bearer {hf_token}"}
42
  body = {'seconds':sleep_time}
43
  requests.post(sleep_time_url,json=body,headers=headers)
44
 
 
45
  def get_sleep_time(hf_token):
46
  sleep_time_url = f"https://huggingface.co/api/spaces/{os.environ['SPACE_ID']}"
47
  headers = { "authorization" : f"Bearer {hf_token}"}
@@ -50,7 +54,7 @@ def get_sleep_time(hf_token):
50
  gcTimeout = response.json()['runtime']['gcTimeout']
51
  except:
52
  gcTimeout = None
53
- global sleep_time = gcTimeout
54
  return gcTimeout
55
 
56
  #sleep_time = get_sleep_time(hf_token)
 
36
  body = {'flavor': hardware}
37
  requests.post(hardware_url, json = body, headers=headers)
38
 
39
+
40
+ global sleep_time
41
+
42
  def swap_sleep_time(hf_token,sleep_time):
43
  sleep_time_url = f"https://huggingface.co/api/spaces/{os.environ['SPACE_ID']}/sleeptime"
44
  headers = { "authorization" : f"Bearer {hf_token}"}
45
  body = {'seconds':sleep_time}
46
  requests.post(sleep_time_url,json=body,headers=headers)
47
 
48
+
49
  def get_sleep_time(hf_token):
50
  sleep_time_url = f"https://huggingface.co/api/spaces/{os.environ['SPACE_ID']}"
51
  headers = { "authorization" : f"Bearer {hf_token}"}
 
54
  gcTimeout = response.json()['runtime']['gcTimeout']
55
  except:
56
  gcTimeout = None
57
+ sleep_time = gcTimeout
58
  return gcTimeout
59
 
60
  #sleep_time = get_sleep_time(hf_token)