QuantumQuadrate / CsPyController

GNU Lesser General Public License v3.0
3 stars 3 forks source link

automatically repeat same experiment when it's over #25

Open kwnminho opened 6 years ago

kwnminho commented 6 years ago

I wanted to allow CsPy to automatically reset and go once experiment is over. Added some code at the end of upload method in experiment.py and doesn't seem to work. I guess because it's on exp_thread not master thread...

     def upload(self):
         #store the notes again
         logger.info('Storing notes ...')
         del self.hdf5['notes']
         self.hdf5['notes'] = self.notes

         #store the log
         # logger.info('Storing log ...')
         # self.log.flush()
         # try:
         #     self.hdf5['log'] = self.log.getvalue()
         # except ValueError:
         #     # this throws an error at the end of an optimization experiment
         #     logger.exception('Exception occured when accessing self.log')
         self.hdf5.flush()

         #copy to network
         if self.copyDataToNetwork:
             logger.info('Copying data to network...')
             shutil.copytree(self.path, os.path.join(self.networkDataPath, self.dailyPath, self.experimentPath))

         self.set_status('idle')
         logger.info('Finished Experiment.')
         self.progress = 100
         self.update_gui()
         if self.enable_sounds:
             sound.complete_sound()
+        if self.experiment.repeat_experiment_automatically:
+            logger.info('Automatically repeating the same experiment')
+            self.resetAndGo()