Skip to content

Commit

Permalink
Add Workflow and upgrade SDK to v6.73.157
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenAnpu committed Aug 14, 2024
1 parent c2c2d85 commit 5de12e8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
15 changes: 5 additions & 10 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"name": "Export to Pascal VOC",
"type": "app",
"categories": [
"images",
"export"
],
"categories": ["images", "export"],
"description": "Converts Supervisely Project to Pascal VOC format",
"docker_image": "supervisely/import-export:6.73.93",
"instance_version": "6.9.22",
"docker_image": "supervisely/import-export:6.73.157",
"instance_version": "6.10.0",
"main_script": "src/main.py",
"modal_template": "src/modal.html",
"modal_template_state": {
Expand All @@ -20,10 +17,8 @@
"icon_background": "#FFFFFF",
"headless": true,
"context_menu": {
"target": [
"images_project"
],
"target": ["images_project"],
"context_root": "Download as"
},
"poster": "https://user-images.githubusercontent.com/48245050/182382862-d74f1b2c-b19e-47c2-84db-45cd934ec34e.png"
}
}
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
supervisely==6.73.93
supervisely==6.73.157
lxml
numpy>=1.19.4
Pillow>=8.0.1
7 changes: 6 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import supervisely as sly

import globals as g
import workflow as w
import utils


Expand All @@ -14,6 +15,8 @@ def from_sly_to_pascal(api: sly.Api):
meta = sly.ProjectMeta.from_json(meta_json)
sly.logger.info("Palette has been created")

w.workflow_input(api, project_info.id)

full_result_dir_name = f"{str(project_info.id)}_{project_info.name}{g.RESULT_DIR_NAME_ENDING}"

result_dir = os.path.join(g.DATA_DIR, full_result_dir_name)
Expand Down Expand Up @@ -156,7 +159,9 @@ def from_sly_to_pascal(api: sly.Api):
utils.write_segm_set(is_trainval, images_stats, result_imgsets_dir)
utils.write_main_set(is_trainval, images_stats, meta, result_imgsets_dir)

sly.output.set_download(result_dir)
file_info = sly.output.set_download(result_dir)

w.workflow_output(api, file_info)


if __name__ == "__main__":
Expand Down
29 changes: 29 additions & 0 deletions src/workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This module contains the functions that are used to configure the input and output of the workflow for the current app.

from typing import Union

import supervisely as sly


def workflow_input(api: sly.Api, project_id: int):
api.app.workflow.add_input_project(project_id)
sly.logger.debug(f"Workflow: Input project - {project_id}")


def workflow_output(api: sly.Api, file: Union[int, sly.api.file_api.FileInfo]):
try:
if isinstance(file, int):
file = api.file.get_info_by_id(file)
relation_settings = sly.WorkflowSettings(
title=file.name,
icon="archive",
icon_color="#33c94c",
icon_bg_color="#d9f7e4",
url=f"/files/{file.id}/true/?teamId={file.team_id}",
url_title="Download",
)
meta = sly.WorkflowMeta(relation_settings=relation_settings)
api.app.workflow.add_output_file(file, meta=meta)
sly.logger.debug(f"Workflow: Output file - {file}")
except Exception as e:
sly.logger.debug(f"Failed to add output to the workflow: {repr(e)}")

0 comments on commit 5de12e8

Please sign in to comment.