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

Model updates with side inputs #25174

Closed
wants to merge 26 commits into from

Conversation

AnandInguva
Copy link
Contributor

@AnandInguva AnandInguva commented Jan 25, 2023

  1. Add side input to the RunInference base transform.
  • Side inputs passed to RunInference DoFn must be singleton, and should be wrapped around beam.ml.inference.base.ModelMetadata.

TODO:

  • Add documentation
  • Add feature to change log
  • Follow up PR on WatchFileTransform PTransform and an example on how to use side inputs with RunInference

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.

@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #25174 (99e14f8) into master (428ec97) will decrease coverage by 0.06%.
The diff coverage is 65.93%.

❗ Current head 99e14f8 differs from pull request most recent head 5e7ca32. Consider uploading reports for the commit 5e7ca32 to get more accurate results

@@            Coverage Diff             @@
##           master   #25174      +/-   ##
==========================================
- Coverage   73.12%   73.07%   -0.06%     
==========================================
  Files         735      741       +6     
  Lines       98161    98822     +661     
==========================================
+ Hits        71779    72212     +433     
- Misses      25019    25247     +228     
  Partials     1363     1363              
Flag Coverage Δ
python 82.50% <65.93%> (-0.17%) ⬇️

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

Impacted Files Coverage Δ
...thon/apache_beam/ml/inference/pytorch_inference.py 0.00% <0.00%> (ø)
...hon/apache_beam/ml/inference/tensorrt_inference.py 0.00% <0.00%> (ø)
sdks/python/apache_beam/ml/inference/base.py 91.37% <76.92%> (-4.39%) ⬇️
...thon/apache_beam/ml/inference/sklearn_inference.py 96.25% <100.00%> (-0.05%) ⬇️
sdks/python/apache_beam/ml/inference/utils.py 100.00% <100.00%> (ø)
sdks/python/apache_beam/utils/python_callable.py 86.88% <0.00%> (-11.48%) ⬇️
.../python/apache_beam/typehints/trivial_inference.py 95.89% <0.00%> (-0.30%) ⬇️
sdks/python/apache_beam/transforms/util.py 96.24% <0.00%> (-0.16%) ⬇️
sdks/python/apache_beam/transforms/external.py 78.74% <0.00%> (-0.14%) ⬇️
...ache/beam/model/fn_execution/v1/beam_fn_api_pb2.py 100.00% <0.00%> (ø)
... and 19 more

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

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@github-actions
Copy link
Contributor

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

R: @tvalentyn for label python.
R: @Abacn for label build.

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).

@AnandInguva AnandInguva marked this pull request as draft January 26, 2023 14:19
@AnandInguva
Copy link
Contributor Author

stop reviewer notifications

@github-actions
Copy link
Contributor

Stopping reviewer notifications for this pull request: requested by reviewer

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@AnandInguva
Copy link
Contributor Author

AnandInguva commented Jan 26, 2023

Some mypy related errors I am facing. Seems like the Generic NamedTuples are not supported in the mypy version 0.782.

If I update mypy, it is causing unrelated errors.

apache_beam/ml/inference/utils.py:45: error: Argument 2 to "PredictionResult" has incompatible type "Dict[Any, Any]"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/base_test.py:91: error: Argument "example" to "PredictionResult" has incompatible type "int"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/base_test.py:92: error: Argument "inference" to "PredictionResult" has incompatible type "int"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:55: error: Argument 1 to "PredictionResult" has incompatible type "ndarray[Any, Any]"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:55: error: Argument 2 to "PredictionResult" has incompatible type "List[ndarray[Any, Any]]"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:63: error: Argument 1 to "PredictionResult" has incompatible type "ndarray[Any, Any]"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:63: error: Argument 2 to "PredictionResult" has incompatible type "List[ndarray[Any, Any]]"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:78: error: Argument 1 to "PredictionResult" has incompatible type "ndarray[Any, Any]"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/tensorrt_inference_test.py:78: error: Argument 2 to "PredictionResult" has incompatible type "List[ndarray[Any, Any]]"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/pytorch_inference_test.py:72: error: Argument 2 to "PredictionResult" has incompatible type "Dict[str, _OUTPUT_TYPE]"; expected "_OUTPUT_TYPE"  [arg-type]
apache_beam/ml/inference/pytorch_inference_test.py:97: error: Argument 1 to "PredictionResult" has incompatible type "Dict[str, Any]"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/pytorch_inference_test.py:105: error: Argument 1 to "PredictionResult" has incompatible type "Dict[str, Any]"; expected "_INPUT_TYPE"  [arg-type]
apache_beam/ml/inference/pytorch_inference_test.py:115: error: Argument 2 to "PredictionResult" has incompatible type "Dict[str, _OUTPUT_TYPE]"; expected "_OUTPUT_TYPE"  [arg-type]

So modifying new class of NamedTuple to accept default value for model_id

@github-actions github-actions bot added the build label Jan 26, 2023
@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

@AnandInguva
Copy link
Contributor Author

https://ci-beam.apache.org/job/beam_PostCommit_Python38_PR/688/console

Successful test in post commit

@AnandInguva
Copy link
Contributor Author

Closing because of #25200

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.

1 participant