From 289d4f3eb4104ec697a9b0412d02af4fee5b7752 Mon Sep 17 00:00:00 2001 From: Ezira Yimer Wolle Date: Thu, 21 Jan 2021 22:31:46 -0500 Subject: [PATCH] Make dpu compatible with re-launching experiments through app. Ensures that data is no overwritten. --- experiment/template/eVOLVER.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/experiment/template/eVOLVER.py b/experiment/template/eVOLVER.py index e88e2e73..fbed9722 100644 --- a/experiment/template/eVOLVER.py +++ b/experiment/template/eVOLVER.py @@ -314,14 +314,14 @@ def _create_file(self, vial, param, directory=None, defaults=None): text_file.write(default + '\n') text_file.close() - def initialize_exp(self, vials, experiment_params, always_yes = False): + def initialize_exp(self, vials, experiment_params, always_yes = False, exp_recover = False): self.experiment_params = experiment_params logger.debug('initializing experiment') if os.path.exists(EXP_DIR): logger.info('found an existing experiment') exp_continue = None - if always_yes: + if always_yes | exp_recover: exp_continue = 'y' else: while exp_continue not in ['y', 'n']: @@ -576,6 +576,11 @@ def get_options(): '(i.e. continues from existing experiment, ' 'overwrites existing data and blanks OD ' 'measurements)') + parser.add_argument('--exp-recover', action='store_true', + default=False, + help='Continues experiment without overwriting information' + '(i.e. continues experiment without overwriting)' + ' existing data or blank measurements') parser.add_argument('--log-name', default=os.path.join(EXP_DIR, 'evolver.log'), help='Log file name directory (default: %(default)s)') @@ -613,10 +618,11 @@ def get_options(): EVOLVER_NS.start_time = EVOLVER_NS.initialize_exp(VIALS, experiment_params, options.always_yes, + options.exp_recover ) # Using a non-blocking stream reader to be able to listen - # for commands from the electron app. + # for commands from the electron app. nbsr = NBSR(sys.stdin) paused = False @@ -635,7 +641,7 @@ def get_options(): level=level) reset_connection_timer = time.time() - while True: + while True: try: # infinite loop @@ -647,7 +653,7 @@ def get_options(): paused = True EVOLVER_NS.stop_exp() socketIO.disconnect() - + if 'continue-script' in message: print('Restarting experiment', flush = True) paused = False