Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openai): propagate asyncio.TimeoutErrors correctly when openai operation canceled [backport 2.10] #10320

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

sabrenner
Copy link
Contributor

Backport 16cdd6a from #10265 to 2.10.

Fixes #10191

In the case of an asyncio future cancellation, we want to propagate that error up appropriately. What this looks like is the response from the OpenAI function being None, which does not conform to the typing from the OpenAI SDK (see original issue). If the result is ever None, we don't pass that result to our shared generator to handle OpenAI responses, and instead let the error bubble up.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

…operation canceled (#10265)

Fixes #10191

In the case of an `asyncio` future cancellation, we want to propagate
that error up appropriately. What this looks like is the `response` from
the OpenAI function being `None`, which does not conform to the typing
from the OpenAI SDK (see original issue). If the result is ever `None`,
we don't pass that result to our shared generator to handle OpenAI
responses, and instead let the error bubble up.

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: backport-10265-to-2.10
Commit report: d0ac57b
Test service: dd-trace-py

✅ 0 Failed, 1218 Passed, 107 Skipped, 13m 25.99s Total Time

@sabrenner sabrenner marked this pull request as ready for review August 21, 2024 17:26
@sabrenner sabrenner requested review from a team as code owners August 21, 2024 17:26
@pr-commenter
Copy link

pr-commenter bot commented Aug 21, 2024

Benchmarks

Benchmark execution time: 2024-08-21 18:16:39

Comparing candidate commit d0ac57b in PR branch backport-10265-to-2.10 with baseline commit 63edc2e in branch 2.10.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 221 metrics, 9 unstable metrics.

@sabrenner sabrenner merged commit ba3a2bc into 2.10 Aug 22, 2024
71 of 77 checks passed
@sabrenner sabrenner deleted the backport-10265-to-2.10 branch August 22, 2024 13:14
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.

2 participants