Terry Zhuo commited on
Commit
071ce9f
·
1 Parent(s): 1bb4e03

rm is_running

Browse files
Files changed (1) hide show
  1. src/execute.py +43 -43
src/execute.py CHANGED
@@ -10,7 +10,7 @@ import shutil
10
  from pathlib import Path
11
 
12
  default_command = "bigcodebench.evaluate"
13
- is_running = False
14
 
15
  def generate_command(
16
  jsonl_file, split, subset, parallel,
@@ -65,53 +65,53 @@ def find_result_file():
65
  return None
66
 
67
  def run_bigcodebench(command):
68
- global is_running
69
- if is_running:
70
- yield "A command is already running. Please wait for it to finish.\n"
71
- return
72
- is_running = True
73
 
74
- try:
75
- yield f"Executing command: {command}\n"
76
-
77
- process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
78
-
79
- def kill_process():
80
- if process.poll() is None: # If the process is still running
81
- process.terminate()
82
- is_running = False
83
- yield "Process terminated after 12 minutes timeout.\n"
84
 
85
- # Start a timer to kill the process after 12 minutes
86
- timer = threading.Timer(720, kill_process)
87
- timer.start()
88
-
89
- for line in process.stdout:
90
- yield line
91
-
92
- # process.wait()
93
-
94
- timer.cancel()
95
-
96
- if process.returncode != 0:
97
- yield f"Error: Command exited with status {process.returncode}\n"
98
-
99
- yield "Evaluation completed.\n"
100
-
101
- result_file = find_result_file()
102
- if result_file:
103
- yield f"Result file found: {result_file}\n"
104
- else:
105
- yield "No result file found.\n"
106
- finally:
107
- is_running = False
108
 
109
  def stream_logs(command, jsonl_file=None):
110
- global is_running
111
 
112
- if is_running:
113
- yield "A command is already running. Please wait for it to finish.\n"
114
- return
115
 
116
  cleanup_previous_files(jsonl_file)
117
  yield "Cleaned up previous files.\n"
 
10
  from pathlib import Path
11
 
12
  default_command = "bigcodebench.evaluate"
13
+ # is_running = False
14
 
15
  def generate_command(
16
  jsonl_file, split, subset, parallel,
 
65
  return None
66
 
67
  def run_bigcodebench(command):
68
+ # global is_running
69
+ # if is_running:
70
+ # yield "A command is already running. Please wait for it to finish.\n"
71
+ # return
72
+ # is_running = True
73
 
74
+ # try:
75
+ yield f"Executing command: {command}\n"
76
+
77
+ process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
78
+
79
+ def kill_process():
80
+ if process.poll() is None: # If the process is still running
81
+ process.terminate()
82
+ # is_running = False
83
+ yield "Process terminated after 12 minutes timeout.\n"
84
 
85
+ # Start a timer to kill the process after 12 minutes
86
+ timer = threading.Timer(720, kill_process)
87
+ timer.start()
88
+
89
+ for line in process.stdout:
90
+ yield line
91
+
92
+ # process.wait()
93
+
94
+ timer.cancel()
95
+
96
+ if process.returncode != 0:
97
+ yield f"Error: Command exited with status {process.returncode}\n"
98
+
99
+ yield "Evaluation completed.\n"
100
+
101
+ result_file = find_result_file()
102
+ if result_file:
103
+ yield f"Result file found: {result_file}\n"
104
+ else:
105
+ yield "No result file found.\n"
106
+ # finally:
107
+ # is_running = False
108
 
109
  def stream_logs(command, jsonl_file=None):
110
+ # global is_running
111
 
112
+ # if is_running:
113
+ # yield "A command is already running. Please wait for it to finish.\n"
114
+ # return
115
 
116
  cleanup_previous_files(jsonl_file)
117
  yield "Cleaned up previous files.\n"