Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

USER vscode

RUN curl -sSf https://rye-up.com/get | RYE_VERSION="0.15.2" RYE_INSTALL_OPTION="--yes" bash
RUN curl -sSf https://rye-up.com/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash
ENV PATH=/home/vscode/.rye/shims:$PATH

RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_VERSION: 0.24.0
RYE_INSTALL_OPTION: "--yes"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_VERSION: 0.24.0
RYE_INSTALL_OPTION: "--yes"

- name: Publish to PyPI
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Error codes are as followed:

### Retries

Certain errors are automatically retried 2 times by default, with a short exponential backoff.
Certain errors are automatically retried 1 times by default, with a short exponential backoff.
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
429 Rate Limit, and >=500 Internal errors are all retried by default.

Expand All @@ -152,15 +152,15 @@ client.with_options(max_retries=5).database_connections.create(

### Timeouts

By default requests time out after 1 minute. You can configure this with a `timeout` option,
By default requests time out after 6 minutes. You can configure this with a `timeout` option,
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from dataherald import Dataherald

# Configure the default for all requests:
client = Dataherald(
# 20 seconds (default is 1 minute)
# 20 seconds (default is 6 minutes)
timeout=20.0,
)

Expand Down
50 changes: 47 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,92 @@
# pre: false
# features: []
# all-features: true
# with-sources: false

-e file:.
annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via dataherald
# via httpx
argcomplete==3.1.2
# via nox
attrs==23.1.0
# via pytest
certifi==2023.7.22
# via httpcore
# via httpx
colorlog==6.7.0
# via nox
dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
# via dataherald
exceptiongroup==1.1.3
# via anyio
filelock==3.12.4
# via virtualenv
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via dataherald
# via respx
idna==3.4
# via anyio
# via httpx
importlib-metadata==7.0.0
iniconfig==2.0.0
# via pytest
mypy==1.7.1
mypy-extensions==1.0.0
# via mypy
nodeenv==1.8.0
# via pyright
nox==2023.4.22
packaging==23.2
# via nox
# via pytest
platformdirs==3.11.0
# via virtualenv
pluggy==1.3.0
# via pytest
py==1.11.0
# via pytest
pydantic==2.4.2
# via dataherald
pydantic-core==2.10.1
pyright==1.1.332
# via pydantic
pyright==1.1.351
pytest==7.1.1
# via pytest-asyncio
pytest-asyncio==0.21.1
python-dateutil==2.8.2
# via time-machine
pytz==2023.3.post1
# via dirty-equals
respx==0.20.2
ruff==0.1.9
setuptools==68.2.2
# via nodeenv
six==1.16.0
# via python-dateutil
sniffio==1.3.0
# via anyio
# via dataherald
# via httpx
time-machine==2.9.0
tomli==2.0.1
# via mypy
# via pytest
typing-extensions==4.8.0
# via dataherald
# via mypy
# via pydantic
# via pydantic-core
virtualenv==20.24.5
# via nox
zipp==3.17.0
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2
# via importlib-metadata
21 changes: 21 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,39 @@
# pre: false
# features: []
# all-features: true
# with-sources: false

-e file:.
annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via dataherald
# via httpx
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via dataherald
exceptiongroup==1.1.3
# via anyio
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via dataherald
idna==3.4
# via anyio
# via httpx
pydantic==2.4.2
# via dataherald
pydantic-core==2.10.1
# via pydantic
sniffio==1.3.0
# via anyio
# via dataherald
# via httpx
typing-extensions==4.8.0
# via dataherald
# via pydantic
# via pydantic-core
6 changes: 3 additions & 3 deletions src/dataherald/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"

# default timeout is 1 minute
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0)
DEFAULT_MAX_RETRIES = 2
# default timeout is 6 minutes
DEFAULT_TIMEOUT = httpx.Timeout(timeout=360.0, connect=5.0)
DEFAULT_MAX_RETRIES = 1
DEFAULT_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)

INITIAL_RETRY_DELAY = 0.5
Expand Down
2 changes: 1 addition & 1 deletion src/dataherald/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def construct_type(*, value: object, type_: type) -> object:

if is_union(origin):
try:
return validate_type(type_=type_, value=value)
return validate_type(type_=cast("type[object]", type_), value=value)
except Exception:
pass

Expand Down
2 changes: 1 addition & 1 deletion src/dataherald/_utils/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __dir__(self) -> Iterable[str]:

@property # type: ignore
@override
def __class__(self) -> type:
def __class__(self) -> type: # pyright: ignore
proxied = self.__get_proxied__()
if issubclass(type(proxied), LazyProxy):
return type(proxied)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_copy_default_options(self) -> None:
# options that have a default are overridden correctly
copied = self.client.copy(max_retries=7)
assert copied.max_retries == 7
assert self.client.max_retries == 2
assert self.client.max_retries == 1

copied2 = copied.copy(max_retries=6)
assert copied2.max_retries == 6
Expand Down Expand Up @@ -763,7 +763,7 @@ def test_copy_default_options(self) -> None:
# options that have a default are overridden correctly
copied = self.client.copy(max_retries=7)
assert copied.max_retries == 7
assert self.client.max_retries == 2
assert self.client.max_retries == 1

copied2 = copied.copy(max_retries=6)
assert copied2.max_retries == 6
Expand Down