datalab-api 0.6.0__tar.gz → 0.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: A Python API for instances of the datalab data management platform (https://github.com/datalab-org/datalab).
5
5
  Author-email: Matthew Evans <matthew@ml-evs.science>
6
6
  License-Expression: MIT
@@ -71,12 +71,18 @@ documentation = "https://datalab-python-api.readthedocs.io"
71
71
  changelog = "https://github.com/datalab-org/datalab-api/releases"
72
72
 
73
73
  [tool.uv]
74
+ required-version = ">=0.9.8" # first release supporting exclude-dependencies; also used by setup-uv in CI
75
+ exclude-dependencies = ["httpx", "httpcore"]
74
76
  cache-keys = [{ git = true }]
75
77
 
76
78
  [tool.versioningit.vcs]
77
79
  method = "git"
78
80
  default-tag = "0.0.1"
79
81
 
82
+ [tool.pytest.ini_options]
83
+ # respx's plugin imports httpx at startup, before conftest can alias it to httpx2
84
+ addopts = "-p no:respx"
85
+
80
86
  [tool.mypy]
81
87
  # plugins = "pydantic.mypy"
82
88
  ignore_missing_imports = true
@@ -5,7 +5,7 @@ from collections.abc import Iterable
5
5
  from pathlib import Path
6
6
  from typing import TYPE_CHECKING, Any, Optional, Union
7
7
 
8
- import httpx
8
+ import httpx2
9
9
 
10
10
  from ._base import BaseDatalabClient, DatalabAPIError, DuplicateItemError, __version__
11
11
  from .utils import networkx_from_item_graph
@@ -398,7 +398,7 @@ class DatalabClient(BaseDatalabClient):
398
398
 
399
399
  # Use a longer read timeout for uploads, as the server may do
400
400
  # significant processing before responding
401
- upload_timeout = httpx.Timeout(self._timeout.connect, read=600.0, pool=self._timeout.pool)
401
+ upload_timeout = httpx2.Timeout(self._timeout.connect, read=600.0, pool=self._timeout.pool)
402
402
 
403
403
  upload_url = f"{self.datalab_api_url}/upload-file/"
404
404
  with open(file_path, "rb") as file:
@@ -6,7 +6,7 @@ from getpass import getpass
6
6
  from importlib.metadata import version
7
7
  from typing import Any
8
8
 
9
- import httpx
9
+ import httpx2
10
10
  from rich.logging import RichHandler
11
11
 
12
12
  from .utils import AutoPrettyPrint
@@ -34,9 +34,9 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
34
34
  """
35
35
 
36
36
  _api_key: str | None = None
37
- _session: httpx.Client | None = None
37
+ _session: httpx2.Client | None = None
38
38
  _headers: dict[str, str]
39
- _timeout: httpx.Timeout = httpx.Timeout(10.0, read=60.0)
39
+ _timeout: httpx2.Timeout = httpx2.Timeout(10.0, read=60.0)
40
40
 
41
41
  interactive: bool = True
42
42
  """Whether the client is being used in an interactive context (e.g., CLI or notebook) or not.
@@ -103,7 +103,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
103
103
  logging.basicConfig(level=log_level, handlers=[RichHandler()])
104
104
  self.log = logging.getLogger(__name__)
105
105
 
106
- self._http_client = httpx.Client
106
+ self._http_client = httpx2.Client
107
107
  self._headers = {"User-Agent": f"Datalab Python API/{__version__}"}
108
108
 
109
109
  self._detect_api_url()
@@ -126,7 +126,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
126
126
  Do not use the session for this, so we are not passing the API key to arbitrary URLs.
127
127
 
128
128
  """
129
- response = httpx.get(self.datalab_api_url)
129
+ response = httpx2.get(self.datalab_api_url)
130
130
  match = re.search(
131
131
  r'<meta name="x_datalab_api_url" content="(.*?)">',
132
132
  response.text,
@@ -145,7 +145,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
145
145
  raise NotImplementedError
146
146
 
147
147
  @property
148
- def session(self) -> httpx.Client:
148
+ def session(self) -> httpx2.Client:
149
149
  if self._session is None:
150
150
  return self._http_client(headers=self.headers, timeout=self.timeout)
151
151
  return self._session
@@ -156,7 +156,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
156
156
  return self._headers
157
157
 
158
158
  @property
159
- def timeout(self) -> httpx.Timeout:
159
+ def timeout(self) -> httpx2.Timeout:
160
160
  """A timeout object to use for the datalab API session."""
161
161
  return self._timeout
162
162
 
@@ -246,7 +246,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
246
246
  self._session.close()
247
247
 
248
248
  def _handle_response(
249
- self, response: httpx.Response, url: str, expected_status: int | list[int] = 200
249
+ self, response: httpx2.Response, url: str, expected_status: int | list[int] = 200
250
250
  ) -> dict[str, Any]:
251
251
  """Handle HTTP response with consistent error handling.
252
252
 
@@ -390,7 +390,7 @@ This is likely a server-side bug. Please report this issue to the datalab develo
390
390
  method, url, follow_redirects=True, timeout=timeout, **kwargs
391
391
  )
392
392
  return self._handle_response(response, url, expected_status)
393
- except (httpx.RequestError, httpx.HTTPStatusError) as e:
393
+ except (httpx2.RequestError, httpx2.HTTPStatusError) as e:
394
394
  raise DatalabAPIError(f"Request failed for {url}: {e}")
395
395
 
396
396
  def _apply_elevation(self, method: str, kwargs: dict[str, Any]) -> dict[str, Any]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: A Python API for instances of the datalab data management platform (https://github.com/datalab-org/datalab).
5
5
  Author-email: Matthew Evans <matthew@ml-evs.science>
6
6
  License-Expression: MIT
@@ -2,7 +2,7 @@ import re
2
2
 
3
3
  import pytest
4
4
  import respx
5
- from httpx import Response
5
+ from httpx2 import Response
6
6
 
7
7
  from datalab_api import DatalabClient
8
8
  from datalab_api._base import DatalabAPIError
File without changes
File without changes
File without changes