From 855cb82e70ecf2b63ca24fb42d4a48df183c78b9 Mon Sep 17 00:00:00 2001 From: Chris Billington Date: Fri, 13 Dec 2019 16:21:08 -0500 Subject: [PATCH 1/2] compilation-queue: Move new_rep_name to runmanager, since the runmanager compilation queue uses it too now. Inform runmanager how many shots are remaining each iteration of the queue. This is a bit of a hack presently, it happens in the queue's thread and so blocks for up to 5 seconds if runmanager is not running. It would be better done as an extension that the queue pipes events to. --- blacs/experiment_queue.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/blacs/experiment_queue.py b/blacs/experiment_queue.py index f98875e..9af0b59 100644 --- a/blacs/experiment_queue.py +++ b/blacs/experiment_queue.py @@ -35,6 +35,7 @@ from labscript_utils.qtwidgets.elide_label import elide_label from labscript_utils.connections import ConnectionTable import labscript_utils.properties +from runmanager import new_rep_name from blacs.tab_base_classes import MODE_MANUAL, MODE_TRANSITION_TO_BUFFERED, MODE_TRANSITION_TO_MANUAL, MODE_BUFFERED import blacs.plugins as plugins @@ -389,10 +390,7 @@ def process_request(self,h5_filepath): rerun = False if rerun or self.is_in_queue(h5_filepath): self._logger.debug('Run file has already been run! Creating a fresh copy to rerun') - new_h5_filepath, repeat_number = self.new_rep_name(h5_filepath) - # Keep counting up until we get a filename that isn't in the filesystem: - while os.path.exists(new_h5_filepath): - new_h5_filepath, repeat_number = self.new_rep_name(new_h5_filepath) + new_h5_filepath, repeat_number = new_rep_name(h5_filepath) success = self.clean_h5_file(h5_filepath, new_h5_filepath, repeat_number=repeat_number) if not success: return 'Cannot create a re run of this experiment. Is it a valid run file?' @@ -419,19 +417,6 @@ def process_request(self,h5_filepath): "The error was %s\n"%error) return message - def new_rep_name(self, h5_filepath): - basename, ext = os.path.splitext(h5_filepath) - if '_rep' in basename and ext == '.h5': - reps = basename.split('_rep')[-1] - try: - reps = int(reps) - except ValueError: - # not a rep - pass - else: - return ''.join(basename.split('_rep')[:-1]) + '_rep%05d.h5' % (reps + 1), reps + 1 - return basename + '_rep%05d.h5' % 1, 1 - def clean_h5_file(self, h5file, new_h5_file, repeat_number=0): try: with h5py.File(h5file, 'r') as old_file: @@ -521,7 +506,16 @@ def manage(self): timeout_limit = 300 #seconds self.set_status("Idle") + import runmanager.remote + from qtutils import inmain + client = runmanager.remote.Client(default_timeout=5) + while self.manager_running: + try: + client.advise_BLACS_shots_remaining(inmain(self._model.rowCount)) + except Exception: + logger.exception("error telling runmanager how many shots are remaining") + # If the pause button is pushed in, sleep if self.manager_paused: if self.get_status() == "Idle": From 242d44a7abf2ebc6a0340579ed8e8a0e08a03535 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Fri, 7 Jan 2022 19:38:33 +1100 Subject: [PATCH 2/2] Use correct timeout argument for runmanager remote client This was implemented independently in both branches, and in the master branch is named just `timeout` --- blacs/experiment_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacs/experiment_queue.py b/blacs/experiment_queue.py index 9af0b59..452ae78 100644 --- a/blacs/experiment_queue.py +++ b/blacs/experiment_queue.py @@ -508,7 +508,7 @@ def manage(self): import runmanager.remote from qtutils import inmain - client = runmanager.remote.Client(default_timeout=5) + client = runmanager.remote.Client(timeout=5) while self.manager_running: try: