Skip to content

fix: add backward compatibility for pyrate-limiter 4.0.0+#296

Merged
ArzelaAscoIi merged 6 commits into
mainfrom
copilot/fix-incompatibility-with-pyrate-limiter
Feb 24, 2026
Merged

fix: add backward compatibility for pyrate-limiter 4.0.0+#296
ArzelaAscoIi merged 6 commits into
mainfrom
copilot/fix-incompatibility-with-pyrate-limiter

Conversation

Copilot AI commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes?

pyrate-limiter 4.0.0 removed raise_when_fail and max_delay parameters from Limiter.__init__(), causing TypeError on initialization.

Implementation:

  • Runtime version detection via inspect.signature() to check for blocking parameter in try_acquire()
  • Conditional Limiter initialization:
    • 4.0.0+: Uses simplified API without deprecated parameters
    • 3.x: Uses legacy API with raise_when_fail=False and max_delay
  • Extracted _rate_limit_acquire() helper method:
    • 4.0.0+: Calls try_acquire("", blocking=False) for non-blocking behavior
    • 3.x: Calls try_acquire("") (non-blocking via raise_when_fail=False)

Example:

# Works with both pyrate-limiter 3.x and 4.x
async with S3(rate_limit=Rate(3000, Duration.SECOND)) as s3:
    await s3.upload_in_memory(session, files)

How did you test it?

  • All 23 existing unit tests pass with both pyrate-limiter 3.7.0 and 4.0.2
  • Verified S3 initialization without TypeError
  • CodeQL security scan: 0 alerts

Notes for the reviewer

Single file modified (deepset_cloud_sdk/_s3/upload.py). Version detection logic at module level (lines 29-38), helper method at lines 142-158.

Checklist

  • I have updated the referenced issue with new insights and changes
  • If this is a code change, I have added unit tests
  • I've used the conventional commit specification for my PR title
  • I updated the docstrings
  • If this is a code change, I added meaningful logs and prepared Datadog visualizations and alerts

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>deepset-cloud-sdk is incompatible with pyrate-limiter>=4.0.0</issue_title>
<issue_description>Describe the bug
pyrate-limiter==4.0.0 was recently released, breaking compatibility: https://github.com/vutran1710/PyrateLimiter/releases/tag/v4.0.0

To Reproduce

from deepset_cloud_sdk.workflows.sync_client.files import upload_texts

# prepare some files
# ...

summary = upload_texts(
    workspace_name=...,
    files=dc_files,
    api_key=...,
    blocking=True,
    timeout_s=300,
    show_progress=True,
    write_mode=WriteMode.OVERWRITE,
    enable_parallel_processing=True,
)

Error

    summary = upload_texts(
              ^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/deepset_cloud_sdk/workflows/sync_client/files.py", line 188, in upload_texts
    return asyncio.run(
           ^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/deepset_cloud_sdk/workflows/async_client/files.py", line 265, in upload_texts
    async with FilesService.factory(_get_config(api_key=api_key, api_url=api_url)) as file_service:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/deepset_cloud_sdk/_service/files_service.py", line 74, in factory
    async with S3(concurrency=concurrency, max_attempts=max_attempts) as s3:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/deepset_cloud_sdk/_s3/upload.py", line 97, in __init__
    self.limiter = Limiter(rate_limit, raise_when_fail=False, max_delay=Duration.SECOND * 1)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Limiter.__init__() got an unexpected keyword argument 'raise_when_fail'

See https://github.com/deepset-ai/haystack/actions/runs/21271332320/job/61221934024

For the moment, we could just pin pyrate-limiter<4.0.0

Checklist

  • I added a label for the level of urgency of this bug (see definitions here)
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 23, 2026 10:28
Co-authored-by: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com>
Co-authored-by: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix deepset-cloud-sdk compatibility with pyrate-limiter 4.0.0 fix: add backward compatibility for pyrate-limiter 4.0.0+ Jan 23, 2026
Copilot AI requested a review from ArzelaAscoIi January 23, 2026 10:35
@ArzelaAscoIi ArzelaAscoIi marked this pull request as ready for review January 23, 2026 10:41
@github-actions

github-actions Bot commented Jan 23, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  deepset_cloud_sdk/_s3
  upload.py 102-105, 124-125, 183-187
Project Total  

This report was generated by python-coverage-comment-action

Co-authored-by: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com>
@ArzelaAscoIi ArzelaAscoIi force-pushed the copilot/fix-incompatibility-with-pyrate-limiter branch from d9fcbbd to 370fa65 Compare February 22, 2026 21:32
ArzelaAscoIi and others added 2 commits February 24, 2026 18:06
- Replace inspect.signature() version detection with try/except on init
- Use **kwargs for try_acquire() to avoid mypy call-arg error
- Fix trailing whitespace formatting issues

Co-authored-by: Cursor <cursoragent@cursor.com>
@ArzelaAscoIi ArzelaAscoIi merged commit 788554a into main Feb 24, 2026
7 checks passed
@ArzelaAscoIi ArzelaAscoIi deleted the copilot/fix-incompatibility-with-pyrate-limiter branch February 24, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deepset-cloud-sdk is incompatible with pyrate-limiter>=4.0.0

2 participants