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

[BEAM-14374] Fix module import error in FullyQualifiedNamedTransform #17482

Merged
merged 3 commits into from
May 7, 2022

Conversation

ihji
Copy link
Contributor

@ihji ihji commented Apr 27, 2022

The second argument of import_module is ignored when the first argument is not a relative name. For example, the current implementation works for io module since import_module('io') also works however it doesn't work for apache_beam.dataframe since import_module('dataframe') also doesn't work.


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).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • 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.

@ihji
Copy link
Contributor Author

ihji commented Apr 27, 2022

R: @robertwb

@codecov
Copy link

codecov bot commented Apr 27, 2022

Codecov Report

Merging #17482 (38ce39f) into master (07f30d2) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #17482      +/-   ##
==========================================
+ Coverage   73.93%   74.02%   +0.09%     
==========================================
  Files         689      691       +2     
  Lines       90397    90873     +476     
==========================================
+ Hits        66832    67266     +434     
- Misses      22381    22423      +42     
  Partials     1184     1184              
Flag Coverage Δ
python 83.71% <100.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
...beam/transforms/fully_qualified_named_transform.py 100.00% <100.00%> (ø)
.../python/apache_beam/testing/test_stream_service.py 88.09% <0.00%> (-4.77%) ⬇️
...s/interactive/dataproc/dataproc_cluster_manager.py 84.21% <0.00%> (-3.70%) ⬇️
sdks/python/apache_beam/coders/row_coder.py 94.49% <0.00%> (-2.51%) ⬇️
sdks/python/apache_beam/runners/common.py 87.94% <0.00%> (-2.48%) ⬇️
sdks/python/apache_beam/io/gcp/gcsfilesystem.py 88.23% <0.00%> (-1.77%) ⬇️
...che_beam/runners/interactive/interactive_runner.py 89.20% <0.00%> (-1.64%) ⬇️
sdks/python/apache_beam/io/localfilesystem.py 90.97% <0.00%> (-1.28%) ⬇️
...ive/messaging/interactive_environment_inspector.py 96.66% <0.00%> (-1.21%) ⬇️
sdks/python/apache_beam/dataframe/frame_base.py 89.54% <0.00%> (-0.83%) ⬇️
... and 46 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f30d2...38ce39f. Read the comment docs.

@aaltay aaltay requested a review from robertwb May 5, 2022 14:55
Copy link
Contributor

@robertwb robertwb left a comment

Choose a reason for hiding this comment

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

Can you add a test?

@ihji
Copy link
Contributor Author

ihji commented May 6, 2022

@robertwb added a test

@@ -116,6 +119,14 @@ def test_glob_filter(self):
with self.assertRaises(ValueError):
FullyQualifiedNamedTransform._resolve('apache_beam.Row')

@patch('importlib.import_module')
def test_resolve(self, mock_import_module):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to be a stickler, but this mocking doesn't actually convince me that the code in question actually does the right thing. Could you actually perform an import here so that we know we're interacting with the import module in the right way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other tests already cover some real importing but I added two more that would have failed without the change in this PR.

Copy link
Contributor

@robertwb robertwb left a comment

Choose a reason for hiding this comment

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

Perfect. Thanks!

@ihji ihji merged commit 70b7567 into apache:master May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants