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

Support models returning a dictionary of outputs #23087

Merged
merged 6 commits into from
Sep 9, 2022

Conversation

damccorm
Copy link
Contributor

@damccorm damccorm commented Sep 8, 2022

The return value of the forward call for many models is a dictionary with the predictions along with more metadata. This supports that return type.

Fixes #22240


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

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • 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.

@codecov
Copy link

codecov bot commented Sep 8, 2022

Codecov Report

Merging #23087 (6884222) into master (595c7e9) will decrease coverage by 0.00%.
The diff coverage is 47.05%.

@@            Coverage Diff             @@
##           master   #23087      +/-   ##
==========================================
- Coverage   73.58%   73.58%   -0.01%     
==========================================
  Files         716      716              
  Lines       95301    95309       +8     
==========================================
+ Hits        70127    70131       +4     
- Misses      23878    23882       +4     
  Partials     1296     1296              
Flag Coverage Δ
python 83.40% <47.05%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
...am/examples/inference/pytorch_language_modeling.py 0.00% <0.00%> (ø)
...thon/apache_beam/ml/inference/pytorch_inference.py 0.00% <0.00%> (ø)
...thon/apache_beam/ml/inference/sklearn_inference.py 95.52% <100.00%> (+0.44%) ⬆️
.../python/apache_beam/testing/test_stream_service.py 88.09% <0.00%> (-4.77%) ⬇️
...che_beam/runners/interactive/interactive_runner.py 90.06% <0.00%> (-1.33%) ⬇️
...beam/runners/portability/local_job_service_main.py 14.43% <0.00%> (-0.42%) ⬇️
sdks/python/apache_beam/transforms/combiners.py 93.05% <0.00%> (-0.39%) ⬇️
...beam/runners/portability/expansion_service_main.py 0.00% <0.00%> (ø)
...hon/apache_beam/runners/worker/bundle_processor.py 93.54% <0.00%> (+0.12%) ⬆️
...ks/python/apache_beam/runners/worker/sdk_worker.py 89.09% <0.00%> (+0.15%) ⬆️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@damccorm
Copy link
Contributor Author

damccorm commented Sep 8, 2022

R: @yeandy

I ended up picking this one up as a good ramp up item, lmk if you think there's a better approach here though.

@damccorm damccorm marked this pull request as ready for review September 8, 2022 15:48
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link
Contributor

@yeandy yeandy left a comment

Choose a reason for hiding this comment

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

Overall, looks good! A few comments; and can you please add a test for SklearnModelHandlerPandas?

@yeandy
Copy link
Contributor

yeandy commented Sep 8, 2022

Let's also run postcommit to ensure the test_torch_run_inference_bert_for_masked_lm test passes.

@yeandy
Copy link
Contributor

yeandy commented Sep 8, 2022

Run Python 3.8 PostCommit

Copy link
Contributor

@yeandy yeandy left a comment

Choose a reason for hiding this comment

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

LGTM

@damccorm
Copy link
Contributor Author

damccorm commented Sep 8, 2022

Overall, looks good! A few comments; and can you please add a test for SklearnModelHandlerPandas?

Good catch - was an oversight on my part.

Thanks for the feedback, I think I've responded to everything at this point!

@damccorm
Copy link
Contributor Author

damccorm commented Sep 8, 2022

Run Python 3.8 PostCommit

@damccorm damccorm merged commit 7a3ac2d into apache:master Sep 9, 2022
@damccorm damccorm deleted the users/damccorm/inferDict branch September 9, 2022 01:13
@AnandInguva
Copy link
Contributor

The inference IT tests are enabled only on Python 3.7 and Python 3.9 post commit suites. (lowest and highest version)

@damccorm
Copy link
Contributor Author

damccorm commented Sep 9, 2022

Oh good to know - it looks like that is passing anyways with this change fortunately - https://ci-beam.apache.org/job/beam_PostCommit_Python37/5697/

@yeandy
Copy link
Contributor

yeandy commented Sep 9, 2022

Sorry about misleading you with the 3.8 run. I always get confused which tests are enabled for which suites.

@damccorm damccorm restored the users/damccorm/inferDict branch September 12, 2022 17:23
@damccorm damccorm deleted the users/damccorm/inferDict branch September 12, 2022 17:24
dedocibula pushed a commit to dedocibula/beam that referenced this pull request Sep 15, 2022
* Support models returning a dictionary of outputs

* Update example with this issue

* Format

* linting

* Feedback

* keys for clarity
kkdoon pushed a commit to twitter-forks/beam that referenced this pull request Sep 29, 2022
* Support models returning a dictionary of outputs

* Update example with this issue

* Format

* linting

* Feedback

* keys for clarity
cushon pushed a commit to cushon/beam that referenced this pull request Oct 17, 2022
* Support models returning a dictionary of outputs

* Update example with this issue

* Format

* linting

* Feedback

* keys for clarity
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.

[Bug]: Pytorch RunInference PredictionResult is a Dict
3 participants