synapse-sdk 1.0.0a35__tar.gz → 1.0.0a37__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of synapse-sdk might be problematic. Click here for more details.
- {synapse_sdk-1.0.0a35/synapse_sdk.egg-info → synapse_sdk-1.0.0a37}/PKG-INFO +1 -1
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/agent/core.py +4 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/actions/export.py +67 -2
- synapse_sdk-1.0.0a37/synapse_sdk/plugins/categories/export/enums.py +7 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/templates/plugin/export.py +23 -5
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/templates/config.yaml +10 -2
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/actions/upload.py +136 -39
- synapse_sdk-1.0.0a37/synapse_sdk/utils/dataset.py +46 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/__init__.py +30 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/providers/__init__.py +30 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/providers/s3.py +35 -0
- synapse_sdk-1.0.0a37/synapse_sdk/utils/storage/providers/sftp.py +47 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37/synapse_sdk.egg-info}/PKG-INFO +1 -1
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk.egg-info/SOURCES.txt +2 -0
- synapse_sdk-1.0.0a35/synapse_sdk/utils/storage/providers/sftp.py +0 -16
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/.github/workflows/lint.yml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/.github/workflows/pypi-publish.yml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/.gitignore +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/.pre-commit-config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/LICENSE +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/README.md +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/locale/en/LC_MESSAGES/messages.mo +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/locale/en/LC_MESSAGES/messages.po +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/locale/ko/LC_MESSAGES/messages.mo +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/locale/ko/LC_MESSAGES/messages.po +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/pyproject.toml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/requirements.test.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/requirements.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/setup.cfg +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/create.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/dataclass.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/default.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/delete.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/list.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/read.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/update.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/alias/utils.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/plugin/create.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/plugin/publish.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/cli/plugin/run.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/agent/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/agent/ray.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/agent/service.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/annotation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/core.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/dataset.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/hitl.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/integration.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/ml.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/backend/models.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/base.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/exceptions.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/ray/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/ray/core.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/ray/serve.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/utils.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/validators/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/clients/validators/collections.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/i18n.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/loggers.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/base.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/actions/validation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/data_validation/templates/plugin/validation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/decorators.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/export/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/actions/deployment.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/actions/inference.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/actions/test.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/actions/train.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/base/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/base/inference.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/templates/plugin/inference.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/templates/plugin/test.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/neural_net/templates/plugin/train.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/actions/post_annotation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/post_annotation/templates/plugin/post_annotation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/actions/pre_annotation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/pre_annotation/templates/plugin/pre_annotation.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/registry.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/actions/auto_label.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/smart_tool/templates/plugin/auto_label.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/templates.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/actions/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/templates/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/templates/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/categories/upload/templates/plugin/upload.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/enums.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/exceptions.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/models.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/cookiecutter.json +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/hooks/post_gen_project.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/hooks/pre_prompt.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.gitignore +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/.pre-commit-config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/README.md +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/config.yaml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/plugin/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/pyproject.toml +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/templates/synapse-{{cookiecutter.plugin_code}}-plugin/requirements.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/upload.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/plugins/utils.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/shared/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/shared/enums.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/types.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/debug.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/file.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/module_loading.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/network.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/pydantic/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/pydantic/config.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/pydantic/errors.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/pydantic/validators.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/providers/gcp.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/registry.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/string.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk.egg-info/dependency_links.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk.egg-info/entry_points.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk.egg-info/requires.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk.egg-info/top_level.txt +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/clients/__init__.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/clients/test_backend_models.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/clients/test_base_client.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/clients/test_collection_validators.py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/utils/__init__,py +0 -0
- {synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/tests/utils/test_debug.py +0 -0
|
@@ -1,17 +1,77 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from abc import ABC, abstractmethod
|
|
2
|
-
from
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Annotated, Any, Literal
|
|
3
5
|
|
|
4
|
-
from pydantic import BaseModel, field_validator
|
|
6
|
+
from pydantic import AfterValidator, BaseModel, field_validator
|
|
5
7
|
from pydantic_core import PydanticCustomError
|
|
6
8
|
|
|
7
9
|
from synapse_sdk.clients.exceptions import ClientError
|
|
8
10
|
from synapse_sdk.i18n import gettext as _
|
|
9
11
|
from synapse_sdk.plugins.categories.base import Action
|
|
10
12
|
from synapse_sdk.plugins.categories.decorators import register_action
|
|
13
|
+
from synapse_sdk.plugins.categories.export.enums import ExportStatus
|
|
11
14
|
from synapse_sdk.plugins.enums import PluginCategory, RunMethod
|
|
15
|
+
from synapse_sdk.plugins.models import Run
|
|
16
|
+
from synapse_sdk.utils.pydantic.validators import non_blank
|
|
12
17
|
from synapse_sdk.utils.storage import get_pathlib
|
|
13
18
|
|
|
14
19
|
|
|
20
|
+
class ExportRun(Run):
|
|
21
|
+
class DataFileLog(BaseModel):
|
|
22
|
+
"""Data file log model."""
|
|
23
|
+
|
|
24
|
+
target_id: int
|
|
25
|
+
data_file_info: str | None
|
|
26
|
+
status: ExportStatus
|
|
27
|
+
error: str | None = None
|
|
28
|
+
created: str
|
|
29
|
+
|
|
30
|
+
def log_file(
|
|
31
|
+
self, log_type: str, target_id: int, data_file_info: dict, status: ExportStatus, error: str | None = None
|
|
32
|
+
):
|
|
33
|
+
"""Log export file information.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
log_type (str): The type of log ('export_data_file' or 'export_origin_file').
|
|
37
|
+
target_id (int): The ID of the data file.
|
|
38
|
+
data_file_info (dict): The JSON info of the data file.
|
|
39
|
+
status (ExportStatus): The status of the data file.
|
|
40
|
+
error (str | None): The error message, if any.
|
|
41
|
+
"""
|
|
42
|
+
now = datetime.now().isoformat()
|
|
43
|
+
self.log(
|
|
44
|
+
log_type,
|
|
45
|
+
self.DataFileLog(
|
|
46
|
+
target_id=target_id,
|
|
47
|
+
data_file_info=json.dumps(data_file_info),
|
|
48
|
+
status=status.value,
|
|
49
|
+
error=error,
|
|
50
|
+
created=now,
|
|
51
|
+
).model_dump(),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def export_log_json_file(
|
|
55
|
+
self,
|
|
56
|
+
target_id: int,
|
|
57
|
+
data_file_info: dict,
|
|
58
|
+
status: ExportStatus = ExportStatus.STAND_BY,
|
|
59
|
+
error: str | None = None,
|
|
60
|
+
):
|
|
61
|
+
"""Log export json data file."""
|
|
62
|
+
self.log_file('export_data_file', target_id, data_file_info, status, error)
|
|
63
|
+
|
|
64
|
+
def export_log_original_file(
|
|
65
|
+
self,
|
|
66
|
+
target_id: int,
|
|
67
|
+
data_file_info: dict,
|
|
68
|
+
status: ExportStatus = ExportStatus.STAND_BY,
|
|
69
|
+
error: str | None = None,
|
|
70
|
+
):
|
|
71
|
+
"""Log export origin data file."""
|
|
72
|
+
self.log_file('export_origin_file', target_id, data_file_info, status, error)
|
|
73
|
+
|
|
74
|
+
|
|
15
75
|
class ExportTargetHandler(ABC):
|
|
16
76
|
"""
|
|
17
77
|
Abstract base class for handling export targets.
|
|
@@ -153,6 +213,8 @@ class ExportParams(BaseModel):
|
|
|
153
213
|
Parameters for the export action.
|
|
154
214
|
|
|
155
215
|
Attributes:
|
|
216
|
+
name (str): The name of the action.
|
|
217
|
+
description (str | None): The description of the action.
|
|
156
218
|
storage (int): The storage ID to save the exported data.
|
|
157
219
|
save_original_file (bool): Whether to save the original file.
|
|
158
220
|
path (str): The path to save the exported data.
|
|
@@ -160,6 +222,8 @@ class ExportParams(BaseModel):
|
|
|
160
222
|
filter (dict): The filter criteria to apply.
|
|
161
223
|
"""
|
|
162
224
|
|
|
225
|
+
name: Annotated[str, AfterValidator(non_blank)]
|
|
226
|
+
description: str | None = None
|
|
163
227
|
storage: int
|
|
164
228
|
save_original_file: bool = True
|
|
165
229
|
path: str
|
|
@@ -193,6 +257,7 @@ class ExportAction(Action):
|
|
|
193
257
|
category = PluginCategory.EXPORT
|
|
194
258
|
method = RunMethod.JOB
|
|
195
259
|
params_model = ExportParams
|
|
260
|
+
run_class = ExportRun
|
|
196
261
|
progress_categories = {
|
|
197
262
|
'dataset_conversion': {
|
|
198
263
|
'proportion': 100,
|
|
@@ -3,6 +3,8 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
import requests
|
|
5
5
|
|
|
6
|
+
from synapse_sdk.plugins.categories.export.enums import ExportStatus
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
def export(run, export_items, path_root, **params):
|
|
8
10
|
"""Executes the export task.
|
|
@@ -54,12 +56,12 @@ def export(run, export_items, path_root, **params):
|
|
|
54
56
|
if save_original_file_flag:
|
|
55
57
|
if no == 1:
|
|
56
58
|
run.log_message('Saving original file.')
|
|
57
|
-
save_original_file(final_data, origin_files_output_path, errors_original_file_list)
|
|
59
|
+
save_original_file(run, final_data, origin_files_output_path, errors_original_file_list)
|
|
58
60
|
|
|
59
61
|
# Extract data as JSON files
|
|
60
62
|
if no == 1:
|
|
61
63
|
run.log_message('Saving json file.')
|
|
62
|
-
save_as_json(final_data, json_output_path, errors_json_file_list)
|
|
64
|
+
save_as_json(run, final_data, json_output_path, errors_json_file_list)
|
|
63
65
|
|
|
64
66
|
run.end_log()
|
|
65
67
|
|
|
@@ -100,10 +102,11 @@ def get_original_file_pathlib(files):
|
|
|
100
102
|
return Path(files['meta']['path_original'])
|
|
101
103
|
|
|
102
104
|
|
|
103
|
-
def save_original_file(result, base_path, error_file_list):
|
|
105
|
+
def save_original_file(run, result, base_path, error_file_list):
|
|
104
106
|
"""Saves the original file.
|
|
105
107
|
|
|
106
108
|
Args:
|
|
109
|
+
run : Execution object
|
|
107
110
|
result (dict): API response data containing file information.
|
|
108
111
|
base_path (Path): The directory where the file will be saved.
|
|
109
112
|
error_file_list (list): A list to store error files.
|
|
@@ -111,17 +114,25 @@ def save_original_file(result, base_path, error_file_list):
|
|
|
111
114
|
file_url = result['files']['url']
|
|
112
115
|
file_name = get_original_file_pathlib(result['files']).name
|
|
113
116
|
response = requests.get(file_url)
|
|
117
|
+
file_info = {'file_name': file_name}
|
|
118
|
+
error_msg = ''
|
|
114
119
|
try:
|
|
115
120
|
with (base_path / file_name).open('wb') as file:
|
|
116
121
|
file.write(response.content)
|
|
122
|
+
status = ExportStatus.SUCCESS
|
|
117
123
|
except Exception as e:
|
|
118
|
-
|
|
124
|
+
error_msg = str(e)
|
|
125
|
+
error_file_list.append([file_name, error_msg])
|
|
126
|
+
status = ExportStatus.FAILED
|
|
127
|
+
|
|
128
|
+
run.export_log_original_file(result['id'], file_info, status, error_msg)
|
|
119
129
|
|
|
120
130
|
|
|
121
|
-
def save_as_json(result, base_path, error_file_list):
|
|
131
|
+
def save_as_json(run, result, base_path, error_file_list):
|
|
122
132
|
"""Saves the data as a JSON file.
|
|
123
133
|
|
|
124
134
|
Args:
|
|
135
|
+
run : Execution object
|
|
125
136
|
result (dict): API response data containing file information.
|
|
126
137
|
base_path (Path): The directory where the file will be saved.
|
|
127
138
|
error_file_list (list): A list to store error files.
|
|
@@ -129,8 +140,15 @@ def save_as_json(result, base_path, error_file_list):
|
|
|
129
140
|
# Default save file name: original file name
|
|
130
141
|
file_name = get_original_file_pathlib(result['files']).stem
|
|
131
142
|
json_data = result['data']
|
|
143
|
+
file_info = {'file_name': file_name}
|
|
144
|
+
error_msg = ''
|
|
132
145
|
try:
|
|
133
146
|
with (base_path / f'{file_name}.json').open('w', encoding='utf-8') as f:
|
|
134
147
|
json.dump(json_data, f, indent=4, ensure_ascii=False)
|
|
148
|
+
status = ExportStatus.SUCCESS
|
|
135
149
|
except Exception as e:
|
|
150
|
+
error_msg = str(e)
|
|
136
151
|
error_file_list.append([f'{file_name}.json', str(e)])
|
|
152
|
+
status = ExportStatus.FAILED
|
|
153
|
+
|
|
154
|
+
run.export_log_json_file(result['id'], file_info, status, error_msg)
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
name: plugin_name
|
|
2
|
+
code: plugin_code
|
|
3
|
+
version: plugin_version
|
|
4
|
+
readme: README.md
|
|
5
|
+
description: This is plugin_name plugin
|
|
6
|
+
category: neural_net
|
|
7
|
+
tasks:
|
|
8
|
+
- object_detection
|
|
2
9
|
data_type: image
|
|
10
|
+
package_manager: uv
|
|
3
11
|
actions:
|
|
4
12
|
train:
|
|
5
13
|
dataset: dataset
|
|
@@ -18,4 +26,4 @@ actions:
|
|
|
18
26
|
endpoints:
|
|
19
27
|
- method: get
|
|
20
28
|
test:
|
|
21
|
-
entrypoint: plugin.test.test
|
|
29
|
+
entrypoint: plugin.test.test
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from enum import Enum
|
|
1
4
|
from typing import Annotated, Dict, List
|
|
2
5
|
|
|
3
6
|
from pydantic import AfterValidator, BaseModel, field_validator
|
|
@@ -16,8 +19,69 @@ from synapse_sdk.utils.pydantic.validators import non_blank
|
|
|
16
19
|
from synapse_sdk.utils.storage import get_pathlib
|
|
17
20
|
|
|
18
21
|
|
|
22
|
+
class UploadStatus(str, Enum):
|
|
23
|
+
SUCCESS = 'success'
|
|
24
|
+
FAILED = 'failed'
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
class UploadRun(Run):
|
|
20
|
-
|
|
28
|
+
class DataFileLog(BaseModel):
|
|
29
|
+
"""Data file log model."""
|
|
30
|
+
|
|
31
|
+
data_file_info: str | None
|
|
32
|
+
status: UploadStatus
|
|
33
|
+
created: str
|
|
34
|
+
|
|
35
|
+
class DataUnitLog(BaseModel):
|
|
36
|
+
"""Data unit log model."""
|
|
37
|
+
|
|
38
|
+
data_unit_id: int | None
|
|
39
|
+
status: UploadStatus
|
|
40
|
+
created: str
|
|
41
|
+
|
|
42
|
+
class TaskLog(BaseModel):
|
|
43
|
+
"""Task log model."""
|
|
44
|
+
|
|
45
|
+
task_id: int | None
|
|
46
|
+
status: UploadStatus
|
|
47
|
+
created: str
|
|
48
|
+
|
|
49
|
+
def log_data_file(self, data_file_info: dict, status: UploadStatus):
|
|
50
|
+
"""Upload data_file log.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
data_file_info (dict): The json info of the data file.
|
|
54
|
+
checksum (str): The checksum of the data file.
|
|
55
|
+
status (DataUnitStatus): The status of the data unit.
|
|
56
|
+
"""
|
|
57
|
+
now = datetime.now().isoformat()
|
|
58
|
+
self.log(
|
|
59
|
+
'upload_data_file',
|
|
60
|
+
self.DataFileLog(data_file_info=json.dumps(data_file_info), status=status.value, created=now).model_dump(),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def log_data_unit(self, data_unit_id: int, status: UploadStatus):
|
|
64
|
+
"""Upload data_unit log.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
data_unit_id (int): The ID of the data unit.
|
|
68
|
+
status (DataUnitStatus): The status of the data unit.
|
|
69
|
+
"""
|
|
70
|
+
now = datetime.now().isoformat()
|
|
71
|
+
self.log(
|
|
72
|
+
'upload_data_unit',
|
|
73
|
+
self.DataUnitLog(data_unit_id=data_unit_id, status=status.value, created=now).model_dump(),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def log_task(self, task_id: int, status: UploadStatus):
|
|
77
|
+
"""Upload task log.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
task_id (int): The ID of the task.
|
|
81
|
+
status (UploadStatus): The status of the task.
|
|
82
|
+
"""
|
|
83
|
+
now = datetime.now().isoformat()
|
|
84
|
+
self.log('upload_task', self.TaskLog(task_id=task_id, status=status.value, created=now).model_dump())
|
|
21
85
|
|
|
22
86
|
|
|
23
87
|
class UploadParams(BaseModel):
|
|
@@ -108,6 +172,7 @@ class UploadAction(Action):
|
|
|
108
172
|
name = 'upload'
|
|
109
173
|
category = PluginCategory.UPLOAD
|
|
110
174
|
method = RunMethod.JOB
|
|
175
|
+
run_class = UploadRun
|
|
111
176
|
progress_categories = {
|
|
112
177
|
'analyze_collection': {
|
|
113
178
|
'proportion': 5,
|
|
@@ -144,9 +209,7 @@ class UploadAction(Action):
|
|
|
144
209
|
uploader = self.get_uploader(pathlib_cwd)
|
|
145
210
|
|
|
146
211
|
# Analyze Collection file specifications to determine the data structure for upload.
|
|
147
|
-
self.run.set_progress(0, 1, category='analyze_collection')
|
|
148
212
|
file_specification_template = self._analyze_collection()
|
|
149
|
-
self.run.set_progress(1, 1, category='analyze_collection')
|
|
150
213
|
|
|
151
214
|
# Setup result dict.
|
|
152
215
|
result = {}
|
|
@@ -162,49 +225,35 @@ class UploadAction(Action):
|
|
|
162
225
|
if not organized_files_count:
|
|
163
226
|
self.run.log_message('Files not found on the path.', context=Context.WARNING.value)
|
|
164
227
|
return result
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
self.run.log_message('Uploading data files...')
|
|
168
|
-
result['uploaded_files'] = self._upload_files(organized_files)
|
|
169
|
-
self.run.set_progress(organized_files_count, organized_files_count, category='upload_data_files')
|
|
170
|
-
self.run.log_message('Upload data files completed.')
|
|
228
|
+
uploaded_files = self._upload_files(organized_files, organized_files_count)
|
|
229
|
+
result['uploaded_files_count'] = len(uploaded_files)
|
|
171
230
|
|
|
172
231
|
# Generate data units for the uploaded data.
|
|
173
|
-
upload_result_count = len(
|
|
232
|
+
upload_result_count = len(uploaded_files)
|
|
174
233
|
if not upload_result_count:
|
|
175
234
|
self.run.log_message('No files were uploaded.', context=Context.WARNING.value)
|
|
176
235
|
return result
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
generated_data_units = self._generate_data_units(result['uploaded_files'])
|
|
180
|
-
result['generated_data_units'] = generated_data_units
|
|
181
|
-
self.run.set_progress(upload_result_count, upload_result_count, category='generate_data_units')
|
|
236
|
+
generated_data_units = self._generate_data_units(uploaded_files, upload_result_count)
|
|
237
|
+
result['generated_data_units_count'] = len(generated_data_units)
|
|
182
238
|
|
|
183
239
|
# Setup task with uploaded synapse-backend data units.
|
|
184
240
|
if not len(generated_data_units):
|
|
185
241
|
self.run.log_message('No data units were generated.', context=Context.WARNING.value)
|
|
186
242
|
return result
|
|
187
243
|
|
|
188
|
-
self.run.set_progress(0, 1, category='generate_tasks')
|
|
189
244
|
if self.config['options']['allow_generate_tasks'] and self.params['is_generate_tasks']:
|
|
190
|
-
self.
|
|
191
|
-
|
|
192
|
-
self.run.log_message('Generating tasks completed')
|
|
245
|
+
generated_tasks = self._generate_tasks(generated_data_units)
|
|
246
|
+
result['generated_tasks_count'] = len(generated_tasks)
|
|
193
247
|
else:
|
|
194
248
|
self.run.log_message('Generating tasks process has passed.')
|
|
195
249
|
|
|
196
|
-
self.run.set_progress(1, 1, category='generate_tasks')
|
|
197
|
-
|
|
198
250
|
# Generate ground truths for the uploaded data.
|
|
199
251
|
# TODO: Need to add ground truths generation logic later.
|
|
200
|
-
self.run.set_progress(0, 1, category='generate_ground_truths')
|
|
201
252
|
if self.config['options']['allow_generate_ground_truths'] and self.params['is_generate_ground_truths']:
|
|
202
|
-
self.
|
|
203
|
-
|
|
204
|
-
self.run.log_message('Generating ground truths completed')
|
|
253
|
+
generated_ground_truths = self._generate_ground_truths()
|
|
254
|
+
result['generated_ground_truths_count'] = len(generated_ground_truths)
|
|
205
255
|
else:
|
|
206
256
|
self.run.log_message('Generating ground truths process has passed.')
|
|
207
|
-
self.run.set_progress(1, 1, category='generate_ground_truths')
|
|
208
257
|
|
|
209
258
|
return result
|
|
210
259
|
|
|
@@ -214,9 +263,17 @@ class UploadAction(Action):
|
|
|
214
263
|
Returns:
|
|
215
264
|
Dict: The file specifications of the collection.
|
|
216
265
|
"""
|
|
266
|
+
|
|
267
|
+
# Initialize progress
|
|
268
|
+
self.run.set_progress(0, 1, category='analyze_collection')
|
|
269
|
+
|
|
217
270
|
client = self.run.client
|
|
218
271
|
collection_id = self.params['collection']
|
|
219
272
|
collection = client.get_dataset(collection_id)
|
|
273
|
+
|
|
274
|
+
# Finish progress
|
|
275
|
+
self.run.set_progress(1, 1, category='analyze_collection')
|
|
276
|
+
|
|
220
277
|
return collection['file_specifications']
|
|
221
278
|
|
|
222
279
|
def _validate_organized_files(self, file_specification_template: Dict, organized_files: List) -> bool:
|
|
@@ -224,24 +281,35 @@ class UploadAction(Action):
|
|
|
224
281
|
validator = FileSpecificationValidator(file_specification_template, organized_files)
|
|
225
282
|
return validator.validate()
|
|
226
283
|
|
|
227
|
-
def _upload_files(self, organized_files) -> List:
|
|
284
|
+
def _upload_files(self, organized_files, organized_files_count: int) -> List:
|
|
228
285
|
"""Upload files to synapse-backend.
|
|
229
286
|
|
|
230
287
|
Returns:
|
|
231
288
|
Dict: The result of the upload.
|
|
232
289
|
"""
|
|
290
|
+
# Initialize progress
|
|
291
|
+
self.run.set_progress(0, organized_files_count, category='upload_data_files')
|
|
292
|
+
self.run.log_message('Uploading data files...')
|
|
293
|
+
|
|
233
294
|
client = self.run.client
|
|
234
295
|
collection_id = self.params['collection']
|
|
235
296
|
upload_result = []
|
|
236
297
|
organized_files_count = len(organized_files)
|
|
237
298
|
current_progress = 0
|
|
238
299
|
for organized_file in organized_files:
|
|
239
|
-
|
|
300
|
+
uploaded_data_file = client.upload_data_file(organized_file, collection_id)
|
|
301
|
+
self.run.log_data_file(organized_file, UploadStatus.SUCCESS)
|
|
302
|
+
upload_result.append(uploaded_data_file)
|
|
240
303
|
self.run.set_progress(current_progress, organized_files_count, category='upload_data_files')
|
|
241
304
|
current_progress += 1
|
|
305
|
+
|
|
306
|
+
# Finish progress
|
|
307
|
+
self.run.set_progress(organized_files_count, organized_files_count, category='upload_data_files')
|
|
308
|
+
self.run.log_message('Upload data files completed.')
|
|
309
|
+
|
|
242
310
|
return upload_result
|
|
243
311
|
|
|
244
|
-
def _generate_data_units(self, uploaded_files: List) -> List:
|
|
312
|
+
def _generate_data_units(self, uploaded_files: List, upload_result_count: int) -> List:
|
|
245
313
|
"""Generate data units for the uploaded data.
|
|
246
314
|
|
|
247
315
|
TODO: make batch size configurable.
|
|
@@ -249,23 +317,36 @@ class UploadAction(Action):
|
|
|
249
317
|
Returns:
|
|
250
318
|
Dict: The result of the generate data units process.
|
|
251
319
|
"""
|
|
320
|
+
# Initialize progress
|
|
321
|
+
self.run.set_progress(0, upload_result_count, category='generate_data_units')
|
|
322
|
+
|
|
252
323
|
client = self.run.client
|
|
253
324
|
|
|
254
|
-
|
|
325
|
+
generated_data_units = []
|
|
255
326
|
current_progress = 0
|
|
256
327
|
batches = get_batched_list(uploaded_files, 100)
|
|
257
328
|
batches_count = len(batches)
|
|
258
329
|
for batch in batches:
|
|
259
|
-
|
|
330
|
+
created_data_units = client.create_data_units(batch)
|
|
331
|
+
generated_data_units.append(created_data_units)
|
|
260
332
|
self.run.set_progress(current_progress, batches_count, category='generate_data_units')
|
|
261
333
|
current_progress += 1
|
|
262
|
-
|
|
334
|
+
for created_data_unit in created_data_units:
|
|
335
|
+
self.run.log_data_unit(created_data_unit['id'], UploadStatus.SUCCESS)
|
|
336
|
+
|
|
337
|
+
# Finish progress
|
|
338
|
+
self.run.set_progress(upload_result_count, upload_result_count, category='generate_data_units')
|
|
263
339
|
|
|
264
|
-
|
|
340
|
+
return sum(generated_data_units, [])
|
|
341
|
+
|
|
342
|
+
def _generate_tasks(self, generated_data_units: List) -> List:
|
|
265
343
|
"""Setup task with uploaded synapse-backend data units.
|
|
266
344
|
|
|
267
345
|
TODO: make batch size configurable.
|
|
268
346
|
"""
|
|
347
|
+
# Initialize progress
|
|
348
|
+
self.run.set_progress(0, 1, category='generate_tasks')
|
|
349
|
+
self.run.log_message('Generating tasks with data files...')
|
|
269
350
|
|
|
270
351
|
# Prepare batches for processing
|
|
271
352
|
client = self.run.client
|
|
@@ -273,21 +354,37 @@ class UploadAction(Action):
|
|
|
273
354
|
current_progress = 0
|
|
274
355
|
|
|
275
356
|
# Generate tasks
|
|
357
|
+
generated_tasks = []
|
|
276
358
|
generated_data_units_count = len(generated_data_units)
|
|
277
|
-
for
|
|
359
|
+
for data_unit in generated_data_units:
|
|
278
360
|
tasks_data = []
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
tasks_data.append(task_data)
|
|
282
|
-
|
|
361
|
+
task_data = {'project': project_id, 'data_unit': data_unit['id']}
|
|
362
|
+
tasks_data.append(task_data)
|
|
283
363
|
if tasks_data:
|
|
284
|
-
client.create_tasks(tasks_data)
|
|
364
|
+
created_tasks = client.create_tasks(tasks_data)
|
|
365
|
+
created_task_ids = [created_task['id'] for created_task in created_tasks]
|
|
366
|
+
generated_tasks.append(created_task_ids)
|
|
367
|
+
for created_task_id in created_task_ids:
|
|
368
|
+
self.run.log_task(created_task_id, UploadStatus.SUCCESS)
|
|
285
369
|
|
|
286
370
|
self.run.set_progress(current_progress, generated_data_units_count, category='generate_tasks')
|
|
287
371
|
current_progress += 1
|
|
288
372
|
|
|
373
|
+
# Finish progress
|
|
374
|
+
self.run.log_message('Generating tasks completed')
|
|
375
|
+
self.run.set_progress(1, 1, category='generate_tasks')
|
|
376
|
+
|
|
377
|
+
return sum(generated_tasks, [])
|
|
378
|
+
|
|
289
379
|
def _generate_ground_truths(self):
|
|
290
380
|
"""Generate ground truths for the uploaded data.
|
|
291
381
|
|
|
292
382
|
TODO: Need to add ground truths generation logic later.
|
|
293
383
|
"""
|
|
384
|
+
# Initialize progress
|
|
385
|
+
self.run.set_progress(0, 1, category='generate_ground_truths')
|
|
386
|
+
self.run.log_message('Generating ground truths...')
|
|
387
|
+
|
|
388
|
+
# Finish progress
|
|
389
|
+
self.run.log_message('Generating ground truths completed')
|
|
390
|
+
self.run.set_progress(1, 1, category='generate_ground_truths')
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def remap_class_labels(dataset, data_type, class_pattern, new_class):
|
|
5
|
+
"""
|
|
6
|
+
Remaps class labels in a dataset by replacing specific classification patterns.
|
|
7
|
+
|
|
8
|
+
This function finds items of a specified data type (e.g., 'pcd', 'image', 'video')
|
|
9
|
+
where the classification matches a given pattern (e.g., 'truck', 'car'), and
|
|
10
|
+
remaps them to a new class label (e.g., 'vehicle'). Useful for consolidating
|
|
11
|
+
or standardizing class labels in ground truth data.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
dataset (dict): The dataset containing ground truth labels
|
|
15
|
+
data_type (str): Type of data to process (e.g., 'pcd', 'image', 'video')
|
|
16
|
+
class_pattern (dict): Pattern to identify target classifications (e.g., {'name': 'truck'})
|
|
17
|
+
new_class (dict): New classification to apply (e.g., {'name': 'vehicle'})
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
dict: Dataset with remapped class labels
|
|
21
|
+
"""
|
|
22
|
+
updated_dataset = dataset.copy()
|
|
23
|
+
|
|
24
|
+
if data_type not in updated_dataset:
|
|
25
|
+
logging.log(logging.WARNING, f"Data type '{data_type}' not found in dataset.")
|
|
26
|
+
return updated_dataset
|
|
27
|
+
|
|
28
|
+
def matches_pattern(classification, pattern):
|
|
29
|
+
"""Check if a classification matches the specified pattern."""
|
|
30
|
+
for key, pattern_value in pattern.items():
|
|
31
|
+
if key not in classification:
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
if isinstance(pattern_value, dict) and isinstance(classification[key], dict):
|
|
35
|
+
if not matches_pattern(classification[key], pattern_value):
|
|
36
|
+
return False
|
|
37
|
+
elif classification[key] != pattern_value:
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
for item in updated_dataset[data_type]:
|
|
43
|
+
if 'classification' in item and matches_pattern(item['classification'], class_pattern):
|
|
44
|
+
item['classification'] = new_class.copy()
|
|
45
|
+
|
|
46
|
+
return updated_dataset
|
|
@@ -36,3 +36,33 @@ def get_pathlib(storage_config: str | dict, path_root: str) -> Path:
|
|
|
36
36
|
"""
|
|
37
37
|
storage_class = get_storage(storage_config)
|
|
38
38
|
return storage_class.get_pathlib(path_root)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_path_file_count(storage_config: str | dict, path_root: str) -> int:
|
|
42
|
+
"""Get the file count in the path.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
storage_config (str | dict): The storage config by synapse-backend storage api.
|
|
46
|
+
path (str): The path.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
int: The file count in the path.
|
|
50
|
+
"""
|
|
51
|
+
storage_class = get_storage(storage_config)
|
|
52
|
+
pathlib_obj = storage_class.get_pathlib(path_root)
|
|
53
|
+
return storage_class.get_path_file_count(pathlib_obj)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def get_path_total_size(storage_config: str | dict, path_root: str) -> int:
|
|
57
|
+
"""Get total size of the files in the path.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
storage_config (str | dict): The storage config by synapse-backend storage api.
|
|
61
|
+
path (str): The path.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
int: The total size of the files in the path.
|
|
65
|
+
"""
|
|
66
|
+
storage_class = get_storage(storage_config)
|
|
67
|
+
pathlib_obj = storage_class.get_pathlib(path_root)
|
|
68
|
+
return storage_class.get_path_total_size(pathlib_obj)
|
{synapse_sdk-1.0.0a35 → synapse_sdk-1.0.0a37}/synapse_sdk/utils/storage/providers/__init__.py
RENAMED
|
@@ -39,4 +39,34 @@ class BaseStorage:
|
|
|
39
39
|
raise NotImplementedError
|
|
40
40
|
|
|
41
41
|
def get_pathlib(self, path):
|
|
42
|
+
"""Get the path as a pathlib object.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
path (str): The path to convert.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
pathlib.Path: The converted path.
|
|
49
|
+
"""
|
|
50
|
+
raise NotImplementedError
|
|
51
|
+
|
|
52
|
+
def get_path_file_count(self, pathlib_obj):
|
|
53
|
+
"""Get the file count in the path.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
pathlib_obj (UPath): The path to get file count.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
int: The file count in the path.
|
|
60
|
+
"""
|
|
61
|
+
raise NotImplementedError
|
|
62
|
+
|
|
63
|
+
def get_path_total_size(self, pathlib_obj):
|
|
64
|
+
"""Get the total size of the path.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
pathlib_obj (UPath): The path to get total size.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
int: The total size of the path.
|
|
71
|
+
"""
|
|
42
72
|
raise NotImplementedError
|
|
@@ -41,3 +41,38 @@ class S3Storage(BaseStorage):
|
|
|
41
41
|
|
|
42
42
|
def get_pathlib(self, path):
|
|
43
43
|
return self.upath.joinuri(path)
|
|
44
|
+
|
|
45
|
+
def get_path_file_count(self, pathlib_obj: UPath):
|
|
46
|
+
"""Get file count in the path from S3 provider.
|
|
47
|
+
|
|
48
|
+
TODO: Need to find a method to get file count using S3 API
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
pathlib_obj (UPath): The path to get file count.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
int: The file count in the path.
|
|
55
|
+
"""
|
|
56
|
+
count = 0
|
|
57
|
+
files = list(pathlib_obj.glob('**/*'))
|
|
58
|
+
for file in files:
|
|
59
|
+
if file.is_file():
|
|
60
|
+
count += 1
|
|
61
|
+
return count
|
|
62
|
+
|
|
63
|
+
def get_path_total_size(self, pathlib_obj: UPath):
|
|
64
|
+
"""Get total size of the files in the path from S3 provider.
|
|
65
|
+
|
|
66
|
+
TODO: Need to find a method to get total file size using S3 API
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
pathlib_obj (UPath): The path to get total size.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
int: The total size of the files in the path.
|
|
73
|
+
"""
|
|
74
|
+
total_size = 0
|
|
75
|
+
for file in pathlib_obj.glob('**/*'):
|
|
76
|
+
if file.is_file():
|
|
77
|
+
total_size += file.stat().st_size
|
|
78
|
+
return total_size
|