Skip to content

About

Rest API sync with the EXACT Server https://github.com/ChristianMarzahl/Exact

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Latest commit

 

History

86 Commits

Folders and files

Repository files navigation

EXACT-Sync

PyPI version fury.io MIT license

Rest API sync with the EXACT Server https://github.com/ChristianMarzahl/Exact

Browsable-API

Example Notebooks

In the folder examples

Pip

pip install EXACT-Sync

Tests

with a lot of implementation examples /exact_sync/v1/test

Basic features:

Connect to server

configuration = Configuration()
configuration.username = 'exact'
configuration.password = 'exact'
configuration.host = "http://127.0.0.1:8000"

client = ApiClient(configuration)

image_sets_api = ImageSetsApi(client)
annotations_api = AnnotationsApi(client)
annotation_types_api = AnnotationTypesApi(client)
images_api = ImagesApi(client)
product_api = ProductsApi(client)
team_api = TeamsApi(client)

Authentication by token:

configuration = Configuration()
configuration.token = 'pat_....<your token here>'
configuration.host = "http://127.0.0.1:8000"

client = ApiClient(configuration)
image_sets_api = ImageSetsApi(client)

Get image set information

image_sets = image_sets_api.list_image_sets(name="cluster_asthma_imageset")
image_sets

Upload image to image set

image_type = int(Image.ImageSourceTypes.DEFAULT)
image = images_api.create_image(file_path=target_file, image_type=image_type, image_set=image_set.id).results[0]
Donwload image from image set
images_api.download_image(id=image_id, target_path=image_path, original_image=True)

Download image annotations

annotations_api.list_annotations(pagination=False, async_req=True, image=image.id)

Get a snapshot centered on a coordinate

snapshot = images_api.get_snapshot(image_source=image.id, x=1000, y=1000, size_x=512, size_y=512)
snapshot.save('snapshot.png')

Move an image to another image set

Moves the image with its files and annotations, like "Move image" in the web UI. The target image set must offer all annotation types used on the image, otherwise the server refuses the move and an ApiException with the reason is raised.

targets = images_api.list_move_targets()  # [{'id': 3, 'name': 'Set B', 'team': 'Team'}, ...]
result = images_api.move_image(id=image.id, target_imageset_id=targets[0]['id'])
# {'id': image.id, 'image_set': targets[0]['id']}

Automatic retries on gateway errors

All API objects retry requests that fail with a transient gateway error (HTTP 502, 503 or 504) using exponential backoff (0.5s, 1s, 2s, ... up to 5 attempts). Retrying is enabled by default and works for synchronous and async_req=True calls.

images_api = ImagesApi(client)                 # retries enabled (default)
images_api = ImagesApi(client, retry=False)    # retries disabled
images_api.retry = False                       # or toggle later

# optional tuning, per instance or per class
images_api.retry_max_attempts = 3
images_api.retry_backoff = 1.0
images_api.retry_statuses = (502,)

Note: non-idempotent requests (e.g. create_*) are retried as well, so in rare cases a request that the server already processed could be executed twice.

About

Rest API sync with the EXACT Server https://github.com/ChristianMarzahl/Exact

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages