mirror of
https://github.com/gryf/coach.git
synced 2025-12-17 11:10:20 +01:00
cleanup debugging code
This commit is contained in:
36
coach.py
36
coach.py
@@ -160,38 +160,6 @@ def run_dict_to_json(_run_dict, task_id=''):
|
||||
return json_path
|
||||
|
||||
|
||||
def enqueue_output(out, queue):
|
||||
for line in iter(out.readline, b''):
|
||||
queue.put(line)
|
||||
out.close()
|
||||
|
||||
|
||||
def merge_streams(processes, output_stream=sys.stdout):
|
||||
q = Queue()
|
||||
threads = []
|
||||
for p in processes:
|
||||
threads.append(Thread(target=enqueue_output, args=(p.stdout, q)))
|
||||
threads.append(Thread(target=enqueue_output, args=(p.stderr, q)))
|
||||
|
||||
for t in threads:
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = q.get_nowait()
|
||||
except Empty:
|
||||
# break when all processes are done and q is empty
|
||||
if all(p.poll() is not None for p in processes):
|
||||
break
|
||||
else:
|
||||
# sys.stdout.write(line)
|
||||
output_stream.write(line.decode(output_stream.encoding))
|
||||
output_stream.flush()
|
||||
|
||||
print('All processes done')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-p', '--preset',
|
||||
@@ -292,8 +260,6 @@ if __name__ == "__main__":
|
||||
if not args.no_summary:
|
||||
atexit.register(logger.print_summary)
|
||||
|
||||
set_cpu()
|
||||
|
||||
# Single-threaded runs
|
||||
if run_dict['num_threads'] == 1:
|
||||
# set tuning parameters
|
||||
@@ -368,8 +334,6 @@ if __name__ == "__main__":
|
||||
else:
|
||||
evaluation_worker = p
|
||||
|
||||
merge_streams(workers + [parameter_server])
|
||||
|
||||
# wait for all workers
|
||||
[w.wait() for w in workers]
|
||||
evaluation_worker.kill()
|
||||
|
||||
14
logger.py
14
logger.py
@@ -250,13 +250,13 @@ class Logger(BaseLogger):
|
||||
if 'Training Reward' in self.data.keys() and 'Evaluation Reward' in self.data.keys():
|
||||
screen.log_title("Max training reward: {}, max evaluation reward: {}".format(self.data['Training Reward'].max(), self.data['Evaluation Reward'].max()))
|
||||
screen.separator()
|
||||
# if screen.ask_yes_no("Do you want to discard the experiment results (Warning: this cannot be undone)?", False):
|
||||
# self.remove_experiment_dir()
|
||||
# elif screen.ask_yes_no("Do you want to specify a different experiment name to save to?", False):
|
||||
# new_name = self.get_experiment_name()
|
||||
# new_path = self.get_experiment_path(new_name, create_path=False)
|
||||
# shutil.move(self.experiments_path, new_path)
|
||||
# screen.log_title("Results moved to: {}".format(new_path))
|
||||
if screen.ask_yes_no("Do you want to discard the experiment results (Warning: this cannot be undone)?", False):
|
||||
self.remove_experiment_dir()
|
||||
elif screen.ask_yes_no("Do you want to specify a different experiment name to save to?", False):
|
||||
new_name = self.get_experiment_name()
|
||||
new_path = self.get_experiment_path(new_name, create_path=False)
|
||||
shutil.move(self.experiments_path, new_path)
|
||||
screen.log_title("Results moved to: {}".format(new_path))
|
||||
|
||||
def get_experiment_name(self, initial_experiment_name=''):
|
||||
match = None
|
||||
|
||||
Reference in New Issue
Block a user