ouob commited on
Commit
0fee76f
·
1 Parent(s): 457b38c

fix: timer

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -12,17 +12,6 @@ HF_HOME = os.getenv('HF_HOME')
12
  AUTH_REPO_URL = REPO_URL.replace('https://', f'https://{USER}:{ACCESS_TOKEN}@')
13
 
14
 
15
- def timer(func):
16
- def wrapper(*args, **kwargs):
17
- start_time = time.time()
18
- result = func(*args, **kwargs)
19
- end_time = time.time()
20
- elapsed_time = end_time - start_time
21
- print(f'建置時間:{elapsed_time:.2f} 秒', )
22
- return result
23
- return wrapper
24
-
25
-
26
  def check_envs():
27
  envs = [USER, REPO_URL, ACCESS_TOKEN]
28
  missing_vars = [var for var in envs if var is None]
@@ -67,17 +56,20 @@ def clone(status_code):
67
  raise e
68
 
69
 
70
- def run():
71
  os.chdir(os.path.join(REPO_DIR))
 
 
72
  print('嘗試運行主程式...')
73
  subprocess.run(["python", "app.py"], check=True)
74
  print('運行成功!')
75
 
76
  def main():
 
77
  check_envs()
78
  status_code = pull()
79
  clone(status_code)
80
- run()
81
 
82
 
83
  if __name__ == "__main__":
 
12
  AUTH_REPO_URL = REPO_URL.replace('https://', f'https://{USER}:{ACCESS_TOKEN}@')
13
 
14
 
 
 
 
 
 
 
 
 
 
 
 
15
  def check_envs():
16
  envs = [USER, REPO_URL, ACCESS_TOKEN]
17
  missing_vars = [var for var in envs if var is None]
 
56
  raise e
57
 
58
 
59
+ def run(build_start):
60
  os.chdir(os.path.join(REPO_DIR))
61
+ build_end = time.time()
62
+ print(f'建置時間:{build_end - build_start} 秒', )
63
  print('嘗試運行主程式...')
64
  subprocess.run(["python", "app.py"], check=True)
65
  print('運行成功!')
66
 
67
  def main():
68
+ build_start = time.perf_counter()
69
  check_envs()
70
  status_code = pull()
71
  clone(status_code)
72
+ run(build_start)
73
 
74
 
75
  if __name__ == "__main__":