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

Refactor code according to keyedModelHandler changes #21819

Merged
merged 2 commits into from
Jun 13, 2022

Conversation

AnandInguva
Copy link
Contributor

Resolve tests failing due to #21777.

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

See CI.md for more information about GitHub Actions CI.

@AnandInguva
Copy link
Contributor Author

R: @robertwb @tvalentyn @yeandy

@AnandInguva
Copy link
Contributor Author

Run Python 3.7 PostCommit

@AnandInguva
Copy link
Contributor Author

Run Python 3.9 PostCommit

PytorchModelHandler(
state_dict_path=known_args.model_state_dict_path,
model_class=model_class,
model_params=model_params))
Copy link
Contributor

@tvalentyn tvalentyn Jun 13, 2022

Choose a reason for hiding this comment

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

Do we still need the type hints on line 139?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, still getting the error(expecting Union) if I remove the output hint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it's because RunInference is imported from api.py instead of base.py and the RunInference in api.py has Union[...] type?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok. I thought the splitting of model handlers would allow us getting the type deterministically instead of having to make a union. we can look into it separately.
cc: @robertwb @yeandy @rezarokni

state_dict_path=known_args.model_state_dict_path,
model_class=model_class,
model_params=model_params)
# the input to RunInference transform is keyed. Wrap
Copy link
Contributor

@tvalentyn tvalentyn Jun 13, 2022

Choose a reason for hiding this comment

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

This sounds like the input is always keyed. Isn't it user's choice? If so, would this be more appropriate instead:

In this example we pass keyed inputs to RunInference transform.
Therefore, we use KeyedModelHandler wrapper over PytorchModelHandler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@yeandy
Copy link
Contributor

yeandy commented Jun 13, 2022

@AnandInguva can you fix the input and state_dict path names too? Or maybe in a separate PR

@AnandInguva
Copy link
Contributor Author

AnandInguva commented Jun 13, 2022

Ran the IT test that uses the above example offline and it passes. Also all the unit tests for torch RunInference passes locally.

@AnandInguva
Copy link
Contributor Author

@AnandInguva can you fix the input and state_dict path names too? Or maybe in a separate PR

will look into it in a separate PR. thanks

@tvalentyn tvalentyn merged commit 63cd54e into apache:master Jun 13, 2022
bullet03 pushed a commit to akvelon/beam that referenced this pull request Jun 20, 2022
* Refactor code according to keyedModelHandler changes

* Add comments on why keyedModelHandler is used.
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.

None yet

3 participants