def test_basic_auth(): try: sa.init(Path("tests") / "config__wrong.json") except sa.SABaseException as e: assert e.message == 'Couldn\'t authorize {"error":"Not authorized."}' else: assert False sa.init(Path.home() / ".superannotate" / "config.json")
def sa_upload_image_folder_files( project_name: str, source: str, conf_path: str = "./config.json", ): sa.init(conf_path) uploaded, skipped, duplicate = sa.upload_images_from_folder_to_project( project=project_name, folder_path=source, recursive_subfolders=True)
def sa_download_files( project_name: str, destination: str = "./downloads", conf_path: object = "./config.json", ): sa.init(conf_path) export = sa.prepare_export(project_name, include_fuse=True) sa.download_export(project=project_name, export=export, folder_path=destination)
from pathlib import Path import json import pytest import superannotate as sa from .common import upload_project sa.init(Path.home() / ".superannotate" / "config.json") PROJECT_NAME = "test export import" PROJECT_FOLDER = Path("./tests/sample_project_vector") def test_basic_export(tmpdir): tmpdir = Path(tmpdir) project = upload_project(PROJECT_FOLDER, PROJECT_NAME, 't', 'Vector', annotation_status='InProgress') # projects_found = sa.search_projects(PROJECT_NAME, return_metadata=True) # for pr in projects_found: # sa.delete_project(pr) # project = sa.create_project(PROJECT_NAME, "t", "Vector") # sa.upload_images_from_folder_to_project( # project, PROJECT_FOLDER, annotation_status="InProgress" # )
import concurrent.futures from pathlib import Path import superannotate as sa sa.init("./b_config.json") project = "Project " images = sa.search_images(project, annotation_status="NotStarted") download_dir = Path("/home/hovnatan/b_work") already_downloaded = list(download_dir.glob("*___objects.json")) with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: i = 0 futures = [] for image in images: if download_dir / (image + "___objects.json") in already_downloaded: print("Ommitting ", image) continue futures.append( executor.submit(sa.download_image_preannotations, project, image, download_dir)) for future in concurrent.futures.as_completed(futures): i += 1 print(i, future.result()) sa.upload_annotations_from_folder_to_project(project, download_dir)
import sys import superannotate as sa try: sa.init(sys.argv[1]) except sa.SABaseException as e: if e.message == "Couldn't authorize": print("Couldn't authorize.") sys.exit(1) else: print("Authorized.")