From 92753509f3c4bbef9b906d3b01dfdf158846b67a Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 25 Oct 2023 10:44:42 +0200 Subject: [PATCH] handle error and update modal window msg --- supervisely/train/src/sly_train.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/supervisely/train/src/sly_train.py b/supervisely/train/src/sly_train.py index 63a7a82769d5..76946aa8afcc 100644 --- a/supervisely/train/src/sly_train.py +++ b/supervisely/train/src/sly_train.py @@ -40,7 +40,15 @@ def train(api: sly.Api, task_id, context, state, app_logger): # download and preprocess Sypervisely project (using cache) download_progress = get_progress_cb("Download data (using cache)", g.project_info.items_count * 2) - sly.download_project(api, project_id, project_dir, cache=my_app.cache, progress_cb=download_progress) + try: + sly.download_project(api, project_id, project_dir, cache=my_app.cache, progress_cb=download_progress) + except Exception as e: + sly.logger.warn("Can not download project") + raise Exception( + "Can not download the project. " + f"Check if the project is available, it is not archived, not modified and not empty. " + f"{repr(e)}" + ) # preprocessing: transform labels to bboxes, filter classes, ... try: @@ -120,7 +128,7 @@ def train(api: sly.Api, task_id, context, state, app_logger): upload_artifacts(g.local_artifacts_dir, g.remote_artifacts_dir) set_task_output() except Exception as e: - my_app.show_modal_window(f"Something went wrong. Find more info in the app logs. Error: {str(e)}", level="error") + my_app.show_modal_window(f"Something went wrong. Find more info in the app logs. {repr(e)}", level="error") api.app.set_field(task_id, "state.started", False) # stop application