-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.py
44 lines (34 loc) · 1.17 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from datetime import datetime, timedelta
import re
import getpass
# read ssh credentials from environment
key = os.environ.get('GPUMONITOR_KEY', None)
password = os.environ.get('GPUMONITOR_PASS', None)
user = os.environ.get('GPUMONITOR_USER', getpass.getuser())
if user is None:
raise ValueError('username for SSH is not set')
# interval to iterate through servers
update_interval = timedelta(seconds=30)
# file to write cache to
cache_file = 'cache.pkl'
# fill in your gpu servers here
servers = [
'gpuserver1',
'gpuserver2',
]
# process filter
process_filter = re.compile(r'.*')
def update_config(file_path):
global cache_file, process_filter, servers, update_interval
import json
with open(file_path, 'r') as f:
new_config = json.load(f)
if 'cache_file' in new_config.keys():
cache_file = new_config['cache_file']
if 'servers' in new_config.keys():
servers = new_config['servers']
if 'update_interval' in new_config.keys():
update_interval = timedelta(seconds=new_config['update_interval'])
if 'process_filter' in new_config.keys():
process_filter = re.compile(new_config['process_filter'])