Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: 'https://github.com/asottile/reorder_python_imports'
rev: v3.13.0
rev: v3.16.0
hooks:
- id: reorder-python-imports
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
Expand All @@ -9,12 +9,12 @@ repos:
- '--application-directories'
- app
- repo: 'https://github.com/python/black'
rev: 22.3.0
rev: 26.1.0
hooks:
- id: black
name: Code Formatter (black)
- repo: 'https://github.com/PyCQA/flake8'
rev: 6.1.0
rev: 7.3.0
hooks:
- id: flake8
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
Expand All @@ -23,15 +23,15 @@ repos:
- '--max-line-length=120'
- --ignore=D100,D203,D405,W503,E203,E501,F841,E126,E712,E123,E131,F821,E121,W605,E402
- repo: 'https://github.com/asottile/pyupgrade'
rev: v2.4.3
rev: v3.21.2
hooks:
- id: pyupgrade
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
name: Upgrade syntax for newer versions of the language (pyupgrade)
args:
- '--py37-plus'
- repo: 'https://github.com/PyCQA/doc8'
rev: v1.1.1
rev: v2.0.0
hooks:
- id: doc8
name: doc8
Expand Down
Empty file added log.txt
Empty file.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ minversion = 3.7
log_cli=true
python_files = test_*.py
;pytest_plugins = ['pytest_profiling']
addopts = -n 6 --dist loadscope
;addopts = -n 6 --dist loadscope
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pydantic>=1.10,<3,!=2.0.*
pydantic~=2.5
pydantic-extra-types~=2.11
aiohttp~=3.8
boto3~=1.42
opencv-python-headless~=4.7
Expand All @@ -10,4 +11,5 @@ requests~=2.32
aiofiles~=25.1
fire~=0.7
mixpanel~=5.1
typing_extensions~=4.15
superannotate-schemas==1.0.49
2 changes: 0 additions & 2 deletions src/superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import sys


__version__ = "4.5.2"


Expand All @@ -22,7 +21,6 @@
from superannotate.lib.app.interface.sdk_interface import SAClient
from superannotate.lib.app.interface.sdk_interface import ItemContext


SESSIONS = {}


Expand Down
1 change: 0 additions & 1 deletion src/superannotate/lib/app/analytics/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import plotly.express as px
from lib.core.exceptions import AppException


logger = logging.getLogger("sa")


Expand Down
4 changes: 2 additions & 2 deletions src/superannotate/lib/app/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def blue_color_generator(n, hex_values=True):
)
hex_color = (
"#"
+ "{:02x}".format(bgr_color[2])
+ f"{bgr_color[2]:02x}"
+ "{:02x}".format(
bgr_color[1],
)
+ "{:02x}".format(bgr_color[0])
+ f"{bgr_color[0]:02x}"
)
if hex_values:
hex_colors.append(hex_color)
Expand Down
1 change: 0 additions & 1 deletion src/superannotate/lib/app/input_converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from lib.app.input_converters.conversion import export_annotation
from lib.app.input_converters.conversion import import_annotation


