Skip to content
Snippets Groups Projects
Commit 862ee6ce authored by Eva Bardou's avatar Eva Bardou :frog: Committed by Yoann Schneider
Browse files

Use tools from `teklia-toolbox` package + Skip SSL verification for local development hosts

parent dee133f1
No related branches found
No related tags found
1 merge request!512Use tools from `teklia-toolbox` package + Skip SSL verification for local development hosts
Pipeline #164969 passed
......@@ -21,6 +21,7 @@ from tenacity import (
)
from arkindex_worker import logger
from teklia_toolbox.requests import should_verify_cert
# Avoid circular imports error when type checking
if TYPE_CHECKING:
......@@ -175,7 +176,9 @@ def _retry_log(retry_state, *args, **kwargs):
reraise=True,
)
def _retried_request(url, *args, method=requests.get, **kwargs):
resp = method(url, *args, timeout=DOWNLOAD_TIMEOUT, **kwargs)
resp = method(
url, *args, timeout=DOWNLOAD_TIMEOUT, verify=should_verify_cert(url), **kwargs
)
resp.raise_for_status()
return resp
......
......@@ -21,7 +21,6 @@ from tenacity import (
wait_exponential,
)
from arkindex import ArkindexClient, options_from_env
from arkindex_worker import logger
from arkindex_worker.cache import (
check_version,
......@@ -31,18 +30,7 @@ from arkindex_worker.cache import (
merge_parents_cache,
)
from arkindex_worker.utils import close_delete_file, extract_tar_zst_archive
def _is_500_error(exc: Exception) -> bool:
"""
Check if an Arkindex API error has a HTTP 5xx error code.
Used to retry most API calls in [BaseWorker][arkindex_worker.worker.base.BaseWorker].
:param exc: Exception to check
"""
if not isinstance(exc, ErrorResponse):
return False
return 500 <= exc.status_code < 600
from teklia_toolbox.requests import _get_arkindex_client, _is_500_error
class ExtrasDirNotFoundError(Exception):
......@@ -197,7 +185,7 @@ class BaseWorker:
Create an ArkindexClient to make API requests towards Arkindex instances.
"""
# Build Arkindex API client from environment variables
self.api_client = ArkindexClient(**options_from_env())
self.api_client = _get_arkindex_client()
logger.debug(f"Setup Arkindex API client on {self.api_client.document.url}")
def configure_for_developers(self):
......
......@@ -75,7 +75,7 @@ select = [
"arkindex_worker/**/*.py" = ["PT018"]
[tool.ruff.lint.isort]
known-first-party = ["arkindex", "arkindex_common", "arkindex_worker"]
known-first-party = ["arkindex", "arkindex_common", "arkindex_worker", "teklia_toolbox"]
known-third-party = [
"PIL",
"apistar",
......
arkindex-client==1.0.15
peewee==3.17.0
Pillow==10.2.0
pymdown-extensions==10.7
python-gnupg==0.5.2
shapely==2.0.3
tenacity==8.2.3
teklia-toolbox==0.1.4rc3
zstandard==0.22.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment