Skip to content

Commit

Permalink
Set proper connection & read timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalBielickiIM committed Mar 20, 2024
1 parent 8c042ab commit 92c158d
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 238 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update -y && \

ENV LANG C.UTF-8

RUN pip install poetry
RUN pip install poetry==1.8.2

COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false && poetry install -n --no-root
Expand Down
2 changes: 1 addition & 1 deletion basemodels/manifest/data/groundtruth.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TLMSSGroundTruthEntry(BaseModel):
def validate_content_type(uri: str) -> None:
"""Validate uri content type"""
try:
response = requests.head(uri)
response = requests.head(uri, timeout=(3.5, 5))
response.raise_for_status()
except RequestException as e:
raise ValidationError(f"groundtruth content type ({uri}) validation failed", GroundtruthEntryKeyModel) from e
Expand Down
2 changes: 1 addition & 1 deletion basemodels/manifest/data/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExampleResourceModel(BaseModel):

def validate_content_type(uri: str) -> None:
"""Validate uri content type"""
response = requests.head(uri)
response = requests.head(uri, timeout=(3.5, 5))
response.raise_for_status()
content_type = response.headers.get("Content-Type", "")
if content_type not in SUPPORTED_CONTENT_TYPES:
Expand Down
2 changes: 1 addition & 1 deletion basemodels/manifest/data/taskdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def validate_datapoint_text(cls, values):
def validate_content_type(uri: str) -> None:
"""Validate uri content type"""
try:
response = requests.head(uri)
response = requests.head(uri, timeout=(3.5, 5))
response.raise_for_status()
except RequestException as e:
raise ValidationError(
Expand Down
4 changes: 2 additions & 2 deletions basemodels/manifest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def validate_groundtruth_uri(manifest: dict):
if uri is None:
return
try:
response = requests.get(uri, timeout=1)
response = requests.get(uri, timeout=(3.5, 5))
response.raise_for_status()

entries_count = 0
Expand Down Expand Up @@ -467,7 +467,7 @@ def validate_taskdata_uri(manifest: dict):
if uri is None:
return
try:
response = requests.get(uri, timeout=1)
response = requests.get(uri, timeout=(3.5, 5))
response.raise_for_status()

entries_count = 0
Expand Down
455 changes: 225 additions & 230 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hmt-basemodels"
version = "0.2.8"
version = "0.2.9"
description = ""
authors = ["Intuition Machines, Inc <support@hcaptcha.com>"]
packages = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="hmt-basemodels",
version="0.2.8",
version="0.2.9",
author="HUMAN Protocol",
description="Common data models shared by various components of the Human Protocol stack",
url="https://github.com/hCaptcha/hmt-basemodels",
Expand Down

0 comments on commit 92c158d

Please sign in to comment.