Skip to content

[Gemini] Prototype OpenAI RemoteInferenceModelHandler Implementation - #40239

Merged
jrmccluskey merged 4 commits into
apache:masterfrom
jrmccluskey:inferenceGPT
Oct 7, 2026
Merged

jrmccluskey merged 4 commits into
apache:masterfrom
jrmccluskey:inferenceGPT

Conversation

@jrmccluskey

Copy link
Copy Markdown
Contributor

Experimental codegen implementation of an OpenAI RemoteInferenceModelHandler in the Python SDK. As is the case with the Java implementation, the IT test will not run as part of CI because beam does not have an OpenAI API key secret.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @claudevdm for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Comment thread sdks/python/apache_beam/ml/inference/openai_inference.py Outdated
Comment thread sdks/python/apache_beam/ml/inference/openai_inference.py
Comment thread sdks/python/apache_beam/ml/inference/openai_inference.py Outdated
A list of Embedding objects matching the batch order.
"""
inf_args = dict(inference_args)
response = client.embeddings.create(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set a default max batch size so that we dont exceed the api batch size limits?

Comment thread sdks/python/apache_beam/ml/inference/openai_inference.py
Comment thread sdks/python/apache_beam/ml/inference/openai_inference.py Outdated
@jrmccluskey

Copy link
Copy Markdown
Contributor Author

Test failures are still the Bigtable issues



def _run_async_with_client(client: AsyncOpenAI, coro: Any) -> Any:
"""Runs a coroutine via asyncio.run and cleans up idle pool connections."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe RunInference shares the client between harness threads so once a batch is done this helper closes all of the client's connections that other threads are waiting on?

Maybe we should we go back to the regular OpenAI client and use a small thread pool to send the prompts at the same time? Or, if you'd rather stay async, create the client inside each batch like the vLLM handler does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flipped back to sync client

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.15%. Comparing base (b849208) to head (edee7f0).
⚠️ Report is 191 commits behind head on master.

Files with missing lines Patch % Lines
...ython/apache_beam/ml/inference/openai_inference.py 0.00% 104 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40239      +/-   ##
============================================
- Coverage     56.09%   55.15%   -0.94%     
+ Complexity     2284     1722     -562     
============================================
  Files          1120     1079      -41     
  Lines        176909   173143    -3766     
  Branches       1475     1262     -213     
============================================
- Hits          99244    95505    -3739     
- Misses        75147    75362     +215     
+ Partials       2518     2276     -242     
Flag Coverage Δ
python 79.56% <0.00%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrmccluskey

Copy link
Copy Markdown
Contributor Author

@claudevdm bump

@jrmccluskey
jrmccluskey merged commit 5aa894f into apache:master Oct 7, 2026
100 of 104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants