nebius/SWE-bench-extra huggingface dataset:
Repository: mgxd/etelemetry-client

Issue:
add a timeout variable
when http calls misbehave because of dns or routing, it would be good to return a response within a specific period of time.

Comments:

Patch:
diff --git a/etelemetry/client.py b/etelemetry/client.py
index 04094ba..0f8ff0c 100644
--- a/etelemetry/client.py
+++ b/etelemetry/client.py
@@ -1,18 +1,26 @@
-from requests import request, ConnectionError
+from requests import request, ConnectionError, ReadTimeout
 
 from .config import ET_PROJECTS
 
 
 def _etrequest(endpoint, method="get", **kwargs):
+    if kwargs.get('timeout') is None:
+        kwargs['timeout'] = 5
     try:
         res = request(method, endpoint, **kwargs)
     except ConnectionError:
         raise RuntimeError("Connection to server could not be made")
+    except ReadTimeout:
+        raise RuntimeError(
+            "No response from server in {timeout} seconds".format(
+                timeout=kwargs.get('timeout')
+            )
+        )
     res.raise_for_status()
     return res
 
 
-def get_project(repo):
+def get_project(repo, **rargs):
     """
     Fetch latest version from server.
 
@@ -20,6 +28,8 @@ def get_project(repo):
     ==========
     repo : str
         GitHub repository as <owner>/<project>
+    **rargs
+        Request keyword arguments
 
     Returns
     =======
@@ -28,5 +38,5 @@ def get_project(repo):
     """
     if "/" not in repo:
         raise ValueError("Invalid repository")
-    res = _etrequest(ET_PROJECTS + repo)
+    res = _etrequest(ET_PROJECTS.format(repo=repo), **rargs)
     return res.json(encoding="utf-8")
diff --git a/etelemetry/config/__init__.py b/etelemetry/config/__init__.py
index 0e1f954..1f2a1a1 100644
--- a/etelemetry/config/__init__.py
+++ b/etelemetry/config/__init__.py
@@ -1,12 +1,13 @@
-hostname = "rig.mit.edu/"
+hostname = "rig.mit.edu"
 https = True
 
 if https is True:
-    ET_ROOT = "https://" + hostname
+    prefix = "https"
 else:
-    ET_ROOT = "http://" + hostname
+    prefix = "http"
 
-root_endpoint = "et/"
-ET_ROOT += root_endpoint
+ET_ROOT = "{prefix}://{hostname}/et/".format(
+    prefix=prefix, hostname=hostname
+)
 
-ET_PROJECTS = ET_ROOT + "projects/"
+ET_PROJECTS = ET_ROOT + "projects/{repo}"


Test patch:
diff --git a/etelemetry/tests/test_client.py b/etelemetry/tests/test_client.py
index f2368d4..9bf1790 100644
--- a/etelemetry/tests/test_client.py
+++ b/etelemetry/tests/test_client.py
@@ -4,11 +4,16 @@ from ..config import ET_ROOT
 from ..client import _etrequest, get_project
 
 
-def test_request():
+def test_etrequest():
     endpoint = "http://fakeendpoint/"
-    with pytest.raises(Exception):
+    with pytest.raises(RuntimeError):
         _etrequest(endpoint, method="get")
     assert _etrequest(ET_ROOT)
+    # ensure timeout is working properly
+    endpoint = "https://google.com"
+    with pytest.raises(RuntimeError):
+        _etrequest(endpoint, timeout=0.01)
+    assert _etrequest(endpoint)
 
 
 def test_get_project():