diff --git a/local.env b/local.env index 708b974..4b45517 100644 --- a/local.env +++ b/local.env @@ -10,9 +10,9 @@ LOG_LEVEL="debug" # Almaz # USER_ID = 330 -TEAM_ID = 447 -WORKSPACE_ID = 680 -# PROJECT_ID = 36910 +TEAM_ID = 451 +WORKSPACE_ID = 712 +PROJECT_ID = 38385 # DATASET_ID = 88187 # DATASET_NAME = diff --git a/src/globals.py b/src/globals.py index 658acee..eaa99b9 100644 --- a/src/globals.py +++ b/src/globals.py @@ -1,16 +1,18 @@ import datetime import os - from distutils.util import strtobool -from dotenv import load_dotenv import supervisely as sly +from dotenv import load_dotenv + +from workflow import Workflow if sly.is_development(): load_dotenv("local.env") load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api() +workflow = Workflow(api) app_data = sly.app.get_data_dir() sly.fs.clean_dir(app_data) diff --git a/src/main.py b/src/main.py index 2b3dbed..0df7c2f 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ +import supervisely as sly + import src.functions as f import src.globals as g -import supervisely as sly # * 1. Get project and dataset infos try: @@ -43,6 +44,7 @@ f"{project.name}. {'' if 'dataset' in dataset.name else 'New dataset: '}{dataset.name}" ) g.api.task.set_output_project(g.task_id, project.id, output_title) +g.workflow.add_output(project) # * 5. Clean app_data directory sly.fs.clean_dir(g.app_data) diff --git a/src/workflow.py b/src/workflow.py new file mode 100644 index 0000000..7be348b --- /dev/null +++ b/src/workflow.py @@ -0,0 +1,37 @@ +import supervisely as sly + + +def check_compatibility(func): + def wrapper(self, *args, **kwargs): + if self.is_compatible is None: + self.is_compatible = self.check_instance_ver_compatibility() + if not self.is_compatible: + return + return func(self, *args, **kwargs) + + return wrapper + + +class Workflow: + def __init__(self, api: sly.Api, min_instance_version: str = None): + self.is_compatible = None + self.api = api + self._min_instance_version = ( + "6.9.31" if min_instance_version is None else min_instance_version + ) + + def check_instance_ver_compatibility(self): + if self.api.instance_version < self._min_instance_version: + sly.logger.info( + f"Supervisely instance version does not support workflow features. To use them, please update your instance minimum to version {self._min_instance_version}." + ) + return False + return True + + @check_compatibility + def add_input(self): + raise NotImplementedError + + @check_compatibility + def add_output(self, project_info: sly.ProjectInfo): + self.api.app.workflow.add_output_project(project_info)