Support run one step for debugging (#99)

This commit is contained in:
you-n-g
2024-07-23 19:00:59 +08:00
committed by GitHub
parent 44169507b2
commit 40d108687c
2 changed files with 17 additions and 4 deletions
+14 -1
View File
@@ -51,9 +51,22 @@ class LoopBase:
self.loop_trace = defaultdict(list[LoopTrace]) # the key is the number of loop
self.session_folder = logger.log_trace_path / "__session__"
def run(self):
def run(self, step_n: int | None = None):
"""
Parameters
----------
step_n : int | None
How many steps to run;
`None` indicates to run forever until error or KeyboardInterrupt
"""
with tqdm(total=len(self.steps), desc="Workflow Progress", unit="step") as pbar:
while True:
if step_n is not None:
if step_n <= 0:
break
step_n -= 1
li, si = self.loop_idx, self.step_idx
start = datetime.datetime.now(datetime.timezone.utc)