Skip to content

Commit 2e823e5

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Added verify_ssl
1 parent 7724005 commit 2e823e5

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/superannotate/lib/core/usecases.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,25 +4509,25 @@ def __init__(
45094509
def execute(self) -> Response:
45104510

45114511
if self._folder.name == "root" and not self._image_names:
4512-
poll_id = self._backend_service.delete_image_annotations(
4512+
response = self._backend_service.delete_image_annotations(
45134513
project_id=self._project.uuid, team_id=self._project.team_id,
45144514
)
45154515
else:
4516-
poll_id = self._backend_service.delete_image_annotations(
4516+
response = self._backend_service.delete_image_annotations(
45174517
project_id=self._project.uuid,
45184518
team_id=self._project.team_id,
45194519
folder_id=self._folder.uuid,
45204520
image_names=self._image_names,
45214521
)
45224522

4523-
if poll_id:
4523+
if response:
45244524
timeout_start = time.time()
45254525
while time.time() < timeout_start + self.POLL_AWAIT_TIME:
45264526
progress = int(
45274527
self._backend_service.get_annotations_delete_progress(
45284528
project_id=self._project.uuid,
45294529
team_id=self._project.team_id,
4530-
poll_id=poll_id,
4530+
poll_id=response.get("poll_id"),
45314531
).get("process", -1)
45324532
)
45334533
if 0 < progress < 100:
@@ -4543,7 +4543,6 @@ def execute(self) -> Response:
45434543
return self._response
45444544

45454545

4546-
45474546
class GetDuplicateImages(BaseUseCase):
45484547
def __init__(self,
45494548
service: SuerannotateServiceProvider,

src/superannotate/lib/infrastructure/controller.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ def __init__(self, logger, config_path=constances.CONFIG_FILE_LOCATION):
5353
self.configs.insert(ConfigEntity("token", ""))
5454
logger.warning("Fill config.json")
5555
return
56+
verify_ssl_entity = self.configs.get_one("ssl_verify")
57+
if not verify_ssl_entity:
58+
verify_ssl = True
59+
else:
60+
verify_ssl = verify_ssl_entity.value
5661
self._backend_client = SuperannotateBackendService(
5762
api_url=self.configs.get_one("main_endpoint").value,
5863
auth_token=ConfigRepository().get_one("token").value,
5964
logger=logger,
65+
verify_ssl=verify_ssl
6066
)
6167
self._s3_upload_auth_data = None
6268
self._projects = None

src/superannotate/lib/infrastructure/services.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from contextlib import contextmanager
23
from datetime import datetime
34
from typing import Dict
@@ -26,11 +27,12 @@ class BaseBackendService(SuerannotateServiceProvider):
2627
Base service class
2728
"""
2829

29-
def __init__(self, api_url: str, auth_token: str, logger, paginate_by=None):
30+
def __init__(self, api_url: str, auth_token: str, logger, paginate_by=None, verify_ssl=True):
3031
self.api_url = api_url
3132
self._auth_token = auth_token
3233
self.logger = logger
3334
self._paginate_by = paginate_by
35+
self._verify_ssl = verify_ssl
3436
self.team_id = auth_token.split("=")[-1]
3537

3638
@timed_lru_cache(seconds=360)
@@ -82,7 +84,7 @@ def _request(
8284
with self.safe_api():
8385
req = requests.Request(method=method, url=url, **kwargs, params=params)
8486
prepared = session.prepare_request(req)
85-
response = session.send(request=prepared)
87+
response = session.send(request=prepared, verify=self._verify_ssl)
8688
if response.status_code == 404 and retried < 3:
8789
return self._request(
8890
url,
@@ -966,7 +968,7 @@ def delete_image_annotations(
966968
delete_annotations_url, "post", params=params, data=data
967969
)
968970
if response.ok:
969-
return response.json()["poll_id"]
971+
return response.json()
970972

971973
def get_annotations_delete_progress(
972974
self, team_id: int, project_id: int, poll_id: int

tests/integration/test_annotation_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class TestAnnotationDelete(BaseTestCase):
10-
PROJECT_NAME_ = "TestAnnotationDelete"
10+
PROJECT_NAME = "TestAnnotationDelete"
1111
PROJECT_DESCRIPTION = "desc"
1212
PROJECT_TYPE = "Vector"
1313
TEST_FOLDER_PATH = "data_set/sample_project_vector_single_image"

0 commit comments

Comments
 (0)