From 1e7d0fa8540ff0184cdcad29467aeef2b0845e13 Mon Sep 17 00:00:00 2001 From: Himorask Date: Fri, 4 Dec 2020 12:18:28 -0500 Subject: [PATCH 1/7] Update experiment.py --- src/auspex/experiment.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/auspex/experiment.py b/src/auspex/experiment.py index 9a68a5458..17f69143c 100644 --- a/src/auspex/experiment.py +++ b/src/auspex/experiment.py @@ -385,14 +385,25 @@ def sweep(self): def connect_instruments(self): # Connect the instruments to their resources if not self.instrs_connected: + connected_list = [] for instrument in self._instruments.values(): - instrument.connect() + try: + instrument.connect() + connected_list.append(instrument) + except: + logger.error(f"Failed to connect to instrument {instrument.name}") + logger.error("Disconnecting from other connected instruments") + for instr in connected_list: + instr.disconnect() self.instrs_connected = True def disconnect_instruments(self): # Connect the instruments to their resources for instrument in self._instruments.values(): - instrument.disconnect() + try: + instrument.disconnect() + except: + logger.error(f"Failed to disconnect from {instrument.name}") self.instrs_connected = False def init_dashboard(self): @@ -549,6 +560,7 @@ def run_sweeps(self): time.sleep(0.1) #connect all instruments self.connect_instruments() + assert self.instrs_connected == True, "Instruments were not connected successfully." try: #initialize instruments From cd30382fb7981d026fcaeda8b0041ce16c65ea39 Mon Sep 17 00:00:00 2001 From: Himorask Date: Fri, 4 Dec 2020 12:27:16 -0500 Subject: [PATCH 2/7] Update qubit_exp.py --- src/auspex/qubit/qubit_exp.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/auspex/qubit/qubit_exp.py b/src/auspex/qubit/qubit_exp.py index 18bfd0c29..b87d599c9 100644 --- a/src/auspex/qubit/qubit_exp.py +++ b/src/auspex/qubit/qubit_exp.py @@ -567,18 +567,38 @@ def add_avg_sweep(self, num_averages): def shutdown_instruments(self): # remove socket listeners logger.debug("Shutting down instruments") - try: + try: for awg in self.awgs: - awg.stop() + try: + awg.stop() + except: + logger.error(f"Could not stop AWG {awg.name}") + pass for dig in self.digitizers: - dig.stop() + try: + dig.stop() + except: + logger.error(f"Could not stop digitizer {dig.name}") + pass for gen_proxy in self.generators: - gen_proxy.instr.output = False + # print("Not shutting down generators! WARNING!") + try: + gen_proxy.instr.output = False + except: + logger.error(f"Could not set {gen_proxy.name} output to false") + pass except: - logger.error('Could Not Stop AWGs or Digitizers; Reset Experiment') + logger.error('Could Not Stop AWGs or Digitizers; Reset Experiment') + failflag = False for instr in self.instruments: - instr.disconnect() - self.dig_exit.set() + try: + instr.disconnect() + except: + logger.error(f"Could not disconnect instrument {instr.name}") + failflag = True + if failflag is True: + logger.error('Could not disconnect from some number of instruments, they may need to be reset.') + self.dig_exit.set() #This fails raising AttributeError sometimes, if it happens to others should also set this more carefully for listener in self.dig_listeners: listener.join(2) if listener.is_alive(): From 9b0deab2c87aa7e08403ca05bb6324f4300dc156 Mon Sep 17 00:00:00 2001 From: Tristan Date: Tue, 8 Dec 2020 18:42:21 -0500 Subject: [PATCH 3/7] Update experiment.py Minor changes to how instrs_connected is handled --- src/auspex/experiment.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/auspex/experiment.py b/src/auspex/experiment.py index 17f69143c..c55a6dea6 100644 --- a/src/auspex/experiment.py +++ b/src/auspex/experiment.py @@ -399,12 +399,13 @@ def connect_instruments(self): def disconnect_instruments(self): # Connect the instruments to their resources - for instrument in self._instruments.values(): - try: - instrument.disconnect() - except: - logger.error(f"Failed to disconnect from {instrument.name}") - self.instrs_connected = False + if self.instrs_connected == True: + for instrument in self._instruments.values(): + try: + instrument.disconnect() + except: + logger.error(f"Failed to disconnect from {instrument.name}") + self.instrs_connected = False def init_dashboard(self): from bqplot import DateScale, LinearScale, DateScale, Axis, Lines, Figure, Tooltip From 80042cb4167d8f3de85e3e64e64246a87390e7d2 Mon Sep 17 00:00:00 2001 From: Tristan Date: Tue, 8 Dec 2020 18:44:19 -0500 Subject: [PATCH 4/7] Update qubit_exp.py dig_exit attribute check --- src/auspex/qubit/qubit_exp.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/auspex/qubit/qubit_exp.py b/src/auspex/qubit/qubit_exp.py index b87d599c9..73d808713 100644 --- a/src/auspex/qubit/qubit_exp.py +++ b/src/auspex/qubit/qubit_exp.py @@ -598,13 +598,16 @@ def shutdown_instruments(self): failflag = True if failflag is True: logger.error('Could not disconnect from some number of instruments, they may need to be reset.') - self.dig_exit.set() #This fails raising AttributeError sometimes, if it happens to others should also set this more carefully - for listener in self.dig_listeners: - listener.join(2) - if listener.is_alive(): - logger.debug(f"Terminating listener {listener} aggressively") - listener.terminate() - del listener + + #Ensure that the digitizer-related attributes were created, since they aren't in certain failure conditions. + if hasattr(self,"dig_exit") and hasattr(self, "dig_listeners"): + self.dig_exit.set() + for listener in self.dig_listeners: + listener.join(2) + if listener.is_alive(): + logger.debug(f"Terminating listener {listener} aggressively") + listener.terminate() + del listener import gc gc.collect() From 4111423ab7f0cefa847c100cd5a5c97ca6d74f70 Mon Sep 17 00:00:00 2001 From: Tristan Date: Tue, 8 Dec 2020 19:07:46 -0500 Subject: [PATCH 5/7] Update experiment.py Minor changes to a failure block --- src/auspex/experiment.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/auspex/experiment.py b/src/auspex/experiment.py index c55a6dea6..7b0e2a846 100644 --- a/src/auspex/experiment.py +++ b/src/auspex/experiment.py @@ -384,7 +384,7 @@ def sweep(self): def connect_instruments(self): # Connect the instruments to their resources - if not self.instrs_connected: + if self.instrs_connected == False: connected_list = [] for instrument in self._instruments.values(): try: @@ -394,7 +394,11 @@ def connect_instruments(self): logger.error(f"Failed to connect to instrument {instrument.name}") logger.error("Disconnecting from other connected instruments") for instr in connected_list: - instr.disconnect() + try: + instr.disconnect() + except: + logger.error(f"Failed to disconnect from {instr.name}") + pass self.instrs_connected = True def disconnect_instruments(self): From da39e3cae1e7416468e1018e24eebde272aa072b Mon Sep 17 00:00:00 2001 From: Tristan Date: Tue, 8 Dec 2020 19:19:30 -0500 Subject: [PATCH 6/7] Update experiment.py Minor fixes --- src/auspex/experiment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/auspex/experiment.py b/src/auspex/experiment.py index 7b0e2a846..d79000594 100644 --- a/src/auspex/experiment.py +++ b/src/auspex/experiment.py @@ -398,7 +398,7 @@ def connect_instruments(self): instr.disconnect() except: logger.error(f"Failed to disconnect from {instr.name}") - pass + raise Exception(f"Failed to connect to all instruments; disconnected as best as possible") self.instrs_connected = True def disconnect_instruments(self): @@ -409,6 +409,7 @@ def disconnect_instruments(self): instrument.disconnect() except: logger.error(f"Failed to disconnect from {instrument.name}") + #This probably should have a fail flag or something to throw a higher error after it's done trying to disconnect self.instrs_connected = False def init_dashboard(self): From 51b43915fac7df8b1f9c91d23b094ae8625e950a Mon Sep 17 00:00:00 2001 From: Tristan Date: Tue, 8 Dec 2020 19:27:07 -0500 Subject: [PATCH 7/7] Update qubit_exp.py Fixed the mistake I was making with pass --- src/auspex/qubit/qubit_exp.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/auspex/qubit/qubit_exp.py b/src/auspex/qubit/qubit_exp.py index 73d808713..fbac3b4d3 100644 --- a/src/auspex/qubit/qubit_exp.py +++ b/src/auspex/qubit/qubit_exp.py @@ -567,26 +567,25 @@ def add_avg_sweep(self, num_averages): def shutdown_instruments(self): # remove socket listeners logger.debug("Shutting down instruments") - try: + try: for awg in self.awgs: try: awg.stop() except: logger.error(f"Could not stop AWG {awg.name}") - pass + raise Exception(f"Could not stop AWG {awg.name}") for dig in self.digitizers: try: dig.stop() except: logger.error(f"Could not stop digitizer {dig.name}") - pass + raise Exception(f"Could not stop digitizer {dig.name}") for gen_proxy in self.generators: - # print("Not shutting down generators! WARNING!") try: gen_proxy.instr.output = False except: logger.error(f"Could not set {gen_proxy.name} output to false") - pass + raise Exception(f"Could not set {gen_proxy.name} output to false") except: logger.error('Could Not Stop AWGs or Digitizers; Reset Experiment') failflag = False