From c46720fcd122e2b07cb3c627373ae164d15bf6f4 Mon Sep 17 00:00:00 2001 From: LaraArgento Date: Thu, 12 Feb 2026 18:41:33 -0300 Subject: [PATCH 1/3] 'wip' --- .../framework/finalize.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py index 5c25988..465e614 100644 --- a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py +++ b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py @@ -72,20 +72,26 @@ def upload_output_orchestrator(): """ Uploads the whole output folder to the BotCity Orchestrator. """ - try: - logger.info( - f"Uploading output to BotCity Orchestrator as Result Files...") - for f in glob.iglob("./output/*"): + logger.info( + f"Uploading output to BotCity Orchestrator as Result Files...") + for f in glob.iglob("./output/*"): + try: fp = Path(f) + # todo add error handling for individual files (e.g. if file is + # locked, too large, etc.) - currently it will just skip and log + # the error STATE.maestro.post_artifact( task_id=STATE.task_id, artifact_name=fp.name, filepath=fp ) - - except Exception as ex: - print(f"Error uploading output to BotCity Orchestrator: {ex}") - raise ex + except Exception as ex: + STATE.maestro.alert( + task_id=STATE.task_id, + title="Error uploading output to BotCity Orchestrator", + message=f"Error uploading file {f} to BotCity Orchestrator: {ex}. Check the Runner Logs for more details.", + alert_type=AlertType.ERROR) + print(f"Error uploading file {f} to BotCity Orchestrator: {ex}") def finish_task_orchestrator(): From 245478cd05601d0d488ff3e6ed20bb3a2fae5335 Mon Sep 17 00:00:00 2001 From: Lara Argento Date: Tue, 9 Jun 2026 18:32:32 -0300 Subject: [PATCH 2/3] adds alert and error report during file upload --- hooks/post_gen_project.py | 6 +++++- .../framework/finalize.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 14e838d..4760f95 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,3 +1,7 @@ import os -os.rename("env", ".env") \ No newline at end of file +os.rename("env", ".env") +os.makedirs( + os.path.join("{{ cookiecutter.bot_id.replace(' ', '_') }}", "framework", "resources"), + exist_ok=True, +) \ No newline at end of file diff --git a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py index 465e614..453ada3 100644 --- a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py +++ b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py @@ -86,12 +86,13 @@ def upload_output_orchestrator(): filepath=fp ) except Exception as ex: + print(f"Error uploading file {f} to BotCity Orchestrator: {ex}") STATE.maestro.alert( task_id=STATE.task_id, title="Error uploading output to BotCity Orchestrator", message=f"Error uploading file {f} to BotCity Orchestrator: {ex}. Check the Runner Logs for more details.", alert_type=AlertType.ERROR) - print(f"Error uploading file {f} to BotCity Orchestrator: {ex}") + STATE.maestro.error(task_id=STATE.task_id, exception=ex) def finish_task_orchestrator(): From ac6f88cb8d9d76f680f8d0f45af9ad85b9f39c95 Mon Sep 17 00:00:00 2001 From: Lara Argento Date: Tue, 9 Jun 2026 18:38:53 -0300 Subject: [PATCH 3/3] adds auto append message if business error occurs --- .../framework/finalize.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py index 453ada3..9b1dbd5 100644 --- a/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py +++ b/{{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py @@ -125,7 +125,36 @@ def finish_status_message() -> str: In our run for task {STATE.task_id} we processed {STATE.total_items} items, from which {STATE.success_count} were with success. Check the Result Files for more details. ''' + # Append optional extra message from STATE.finish_message_extra if + # present + extra = getattr(STATE, "finish_message_extra", None) + if extra: + msg = msg + str(extra) return msg except Exception as ex: logger.error(f"Error generating finish status message: {ex}") return "Task completed. Check the Result Files for more details." + +def append_finish_status_message(extra: str) -> None: + """ + Append extra text to be included into finish_status_message. + Stores a single string at STATE.finish_message_extra (concatenates with newlines). + Will not add the text if an existing line is exactly the same (after trimming). + """ + try: + new = str(extra).strip() + if not new: + return + current = getattr(STATE, "finish_message_extra", "") + # check for exact duplicate among existing lines (trimmed) + existing_lines = [line.strip() + for line in current.splitlines() if line.strip()] + if new in existing_lines: + logger.debug("Duplicate finish status message skipped.") + return + if current: + STATE.finish_message_extra = f"{current} {new}" + else: + STATE.finish_message_extra = new + except Exception as ex: + logger.error(f"Error appending finish status message: {ex}")