Spaces:
Sleeping
Sleeping
File size: 2,147 Bytes
c3ece9d edf61c6 |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import platform,socket,re,uuid,json,psutil,logging
from datetime import datetime as dt
from google_sheet import log_repo, conf_repo, SheetCRUDRepository
from version import VERSION
import pytz
def get_now():
current_time = dt.now(pytz.timezone('Asia/Ho_Chi_Minh'))
return current_time
def get_sys_info():
try:
info={}
info['platform']=platform.system()
info['platform-release']=platform.release()
info['platform-version']=platform.version()
info['architecture']=platform.machine()
info['hostname']=socket.gethostname()
info['ip-address']=socket.gethostbyname(socket.gethostname())
info['mac-address']=':'.join(re.findall('..', '%012x' % uuid.getnode()))
info['processor']=platform.processor()
info['ram']=str(round(psutil.virtual_memory().total / (1024.0 **3)))+" GB"
return json.dumps(info)
except Exception as e:
logging.exception(e)
class SheetLogger:
def __init__(self, log_repo: SheetCRUDRepository, config_repo: SheetCRUDRepository):
self.log_repo = log_repo
self.config_repo = config_repo
def log(self, log='', nb='', username=''):
self.log_repo.create({
"time": str(get_now()),
"notebook_name": nb,
"kaggle_username": username,
"log": log,
"device": str(get_sys_info()),
"version": VERSION
})
def update_job_status(self, row, validate_status: str = None, notebook_status: str = None):
data = self.config_repo.read(row)
data.update({"last_updated": str(get_now())})
if validate_status is not None:
data.update({"validate_status": validate_status})
if notebook_status is not None:
data.update({"notebook_status": notebook_status})
self.config_repo.update(row, data)
# print(self.config_repo.find({"config": "hahunavth/vlsp-sv-2023-s2pecnet-train"}))
sheet_logger = SheetLogger(log_repo, conf_repo)
if __name__ == "__main__":
sheet_logger.update_job_status(5, "abc" , ) |