From 931ac3c614c5c1bf038a198fdcff480be8e50c1b Mon Sep 17 00:00:00 2001
From: iwatkot
Date: Mon, 9 Oct 2023 17:17:39 +0300
Subject: [PATCH 1/7] Image meta support.
---
README.md | 7 ++++---
config.json | 2 +-
src/main.py | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 72a4d86..a8fb091 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,6 @@
How To Use
-
[![](https://img.shields.io/badge/supervisely-ecosystem-brightgreen)](https://ecosystem.supervise.ly/apps/supervisely-ecosystem/export-to-supervisely-format)
[![](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://supervise.ly/slack)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/supervisely-ecosystem/export-to-supervisely-format)
@@ -19,13 +18,15 @@
# Overview
-Download images project or dataset in [Supervisely JSON format](https://docs.supervise.ly/data-organization/00_ann_format_navi). It is possible to download both images and annotations or only annotations.
+ℹ️ Starting from version 2.7.7 the application will save images metadata in JSON format to `meta` directory in each dataset.
+Download images project or dataset in [Supervisely JSON format](https://docs.supervise.ly/data-organization/00_ann_format_navi). It is possible to download both images and annotations or only annotations.
# How To Use
+
**Step 1**: Add app to your team from [Ecosystem](https://ecosystem.supervise.ly/apps/export-to-supervisely-format) if it is not there
-**Step 2**: Open context menu of images project (or images dataset) -> `Run App` -> `Download via app` -> `Export to Supervisely format`
+**Step 2**: Open context menu of images project (or images dataset) -> `Run App` -> `Download via app` -> `Export to Supervisely format`
diff --git a/config.json b/config.json
index 2ab9fe9..1ff6209 100644
--- a/config.json
+++ b/config.json
@@ -6,7 +6,7 @@
"export"
],
"description": "images and JSON annotations",
- "docker_image": "supervisely/import-export:6.72.114",
+ "docker_image": "supervisely/import-export:6.72.149",
"instance_version": "6.5.1",
"main_script": "src/main.py",
"modal_template": "src/modal.html",
diff --git a/src/main.py b/src/main.py
index 65779c2..e2af43e 100644
--- a/src/main.py
+++ b/src/main.py
@@ -113,7 +113,7 @@ def download_json_plus_images(api, project, dataset_ids):
if os.path.exists(download_dir):
sly.fs.clean_dir(download_dir)
sly.download_project(api, project.id, download_dir, dataset_ids=dataset_ids,
- log_progress=True, batch_size=batch_size)
+ log_progress=True, batch_size=batch_size, save_image_meta=True)
sly.logger.info('Project {!r} has been successfully downloaded.'.format(project.name))
From 79f007d20de00ed9b6ba43982ea90e6dccc8b927 Mon Sep 17 00:00:00 2001
From: Almaz <79905215+almazgimaev@users.noreply.github.com>
Date: Fri, 1 Dec 2023 22:15:08 +0100
Subject: [PATCH 2/7] Update SDK version to 6.72.206. Download project with
retries. Update app files. (#13)
* update app, download with retries
* update supervisely and min_instance versions
* add debug and supervisely to gitignore
* update env file
* vscode settings
---
.gitignore | 4 +-
.vscode/settings.json | 35 +++++++++++++
config.json | 4 +-
debug.env | 20 --------
dev_requirements.txt | 2 +-
local.env | 13 +++++
src/main.py | 116 ++++++++++++++++++++++++++----------------
src/sly_functions.py | 72 ++++++++++++++++++++++++++
8 files changed, 199 insertions(+), 67 deletions(-)
create mode 100644 .vscode/settings.json
delete mode 100644 debug.env
create mode 100644 local.env
create mode 100644 src/sly_functions.py
diff --git a/.gitignore b/.gitignore
index acfe160..3e8c02c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@ secret_debug.env
.idea
venv
.venv/
-dataset_tools
\ No newline at end of file
+dataset_tools
+supervisely
+debug
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..8ad43f3
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,35 @@
+{
+ "files.exclude": {
+ "**/__pycache__": true,
+ "build": true,
+ "supervisely.egg-info": true,
+ ".venv": true
+ },
+ "python.defaultInterpreterPath": ".venv/bin/python",
+ "editor.formatOnSave": true,
+ "editor.formatOnPaste": true,
+ "editor.formatOnType": true,
+ "black-formatter.args": ["--line-length", "100"],
+ "[html]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[json]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[python]": {
+ "editor.defaultFormatter": "ms-python.black-formatter",
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.organizeImports": true
+ }
+ },
+ "isort.args": ["--profile", "black"],
+ "debug.inlineValues": "off",
+ "python.analysis.typeCheckingMode": "off",
+ "python.analysis.autoImportCompletions": false,
+ "autoDocstring.docstringFormat": "sphinx",
+ "autoDocstring.customTemplatePath": "docs/.mustache",
+ "python.testing.pytestArgs": ["tests/inference_cache"],
+ "python.testing.unittestEnabled": false,
+ "python.testing.pytestEnabled": true
+}
diff --git a/config.json b/config.json
index 1ff6209..1d88d4a 100644
--- a/config.json
+++ b/config.json
@@ -6,8 +6,8 @@
"export"
],
"description": "images and JSON annotations",
- "docker_image": "supervisely/import-export:6.72.149",
- "instance_version": "6.5.1",
+ "docker_image": "supervisely/import-export:6.72.206",
+ "instance_version": "6.8.48",
"main_script": "src/main.py",
"modal_template": "src/modal.html",
"modal_template_state": {
diff --git a/debug.env b/debug.env
deleted file mode 100644
index f5198b4..0000000
--- a/debug.env
+++ /dev/null
@@ -1,20 +0,0 @@
-PYTHONUNBUFFERED=1
-TASK_ID=14507
-
-context.teamId=8
-context.workspaceId=349
-modal.state.slyProjectId=9771
-modal.state.download=all
-modal.state.fixExtension=true
-DEBUG_APP_DIR="/home/paul/Documents/Work/Applications/export-to-supervisely-format/debug/app_debug_data"
-DEBUG_CACHE_DIR="/home/paul/Documents/Work/Applications/export-to-supervisely-format/debug/app_debug_cache"
-
-LOG_LEVEL="debug"
-#DEBUG_APP_DIR="/Users/maxim/work/app_debug_data"
-#DEBUG_CACHE_DIR="/Users/maxim/work/app_debug_cache"
-
-SERVER_ADDRESS="put your value here in secret_debug.env"
-API_TOKEN="put your value here in secret_debug.env"
-AGENT_TOKEN="put your value here in secret_debug.env"
-
-
diff --git a/dev_requirements.txt b/dev_requirements.txt
index 91e4657..d5cc636 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -1 +1 @@
-supervisely==6.72.110
+supervisely==6.72.206
diff --git a/local.env b/local.env
new file mode 100644
index 0000000..fd0ab63
--- /dev/null
+++ b/local.env
@@ -0,0 +1,13 @@
+PYTHONUNBUFFERED=1
+TASK_ID=50046
+
+context.teamId=537
+context.workspaceId=1029
+modal.state.slyProjectId=32318
+modal.state.download=all
+modal.state.fixExtension=true
+
+DEBUG_APP_DIR=debug/app_debug_data
+DEBUG_CACHE_DIR=debug/app_debug_cache
+
+LOG_LEVEL="debug"
diff --git a/src/main.py b/src/main.py
index e2af43e..9543c96 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,22 +1,30 @@
import os
+from distutils import util
+
+from dotenv import load_dotenv
+
+import sly_functions as f
import supervisely as sly
from supervisely.api.module_api import ApiField
-from supervisely.io.fs import get_file_ext
from supervisely.app.v1.app_service import AppService
-from distutils import util
+from supervisely.io.fs import get_file_ext
-api: sly.Api = sly.Api.from_env()
-my_app: AppService = AppService()
+if sly.is_development():
+ load_dotenv("local.env")
+ load_dotenv(os.path.expanduser("~/supervisely.env"))
-TEAM_ID = int(os.environ['context.teamId'])
-WORKSPACE_ID = int(os.environ['context.workspaceId'])
-PROJECT_ID = int(os.environ['modal.state.slyProjectId'])
-DATASET_ID = os.environ.get('modal.state.slyDatasetId', None)
+api = sly.Api.from_env()
+my_app = AppService()
+
+TEAM_ID = int(os.environ["context.teamId"])
+WORKSPACE_ID = int(os.environ["context.workspaceId"])
+PROJECT_ID = int(os.environ["modal.state.slyProjectId"])
+DATASET_ID = os.environ.get("modal.state.slyDatasetId", None)
if DATASET_ID is not None:
DATASET_ID = int(DATASET_ID)
task_id = int(os.environ["TASK_ID"])
-mode = os.environ['modal.state.download']
-replace_method = bool(util.strtobool(os.environ['modal.state.fixExtension']))
+mode = os.environ["modal.state.download"]
+replace_method = bool(util.strtobool(os.environ["modal.state.fixExtension"]))
batch_size = 10
@@ -34,7 +42,7 @@ def ours_convert_json_info(self, info: dict, skip_missing=True):
val = info[field_name]
field_values.append(val)
if field_name == ApiField.MIME:
- temp_ext = val.split('/')[1]
+ temp_ext = val.split("/")[1]
field_values.append(temp_ext)
for idx, field_name in enumerate(self.info_sequence()):
if field_name == ApiField.NAME:
@@ -42,7 +50,7 @@ def ours_convert_json_info(self, info: dict, skip_missing=True):
if not cur_ext:
field_values[idx] = "{}.{}".format(field_values[idx], temp_ext)
break
- if temp_ext == 'jpeg' and cur_ext in ['jpg', 'jpeg', 'mpo']:
+ if temp_ext == "jpeg" and cur_ext in ["jpg", "jpeg", "mpo"]:
break
if temp_ext != cur_ext and cur_ext is not None:
pass
@@ -51,12 +59,12 @@ def ours_convert_json_info(self, info: dict, skip_missing=True):
def init(data, state):
- state['download'] = mode
- state['fixExtension'] = replace_method
+ state["download"] = mode
+ state["fixExtension"] = replace_method
if replace_method:
- sly.logger.debug('change SDK method')
+ sly.logger.debug("change SDK method")
sly.api.image_api.ImageApi._convert_json_info = ours_convert_json_info
@@ -78,64 +86,84 @@ def download_as_sly(api: sly.Api, task_id, context, state, app_logger):
except Exception as e:
raise Exception(f"Failed to get list of datasets from project ID:{project.id}. {e}")
dataset_ids = [dataset.id for dataset in datasets]
- if mode == 'all':
+ if mode == "all":
download_json_plus_images(api, project, dataset_ids)
else:
download_only_json(api, project, dataset_ids)
- download_dir = os.path.join(my_app.data_dir, f'{project.id}_{project.name}')
- full_archive_name = str(project.id) + '_' + project.name + '.tar'
+ download_dir = os.path.join(my_app.data_dir, f"{project.id}_{project.name}")
+ full_archive_name = str(project.id) + "_" + project.name + ".tar"
result_archive = os.path.join(my_app.data_dir, full_archive_name)
sly.fs.archive_directory(download_dir, result_archive)
app_logger.info("Result directory is archived")
upload_progress = []
remote_archive_path = os.path.join(
- sly.team_files.RECOMMENDED_EXPORT_PATH, "export-to-supervisely-format/{}_{}".format(task_id, full_archive_name))
+ sly.team_files.RECOMMENDED_EXPORT_PATH,
+ "export-to-supervisely-format/{}_{}".format(task_id, full_archive_name),
+ )
def _print_progress(monitor, upload_progress):
if len(upload_progress) == 0:
- upload_progress.append(sly.Progress(message="Upload {!r}".format(full_archive_name),
- total_cnt=monitor.len,
- ext_logger=app_logger,
- is_size=True))
+ upload_progress.append(
+ sly.Progress(
+ message="Upload {!r}".format(full_archive_name),
+ total_cnt=monitor.len,
+ ext_logger=app_logger,
+ is_size=True,
+ )
+ )
upload_progress[0].set_current_value(monitor.bytes_read)
- file_info = api.file.upload(TEAM_ID, result_archive, remote_archive_path,
- lambda m: _print_progress(m, upload_progress))
+ file_info = api.file.upload(
+ TEAM_ID, result_archive, remote_archive_path, lambda m: _print_progress(m, upload_progress)
+ )
app_logger.info("Uploaded to Team-Files: {!r}".format(file_info.path))
- api.task.set_output_archive(task_id, file_info.id, full_archive_name, file_url=file_info.storage_path)
+ api.task.set_output_archive(
+ task_id, file_info.id, full_archive_name, file_url=file_info.storage_path
+ )
my_app.stop()
def download_json_plus_images(api, project, dataset_ids):
- sly.logger.info('DOWNLOAD_PROJECT', extra={'title': project.name})
- download_dir = os.path.join(my_app.data_dir, f'{project.id}_{project.name}')
+ sly.logger.info("DOWNLOAD_PROJECT", extra={"title": project.name})
+ download_dir = os.path.join(my_app.data_dir, f"{project.id}_{project.name}")
if os.path.exists(download_dir):
sly.fs.clean_dir(download_dir)
- sly.download_project(api, project.id, download_dir, dataset_ids=dataset_ids,
- log_progress=True, batch_size=batch_size, save_image_meta=True)
- sly.logger.info('Project {!r} has been successfully downloaded.'.format(project.name))
+ f.download_project(
+ api,
+ project.id,
+ download_dir,
+ dataset_ids=dataset_ids,
+ log_progress=True,
+ batch_size=batch_size,
+ save_image_meta=True,
+ )
+ sly.logger.info("Project {!r} has been successfully downloaded.".format(project.name))
def download_only_json(api, project, dataset_ids):
- sly.logger.info('DOWNLOAD_PROJECT', extra={'title': project.name})
- download_dir = os.path.join(my_app.data_dir, f'{project.id}_{project.name}')
+ sly.logger.info("DOWNLOAD_PROJECT", extra={"title": project.name})
+ download_dir = os.path.join(my_app.data_dir, f"{project.id}_{project.name}")
sly.fs.mkdir(download_dir)
meta_json = api.project.get_meta(project.id)
- sly.io.json.dump_json_file(meta_json, os.path.join(download_dir, 'meta.json'))
+ sly.io.json.dump_json_file(meta_json, os.path.join(download_dir, "meta.json"))
total_images = 0
dataset_info = (
[api.dataset.get_info_by_id(ds_id) for ds_id in dataset_ids]
- if (dataset_ids is not None) else api.dataset.get_list(project.id))
+ if (dataset_ids is not None)
+ else api.dataset.get_list(project.id)
+ )
for dataset in dataset_info:
- ann_dir = os.path.join(download_dir, dataset.name, 'ann')
+ ann_dir = os.path.join(download_dir, dataset.name, "ann")
sly.fs.mkdir(ann_dir)
images = api.image.get_list(dataset.id)
ds_progress = sly.Progress(
- 'Downloading annotations for: {!r}/{!r}'.format(project.name, dataset.name), total_cnt=len(images))
+ "Downloading annotations for: {!r}/{!r}".format(project.name, dataset.name),
+ total_cnt=len(images),
+ )
for batch in sly.batched(images, batch_size=10):
image_ids = [image_info.id for image_info in batch]
image_names = [image_info.name for image_info in batch]
@@ -144,22 +172,24 @@ def download_only_json(api, project, dataset_ids):
ann_infos = api.annotation.download_batch(dataset.id, image_ids)
for image_name, ann_info in zip(image_names, ann_infos):
- sly.io.json.dump_json_file(ann_info.annotation, os.path.join(ann_dir, image_name + '.json'))
+ sly.io.json.dump_json_file(
+ ann_info.annotation, os.path.join(ann_dir, image_name + ".json")
+ )
ds_progress.iters_done_report(len(batch))
total_images += len(batch)
- sly.logger.info('Project {!r} has been successfully downloaded'.format(project.name))
- sly.logger.info('Total number of images: {!r}'.format(total_images))
+ sly.logger.info("Project {!r} has been successfully downloaded".format(project.name))
+ sly.logger.info("Total number of images: {!r}".format(total_images))
def main():
sly.logger.info(
"Script arguments",
extra={
- "TEAM_ID": TEAM_ID,
+ "TEAM_ID": TEAM_ID,
"WORKSPACE_ID": WORKSPACE_ID,
- "PROJECT_ID": PROJECT_ID
- }
+ "PROJECT_ID": PROJECT_ID,
+ },
)
data = {}
diff --git a/src/sly_functions.py b/src/sly_functions.py
new file mode 100644
index 0000000..9212c46
--- /dev/null
+++ b/src/sly_functions.py
@@ -0,0 +1,72 @@
+import os
+import time
+import supervisely as sly
+
+
+def _download_batch_with_retry(api: sly.Api, dataset_id, image_ids):
+ retry_cnt = 5
+ curr_retry = 0
+ while curr_retry <= retry_cnt:
+ try:
+ imgs_bytes = api.image.download_bytes(dataset_id, image_ids)
+ if len(imgs_bytes) != len(image_ids):
+ raise RuntimeError(
+ f"Downloaded {len(imgs_bytes)} images, but {len(image_ids)} expected."
+ )
+ return imgs_bytes
+ except Exception as e:
+ curr_retry += 1
+ if curr_retry <= retry_cnt:
+ time.sleep(2 * curr_retry)
+ sly.logger.warn(
+ f"Failed to download images, retry {curr_retry} of {retry_cnt}... Error: {e}"
+ )
+ raise RuntimeError(
+ f"Failed to download images with ids {image_ids}. Check your data and try again later."
+ )
+
+
+def download_project(api: sly.Api, project_id, dest_dir, dataset_ids=None, log_progress=False, batch_size=10, save_image_meta=True):
+ dataset_ids = set(dataset_ids) if (dataset_ids is not None) else None
+ project_fs = sly.Project(dest_dir, sly.OpenMode.CREATE)
+ meta = sly.ProjectMeta.from_json(api.project.get_meta(project_id))
+ project_fs.set_meta(meta)
+
+ for dataset_info in api.dataset.get_list(project_id):
+ dataset_id = dataset_info.id
+ if dataset_ids is not None and dataset_id not in dataset_ids:
+ continue
+
+ dataset_fs = project_fs.create_dataset(dataset_info.name)
+ images = api.image.get_list(dataset_id)
+
+ if save_image_meta:
+ meta_dir = os.path.join(dest_dir, dataset_info.name, "meta")
+ sly.fs.mkdir(meta_dir)
+ for image_info in images:
+ meta_paths = os.path.join(meta_dir, image_info.name + ".json")
+ sly.json.dump_json_file(image_info.meta, meta_paths)
+
+ ds_progress = None
+ if log_progress:
+ ds_progress = sly.Progress(
+ "Downloading dataset: {!r}".format(dataset_info.name),
+ total_cnt=len(images),
+ )
+
+ for batch in sly.batched(images, batch_size=10):
+ image_ids = [image_info.id for image_info in batch]
+ image_names = [image_info.name for image_info in batch]
+
+ # download images
+ batch_imgs_bytes = _download_batch_with_retry(api, dataset_id, image_ids)
+
+ # download annotations in json format
+ ann_infos = api.annotation.download_batch(dataset_id, image_ids)
+ ann_jsons = [ann_info.annotation for ann_info in ann_infos]
+
+ for name, img_bytes, ann in zip(image_names, batch_imgs_bytes, ann_jsons):
+ dataset_fs.add_item_raw_bytes(item_name=name, item_raw_bytes=img_bytes, ann=ann)
+
+ if log_progress:
+ ds_progress.iters_done_report(len(batch))
From edc46b8515555f286a6bbe47fe03dd885345ccdd Mon Sep 17 00:00:00 2001
From: Almaz <79905215+almazgimaev@users.noreply.github.com>
Date: Fri, 1 Dec 2023 23:44:51 +0100
Subject: [PATCH 3/7] Update logs (#14)
---
config.json | 2 +-
src/sly_functions.py | 49 +++++++++++++++++++++++++++++---------------
2 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/config.json b/config.json
index 1d88d4a..9a480d7 100644
--- a/config.json
+++ b/config.json
@@ -6,7 +6,7 @@
"export"
],
"description": "images and JSON annotations",
- "docker_image": "supervisely/import-export:6.72.206",
+ "docker_image": "supervisely/import-export:6.72.205",
"instance_version": "6.8.48",
"main_script": "src/main.py",
"modal_template": "src/modal.html",
diff --git a/src/sly_functions.py b/src/sly_functions.py
index 9212c46..8f18d40 100644
--- a/src/sly_functions.py
+++ b/src/sly_functions.py
@@ -1,32 +1,47 @@
import os
import time
+
import supervisely as sly
def _download_batch_with_retry(api: sly.Api, dataset_id, image_ids):
retry_cnt = 5
- curr_retry = 0
- while curr_retry <= retry_cnt:
- try:
- imgs_bytes = api.image.download_bytes(dataset_id, image_ids)
- if len(imgs_bytes) != len(image_ids):
- raise RuntimeError(
- f"Downloaded {len(imgs_bytes)} images, but {len(image_ids)} expected."
- )
- return imgs_bytes
- except Exception as e:
- curr_retry += 1
- if curr_retry <= retry_cnt:
+ curr_retry = 1
+ try:
+ imgs_bytes = api.image.download_bytes(dataset_id, image_ids)
+ if len(imgs_bytes) != len(image_ids):
+ raise RuntimeError(
+ f"Downloaded {len(imgs_bytes)} images, but {len(image_ids)} expected."
+ )
+ return imgs_bytes
+ except Exception as e:
+ sly.logger.warn(f"Failed to download images... Error: {e}")
+ while curr_retry <= retry_cnt:
+ try:
+ sly.logger.warn(f"Retry {curr_retry}/{retry_cnt} to download images")
time.sleep(2 * curr_retry)
- sly.logger.warn(
- f"Failed to download images, retry {curr_retry} of {retry_cnt}... Error: {e}"
- )
+ imgs_bytes = api.image.download_bytes(dataset_id, image_ids)
+ if len(imgs_bytes) != len(image_ids):
+ raise RuntimeError(
+ f"Downloaded {len(imgs_bytes)} images, but {len(image_ids)} expected."
+ )
+ return imgs_bytes
+ except Exception as e:
+ curr_retry += 1
raise RuntimeError(
f"Failed to download images with ids {image_ids}. Check your data and try again later."
)
-def download_project(api: sly.Api, project_id, dest_dir, dataset_ids=None, log_progress=False, batch_size=10, save_image_meta=True):
+def download_project(
+ api: sly.Api,
+ project_id,
+ dest_dir,
+ dataset_ids=None,
+ log_progress=True,
+ batch_size=10,
+ save_image_meta=True,
+):
dataset_ids = set(dataset_ids) if (dataset_ids is not None) else None
project_fs = sly.Project(dest_dir, sly.OpenMode.CREATE)
meta = sly.ProjectMeta.from_json(api.project.get_meta(project_id))
@@ -54,7 +69,7 @@ def download_project(api: sly.Api, project_id, dest_dir, dataset_ids=None, log_p
total_cnt=len(images),
)
- for batch in sly.batched(images, batch_size=10):
+ for batch in sly.batched(images, batch_size=batch_size):
image_ids = [image_info.id for image_info in batch]
image_names = [image_info.name for image_info in batch]
From aa4b0d6dcde0b37e132722095753fc60146eb897 Mon Sep 17 00:00:00 2001
From: Ars Vladimirov
Date: Fri, 5 Jan 2024 20:02:02 +0600
Subject: [PATCH 4/7] update dev_reuirements to 6.72.233
---
create_venv.sh | 22 ++++++++++++++++++++++
dev_requirements.txt | 2 +-
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 create_venv.sh
diff --git a/create_venv.sh b/create_venv.sh
new file mode 100644
index 0000000..ba53ea2
--- /dev/null
+++ b/create_venv.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# learn more in documentation
+# Official python docs: https://docs.python.org/3/library/venv.html
+# Superviely developer portal: https://developer.supervise.ly/getting-started/installation#venv
+
+if [ -d ".venv" ]; then
+ echo "VENV already exists, will be removed"
+ rm -rf .venv
+fi
+
+echo "VENV will be created" && \
+python3 -m venv .venv && \
+source .venv/bin/activate && \
+
+echo "Install requirements..." && \
+pip3 install -r dev_requirements.txt && \
+echo "Requirements have been successfully installed" && \
+echo "Testing imports, please wait a minute ..." && \
+python3 -c "import supervisely as sly" && \
+echo "Success!" && \
+deactivate
\ No newline at end of file
diff --git a/dev_requirements.txt b/dev_requirements.txt
index d5cc636..09407bb 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -1 +1 @@
-supervisely==6.72.206
+supervisely==6.72.233
From 20d56cadd5ef6f5cef783edbf57943921d226e37 Mon Sep 17 00:00:00 2001
From: Ars Vladimirov
Date: Fri, 5 Jan 2024 20:04:46 +0600
Subject: [PATCH 5/7] add requirements
---
requirements.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 requirements.txt
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..09407bb
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+supervisely==6.72.233
From 86d7d95041c98b214a7b308542a7844d6e3c02de Mon Sep 17 00:00:00 2001
From: Ars Vladimirov
Date: Fri, 5 Jan 2024 20:17:33 +0600
Subject: [PATCH 6/7] with_settings=True
---
.vscode/settings.json | 4 ++--
src/main.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8ad43f3..adb9109 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,7 +3,7 @@
"**/__pycache__": true,
"build": true,
"supervisely.egg-info": true,
- ".venv": true
+ // ".venv": true
},
"python.defaultInterpreterPath": ".venv/bin/python",
"editor.formatOnSave": true,
@@ -20,7 +20,7 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
- "source.organizeImports": true
+ "source.organizeImports": "explicit"
}
},
"isort.args": ["--profile", "black"],
diff --git a/src/main.py b/src/main.py
index 9543c96..d152900 100644
--- a/src/main.py
+++ b/src/main.py
@@ -145,7 +145,7 @@ def download_only_json(api, project, dataset_ids):
sly.logger.info("DOWNLOAD_PROJECT", extra={"title": project.name})
download_dir = os.path.join(my_app.data_dir, f"{project.id}_{project.name}")
sly.fs.mkdir(download_dir)
- meta_json = api.project.get_meta(project.id)
+ meta_json = api.project.get_meta(project.id, with_settings=True)
sly.io.json.dump_json_file(meta_json, os.path.join(download_dir, "meta.json"))
total_images = 0
From 12a62538de4700fd8f9c0bbb730a5a8ef92db7f8 Mon Sep 17 00:00:00 2001
From: Ars Vladimirov
Date: Fri, 5 Jan 2024 20:36:42 +0600
Subject: [PATCH 7/7] sly_functions.py: add with_settings=True
---
local.env | 8 ++++----
src/sly_functions.py | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/local.env b/local.env
index fd0ab63..e0625e6 100644
--- a/local.env
+++ b/local.env
@@ -1,9 +1,9 @@
PYTHONUNBUFFERED=1
-TASK_ID=50046
+TASK_ID=51612 #50046
-context.teamId=537
-context.workspaceId=1029
-modal.state.slyProjectId=32318
+context.teamId=449 #537
+context.workspaceId=691 #1029
+modal.state.slyProjectId=32796 #32318
modal.state.download=all
modal.state.fixExtension=true
diff --git a/src/sly_functions.py b/src/sly_functions.py
index 8f18d40..dbc8f09 100644
--- a/src/sly_functions.py
+++ b/src/sly_functions.py
@@ -44,7 +44,7 @@ def download_project(
):
dataset_ids = set(dataset_ids) if (dataset_ids is not None) else None
project_fs = sly.Project(dest_dir, sly.OpenMode.CREATE)
- meta = sly.ProjectMeta.from_json(api.project.get_meta(project_id))
+ meta = sly.ProjectMeta.from_json(api.project.get_meta(project_id, with_settings=True))
project_fs.set_meta(meta)
for dataset_info in api.dataset.get_list(project_id):