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
25 changes: 25 additions & 0 deletions src/superannotate/lib/app/interface/sdk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,31 @@ def upload_annotations(
"skipped": []
}

Example Usage with JSONL Upload:
::
import json
from pathlib import Path
from superannotate import SAClient

# Assuming annotations are stored in JSONL format
annotations_path = Path("annotations.jsonl")
annotations = []

# Reading the JSONL file and converting it into a list of dictionaries
with annotations_path.open("r", encoding="utf-8") as f:
for line in f:
annotations.append(json.loads(line))

# Initialize the Superannotate client
sa = SAClient()

# Call the upload_annotations function
response = client.upload_annotations(
project="project1/folder1",
annotations=annotations,
keep_status=True
)

"""
if keep_status is not None:
warnings.warn(
Expand Down
1 change: 1 addition & 0 deletions src/superannotate/lib/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def setup_logging(level=DEFAULT_LOGGING_LEVEL, file_path=LOG_FILE_LOCATION):
"Tokenization",
"ImageAutoAssignEnable",
"TemplateState",
"CategorizeItems",
]

__alL__ = (
Expand Down
2 changes: 2 additions & 0 deletions src/superannotate/lib/core/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from lib.core.entities.items import TiledEntity
from lib.core.entities.items import VideoEntity
from lib.core.entities.project import AttachmentEntity
from lib.core.entities.project import CategoryEntity
from lib.core.entities.project import ContributorEntity
from lib.core.entities.project import ProjectEntity
from lib.core.entities.project import SettingEntity
Expand Down Expand Up @@ -41,6 +42,7 @@
# project
"ProjectEntity",
"WorkflowEntity",
"CategoryEntity",
"ContributorEntity",
"ConfigEntity",
"StepEntity",
Expand Down
5 changes: 5 additions & 0 deletions src/superannotate/lib/core/entities/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ def is_system(self):

class Config:
extra = Extra.ignore


class CategoryEntity(BaseModel):
id: Optional[int]
name: Optional[str]
4 changes: 4 additions & 0 deletions src/superannotate/lib/core/service_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ class ProjectResponse(ServiceResponse):
res_data: entities.ProjectEntity = None


class ListCategoryResponse(ServiceResponse):
res_data: List[entities.CategoryEntity] = None


class WorkflowResponse(ServiceResponse):
res_data: entities.WorkflowEntity = None

Expand Down
17 changes: 17 additions & 0 deletions src/superannotate/lib/core/serviceproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from lib.core.service_types import FolderListResponse
from lib.core.service_types import FolderResponse
from lib.core.service_types import IntegrationListResponse
from lib.core.service_types import ListCategoryResponse
from lib.core.service_types import ProjectListResponse
from lib.core.service_types import ProjectResponse
from lib.core.service_types import ServiceResponse
Expand Down Expand Up @@ -87,6 +88,16 @@ def list_workflow_statuses(self, project_id: int, workflow_id: int):
def list_workflow_roles(self, project_id: int, workflow_id: int):
raise NotImplementedError

@abstractmethod
def list_project_categories(self, project_id: int) -> ListCategoryResponse:
raise NotImplementedError

@abstractmethod
def create_project_categories(
self, project_id: int, categories: List[str]
) -> ServiceResponse:
raise NotImplementedError


class BaseProjectService(SuperannotateServiceProvider):
@abstractmethod
Expand Down Expand Up @@ -350,6 +361,12 @@ def delete_multiple(
) -> ServiceResponse:
raise NotImplementedError

@abstractmethod
def bulk_attach_categories(
self, project_id: int, folder_id: int, item_category_map: Dict[int, int]
) -> bool:
raise NotImplementedError


class BaseAnnotationService(SuperannotateServiceProvider):
@abstractmethod
Expand Down
Loading