Skip to content

Commit

Permalink
fix: Started catching exceptions in workflow runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirbanbasu committed Sep 10, 2024
1 parent 557e636 commit 692c224
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
except ImportError: # Graceful fallback if IceCream isn't installed.
ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a) # noqa

import sys
from tqdm import tqdm
import asyncio
import uuid
Expand Down Expand Up @@ -963,13 +964,14 @@ async def run(self, query: str):
query=query,
)
)
# done = -1 => error; done = 0 => in-progress; done = 1 => done
done: bool = False
total_steps: int = 0
finished_steps: int = 0
terminal_columns, _ = get_terminal_size()
progress_bar = tqdm(
total=total_steps,
leave=True,
leave=False,
unit="step",
ncols=int(terminal_columns / 2),
desc=APP_TITLE_SHORT,
Expand All @@ -985,7 +987,14 @@ async def run(self, query: str):
progress_bar.update(finished_steps)
progress_bar.refresh()
yield done, finished_steps, total_steps, ev.msg
result = await task
done = self.workflow.is_done()
progress_bar.close()
try:
result = await task
done = self.workflow.is_done()
progress_bar.close()
except Exception as e:
result = f"Exception in running the workflow(s): {str(e)}"
# Set this to done, otherwise another workflow call cannot be made.
done = True
progress_bar.close()
print(result, file=sys.stderr)
yield done, finished_steps, total_steps, result

0 comments on commit 692c224

Please sign in to comment.