hysts HF staff commited on
Commit
7faab03
1 Parent(s): 32fd025
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -11,16 +11,17 @@ from huggingface_hub import HfApi
11
 
12
  from demo_list import DemoList
13
 
14
- INTERVAL_MIN = int(os.getenv('INTERVAL_MIN', '10'))
15
-
16
  demo_list = DemoList()
17
 
18
  api = HfApi()
19
- scheduler = BackgroundScheduler()
20
- scheduler.add_job(func=lambda: api.restart_space(os.getenv('SPACE_ID')),
21
- trigger='interval',
22
- seconds=60 * INTERVAL_MIN)
23
- scheduler.start()
 
 
 
24
 
25
  STATUS_CHOICES = [
26
  'RUNNING',
@@ -45,7 +46,6 @@ SDK_CHOICES = [
45
  'streamlit',
46
  'docker',
47
  ]
48
- WHOAMI = api.whoami()['name']
49
  OWNER_CHOICES = [WHOAMI, 'other organizations']
50
 
51
 
 
11
 
12
  from demo_list import DemoList
13
 
 
 
14
  demo_list = DemoList()
15
 
16
  api = HfApi()
17
+ WHOAMI = api.whoami()['name']
18
+ if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
19
+ INTERVAL_MIN = int(os.getenv('INTERVAL_MIN', '10'))
20
+ scheduler = BackgroundScheduler()
21
+ scheduler.add_job(func=lambda: api.restart_space(SPACE_ID),
22
+ trigger='interval',
23
+ seconds=60 * INTERVAL_MIN)
24
+ scheduler.start()
25
 
26
  STATUS_CHOICES = [
27
  'RUNNING',
 
46
  'streamlit',
47
  'docker',
48
  ]
 
49
  OWNER_CHOICES = [WHOAMI, 'other organizations']
50
 
51