Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os

os.rename("env", ".env")
os.rename("env", ".env")
os.makedirs(
os.path.join("{{ cookiecutter.bot_id.replace(' ', '_') }}", "framework", "resources"),
exist_ok=True,
)
52 changes: 44 additions & 8 deletions {{ cookiecutter.bot_id.replace(' ', '_') }}/framework/finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,27 @@ 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:
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)
STATE.maestro.error(task_id=STATE.task_id, exception=ex)


def finish_task_orchestrator():
Expand Down Expand Up @@ -118,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}")