From fbb29a8d3e005ffcca77d3479293cfede6ba2673 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Tue, 21 Nov 2023 15:59:33 +0100 Subject: [PATCH] increase timeout to 20 s --- dsp_permissions_scripts/ap/ap_delete.py | 2 +- dsp_permissions_scripts/ap/ap_get.py | 2 +- dsp_permissions_scripts/ap/ap_set.py | 2 +- dsp_permissions_scripts/doap/doap_get.py | 2 +- dsp_permissions_scripts/doap/doap_set.py | 2 +- dsp_permissions_scripts/oap/oap_get.py | 2 +- dsp_permissions_scripts/oap/oap_set.py | 4 ++-- dsp_permissions_scripts/utils/authentication.py | 2 +- dsp_permissions_scripts/utils/project.py | 6 +++--- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dsp_permissions_scripts/ap/ap_delete.py b/dsp_permissions_scripts/ap/ap_delete.py index 6e8b8afc..61d6cddd 100644 --- a/dsp_permissions_scripts/ap/ap_delete.py +++ b/dsp_permissions_scripts/ap/ap_delete.py @@ -22,7 +22,7 @@ def _delete_ap_on_server( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/{ap_iri}" response = http_call_with_retry( - action=lambda: requests.delete(url, headers=headers, timeout=10), + action=lambda: requests.delete(url, headers=headers, timeout=20), err_msg=f"Could not delete Administrative Permission {ap.iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/ap/ap_get.py b/dsp_permissions_scripts/ap/ap_get.py index b897f08f..4f17b884 100644 --- a/dsp_permissions_scripts/ap/ap_get.py +++ b/dsp_permissions_scripts/ap/ap_get.py @@ -48,7 +48,7 @@ def _get_all_aps_of_project( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/ap/{project_iri}" response = http_call_with_retry( - action=lambda: requests.get(url, headers=headers, timeout=10), + action=lambda: requests.get(url, headers=headers, timeout=20), err_msg=f"Could not get APs of project {project_iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/ap/ap_set.py b/dsp_permissions_scripts/ap/ap_set.py index 4b8577b7..bbe6b210 100644 --- a/dsp_permissions_scripts/ap/ap_set.py +++ b/dsp_permissions_scripts/ap/ap_set.py @@ -28,7 +28,7 @@ def _update_ap_on_server( url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_ap(ap)["hasPermissions"]} response = http_call_with_retry( - action=lambda: requests.put(url, headers=headers, json=payload, timeout=10), + action=lambda: requests.put(url, headers=headers, json=payload, timeout=20), err_msg=f"Could not update Administrative Permission {ap.iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/doap/doap_get.py b/dsp_permissions_scripts/doap/doap_get.py index 7eae28ce..e73cdfd4 100644 --- a/dsp_permissions_scripts/doap/doap_get.py +++ b/dsp_permissions_scripts/doap/doap_get.py @@ -46,7 +46,7 @@ def _get_all_doaps_of_project( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/doap/{project_iri}" response = http_call_with_retry( - action=lambda: requests.get(url, headers=headers, timeout=10), + action=lambda: requests.get(url, headers=headers, timeout=20), err_msg=f"Error while getting DOAPs of project {project_iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/doap/doap_set.py b/dsp_permissions_scripts/doap/doap_set.py index be9918af..07cc8c60 100644 --- a/dsp_permissions_scripts/doap/doap_set.py +++ b/dsp_permissions_scripts/doap/doap_set.py @@ -29,7 +29,7 @@ def _update_doap_scope_on_server( url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_scope(scope)} response = http_call_with_retry( - action=lambda: requests.put(url, headers=headers, json=payload, timeout=10), + action=lambda: requests.put(url, headers=headers, json=payload, timeout=20), err_msg=f"Could not update scope of DOAP {doap_iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/oap/oap_get.py b/dsp_permissions_scripts/oap/oap_get.py index 239751c5..22d504ce 100644 --- a/dsp_permissions_scripts/oap/oap_get.py +++ b/dsp_permissions_scripts/oap/oap_get.py @@ -104,7 +104,7 @@ def get_resource( url = f"{protocol}://{host}/v2/resources/{iri}" headers = {"Authorization": f"Bearer {token}"} response = http_call_with_retry( - action=lambda: requests.get(url, headers=headers, timeout=10), + action=lambda: requests.get(url, headers=headers, timeout=20), err_msg=f"Error while getting resource {resource_iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/oap/oap_set.py b/dsp_permissions_scripts/oap/oap_set.py index 123a1ff0..35c1e5dd 100644 --- a/dsp_permissions_scripts/oap/oap_set.py +++ b/dsp_permissions_scripts/oap/oap_set.py @@ -61,7 +61,7 @@ def _update_permissions_for_value( url = f"{protocol}://{host}/v2/values" headers = {"Authorization": f"Bearer {token}"} response = http_call_with_retry( - action=lambda: requests.put(url, headers=headers, json=payload, timeout=10), + action=lambda: requests.put(url, headers=headers, json=payload, timeout=20), err_msg=f"Error while updating permissions of resource {resource_iri}, value {value.value_iri}", ) if response.status_code == 400 and response.text: @@ -102,7 +102,7 @@ def _update_permissions_for_resource( url = f"{protocol}://{host}/v2/resources" headers = {"Authorization": f"Bearer {token}"} response = http_call_with_retry( - action=lambda: requests.put(url, headers=headers, json=payload, timeout=10), + action=lambda: requests.put(url, headers=headers, json=payload, timeout=20), err_msg=f"ERROR while updating permissions of resource {resource_iri}", ) if response.status_code != 200: diff --git a/dsp_permissions_scripts/utils/authentication.py b/dsp_permissions_scripts/utils/authentication.py index 82b985ec..fc0a2e97 100644 --- a/dsp_permissions_scripts/utils/authentication.py +++ b/dsp_permissions_scripts/utils/authentication.py @@ -9,7 +9,7 @@ def _get_token(host: str, email: str, pw: str) -> str: """Requests an access token from DSP-API""" protocol = get_protocol(host) url = f"{protocol}://{host}/v2/authentication" - response = requests.post(url, json={"email": email, "password": pw}, timeout=10) + response = requests.post(url, json={"email": email, "password": pw}, timeout=20) if response.status_code != 200: raise ApiError("Could not login", response.text, response.status_code) token: str = response.json()["token"] diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index 8efddfb7..9df8ebd6 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -20,7 +20,7 @@ def _get_onto_iris_of_project( url = f"{protocol}://{host}/v2/ontologies/metadata" headers = {"Authorization": f"Bearer {token}"} response = http_call_with_retry( - action=lambda: requests.get(url, headers=headers, timeout=10), + action=lambda: requests.get(url, headers=headers, timeout=20), err_msg="Could not get onto IRIs", ) if response.status_code != 200: @@ -39,7 +39,7 @@ def _get_class_iris_of_onto( url = f"{protocol}://{host}/v2/ontologies/allentities/{quote_plus(onto_iri)}" headers = {"Authorization": f"Bearer {token}"} response = http_call_with_retry( - action=lambda: requests.get(url, headers=headers, timeout=10), + action=lambda: requests.get(url, headers=headers, timeout=20), err_msg="Could not get class IRIs", ) if response.status_code != 200: @@ -78,7 +78,7 @@ def get_project_iri_by_shortcode(shortcode: str, host: str) -> str: protocol = get_protocol(host) url = f"{protocol}://{host}/admin/projects/shortcode/{shortcode}" response = http_call_with_retry( - action=lambda: requests.get(url, timeout=10), + action=lambda: requests.get(url, timeout=20), err_msg="Cannot retrieve project IRI", ) if response.status_code != 200: