from editor_code.copy_editor.edit_training_run import EditTrainingRuns print os.environ['COPY_EDIT_DATA'] #no-profile profile = False runs = EditTrainingRuns() config = Config.from_file('editor_code/configs/editor/github_s2s.txt') run = runs.new(config) if profile: from gtd.chrono import Profiling, Profiler profiler = Profiler.default() import editor_code.copy_editor.retriever import editor_code.copy_editor.editor profiler.add_module(editor_code.copy_editor.editor) profiler.add_module(editor_code.copy_editor.retriever) Profiling.start() run.train() Profiler.report(profiler) # prints out report else: run.train() #runs = EditTrainingRuns() #config = Config.from_file('editor_code/configs/editor/default.txt') #run = runs.new(config) #run.train()
run.metadata['host'] = socket.gethostname() # start training run.workspace.add_file('stdout', 'stdout.txt') run.workspace.add_file('stderr', 'stderr.txt') run.workspace.add_file('command', 'command.txt') with open(run.workspace.command, 'a') as fout: fout.write(str(sys.argv)) if args.comment: run.workspace.add_file('comment', 'comment.txt') with open(run.workspace.comment, 'a') as fout: fout.write(str(args.comment)) if args.profile: from gtd.chrono import Profiling, Profiler profiler = Profiler.default() # To profile a class, do something like # import phrasenode.foo # profiler.add_module(phrasenode.foo) Profiling.start() with save_stdout(run.workspace.root): try: run.load_latest_model() run.train() finally: run.close() if args.profile: Profiling.report()