progress bar format on 1.11
We found the old delault informations provided by tqdm more pertinent for "standard" scans (providing the remaining time and the frame rate). Also, we suggest to add the information "infinite scan" based on the npoint and not the type of scan (it is possible to start a loopscan with npoints = 0).
We propose the following modifications on bliss/shell/data/display.py. Modifications are labeled as comments # BM32 - ...
class StepScanProgress(ScanProgress):
def __init__(self, tracked_channels=None, output=None):
super().__init__(tracked_channels)
self._output = output
def scan_new_callback(self):
npoints = self.scan_info["npoints"]
count_time = self.scan_info.get("count_time", 0.2)
if count_time == 0:
count_time = 0.2
fps = 1 / count_time
#if self.scan_type == "timescan": # infinite
if npoints == 0 : # BM32 - infinite scan based on npoints
total = 0
bar_format = " ===> Running infinite scan <=== (abort with Ctrl-c) [elapsed time {elapsed_s:.1f} s] "
elif self.scan_type == "ct": # based on count_time
total = count_time
self.__start = time.time()
self.__prev = self.__start
self.__end = self.__start + total
bar_format = (
"{l_bar}{bar} (abort with Ctrl-c) [elapsed time {elapsed_s:.1f} s] "
)
self._scan_renderer = ScanRenderer(self.scan_info)
fps = 10 / count_time
self._tracked_channels = (
"all" # listen all scan channels in order to display ct output
)
else: # based on npoints
self.__prev = 0
total = npoints
# bar_format = (
# "{l_bar}{bar} (abort with Ctrl-c) [elapsed time {elapsed_s:.1f}] "
# ) # bliss new format
bar_format = (
"{l_bar}{bar} [elapsed {elapsed_s:.1f} - remaining {remaining_s:.1f} s - {rate_fmt}] "
) # BM32 format
fps = max(1, fps)
self._frame_rate = min(10, fps)
self.__progress_bar = tqdm(
total=total,
unit_scale=True,
leave=False,
ascii=False,
bar_format=bar_format,
dynamic_ncols=True,
file=self._output, # stderr by default
)
def scan_end_callback(self):
self.__progress_bar.clear()
self.__progress_bar.close()
self.__progress_bar = None
if self.scan_type == "ct":
self._scan_renderer.print_table_header()
self._scan_renderer.append_data(self._data_dict)
self._scan_renderer.print_data_ct(None)
def progress_callback(self):
now = time.time()
#if self.scan_type == "timescan":
if self.scan_info["npoints"] == 0: # BM32 - infinite scan based on npoints
incr = 1
elif self.scan_type == "ct":
if now <= self.__end:
incr = now - self.__prev
else:
incr = 0
else: # based on point number
if not self._scan._acq_chain.iterators:
# not yet initialized
return
now = (
self._scan._acq_chain.iterators[0].sequence_index + 1
) # step_by_step scan has only one top_master
incr = now - self.__prev
self.__progress_bar.update(incr)
self.__prev = now