__all__ = [
"export_annotation",
"import_annotation",
Expand Down
4 changes: 2 additions & 2 deletions src/superannotate/lib/app/input_converters/conversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Main module for input converters
"""

import os
import shutil
import tempfile
Expand All @@ -15,7 +16,6 @@
from .export_from_sa_conversions import export_from_sa
from .import_to_sa_conversions import import_to_sa


ALLOWED_TASK_TYPES = [
"panoptic_segmentation",
"instance_segmentation",
Expand Down Expand Up @@ -108,7 +108,7 @@ def _passes_value_sanity(values_info):
for value in values_info:
if value[0] not in value[2]:
raise AppException(
"'{}' should be one of the following '{}'".format(value[1], value[2])
f"'{value[1]}' should be one of the following '{value[2]}'"
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

import logging

from .coco_converters.coco_to_sa_vector import coco_instance_segmentation_to_sa_vector
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

import json
import logging
from collections import namedtuple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

import logging
import threading
from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
COCO to SA conversion method
"""

import logging

from .coco_api import _maskfrRLE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
COCO to SA conversion methods
"""

import json
import logging
import threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
SA to COCO conversion methods
"""

import logging
import threading

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
said strategy.

"""

from .coco_converters.coco_strategies import CocoKeypointDetectionStrategy
from .coco_converters.coco_strategies import CocoObjectDetectionStrategy
from .coco_converters.coco_strategies import CocoPanopticConverterStrategy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

import numpy as np

from ....common import write_to_json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Dataloop to SA conversion method
"""

import json
import logging
import threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Googlecloud to SA conversion method
"""

import logging
import threading
from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging


logger = logging.getLogger("sa")


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Labelbox to SA conversion method
"""

import logging
import threading

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Sagemaker to SA conversion method
"""

import json
import logging
import threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Supervisely to SA conversion method
"""

import json
import logging
import threading
Expand Down Expand Up @@ -92,9 +93,11 @@ def supervisely_to_sa(json_files, class_id_map, task, output_dir):
elif obj["geometryType"] == "bitmap":
for ppoints in _base64_to_polygon(obj["bitmap"]["data"]):
points = [
x + obj["bitmap"]["origin"][0]
if i % 2 == 0
else x + obj["bitmap"]["origin"][1]
(
x + obj["bitmap"]["origin"][0]
if i % 2 == 0
else x + obj["bitmap"]["origin"][1]
)
for i, x in enumerate(ppoints)
]
instance_type = "polygon"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
VGG to SA conversion method.
"""

import json
import logging
import threading
Expand Down Expand Up @@ -59,10 +60,8 @@ def vgg_to_sa(json_data, task, output_dir):
instances = img["regions"]
for instance in instances:
if "type" not in instance["region_attributes"].keys():
raise KeyError(
"'VGG' JSON should contain 'type' key which will \
be category name. Please correct JSON file."
)
raise KeyError("'VGG' JSON should contain 'type' key which will \
be category name. Please correct JSON file.")
if not isinstance(instance["region_attributes"]["type"], str):
raise ValueError("Wrong attribute was choosen for 'type' attribute.")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
VOC to SA conversion method
"""

import logging

import cv2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
VOC to SA conversion method
"""

import logging
import threading

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
VoTT to SA conversion method
"""

import json
import logging
import threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

import numpy as np

from ....common import write_to_json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
YOLO to SA conversion method
"""

import logging
import threading
from glob import glob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Module which will convert from
superannotate annotation format to other annotation formats
"""

import copy
import json
import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Module which will convert from other
annotation formats to superannotate annotation format
"""

import logging
import shutil
from pathlib import Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import shutil


logger = logging.getLogger("sa")


Expand Down
13 changes: 6 additions & 7 deletions src/superannotate/lib/app/interface/base_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pathlib import Path
from types import FunctionType
from typing import Iterable
from typing import Optional
from typing import Sized

import lib.core as constants
Expand All @@ -18,19 +19,20 @@
from lib.core.entities.base import ConfigEntity
from lib.core.entities.base import TokenStr
from lib.core.exceptions import AppException
from lib.core.pydantic_v1 import ErrorWrapper
from lib.core.pydantic_v1 import ValidationError
from lib.infrastructure.controller import Controller
from lib.infrastructure.utils import extract_project_folder_inputs
from lib.infrastructure.validators import wrap_error
from mixpanel import Mixpanel
from pydantic import ValidationError


class BaseInterfaceFacade:
REGISTRY = []

@validate_arguments
def __init__(self, token: TokenStr = None, config_path: str = None):
def __init__(
self, token: Optional[TokenStr] = None, config_path: Optional[str] = None
):
try:
if token:
config = ConfigEntity(SA_TOKEN=token)
Expand Down Expand Up @@ -80,10 +82,7 @@ def _retrieve_configs_from_json(path: Path) -> typing.Union[ConfigEntity]:
try:
config = ConfigEntity(SA_TOKEN=token)
except ValidationError:
raise ValidationError(
[ErrorWrapper(ValueError("Invalid token."), loc="token")],
model=ConfigEntity,
)
raise AppException("Invalid token.")
host = json_data.get("main_endpoint")
verify_ssl = json_data.get("ssl_verify")
if host:
Expand Down
Loading