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

[yaml] Adding Spanner IO Providers for Beam YAML #31987

Merged
merged 21 commits into from
Sep 9, 2024

Conversation

reeba212
Copy link
Contributor

  1. Added SpannerReadSchemaTransformProvider.java, a provider for reading from spanner.
  2. Modified SpannerWriteSchemaTransformProvider.java to incorporate error handling and fixed other issues.
  3. Modified MutationUtils.java to add a function "createRowFromMutation" which creates a Beam Row from a Mutation. This is used in the spanner write provider.
  4. Modified ErrorHandling.java to make it serializable.
  5. Modified standard_io.yaml to register the Spanner IO providers.

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.

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

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Thanks Reeba! I left some comments, but the overall structure looks really good

@Polber
Copy link
Contributor

Polber commented Jul 25, 2024

R: @damccorm

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@Polber Polber mentioned this pull request Jul 31, 2024
3 tasks
@reeba212 reeba212 changed the title Adding Spanner IO Providers for Beam YAML [yaml] Adding Spanner IO Providers for Beam YAML Aug 22, 2024
Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Added some comments related to newly added testing framework

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Couple more small changes. Also, make sure to address the unresolved conversations. Thanks!

@Polber
Copy link
Contributor

Polber commented Aug 27, 2024

@reeba212 #32008 was merged, so you should be able to rebase on main and make sure checks pass!

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Lint errors:

************* Module apache_beam.io.gcp.spanner_wrapper	
apache_beam/io/gcp/spanner_wrapper.py:20:0: W0611: Unused apache_beam imported as beam (unused-import)	
************* Module apache_beam.yaml.integration_tests	
apache_beam/yaml/integration_tests.py:50:0: W0404: Reimport 'contextlib' (imported line 20) (reimported)	
apache_beam/yaml/integration_tests.py:50:0: C0413: Import "import contextlib" should be placed at the top of the module (wrong-import-position)	
apache_beam/yaml/integration_tests.py:51:0: W0404: Reimport 'uuid' (imported line 27) (reimported)	
apache_beam/yaml/integration_tests.py:51:0: C0413: Import "import uuid" should be placed at the top of the module (wrong-import-position)	
apache_beam/yaml/integration_tests.py:52:0: W0404: Reimport 'logging' (imported line 24) (reimported)	
apache_beam/yaml/integration_tests.py:52:0: C0413: Import "import logging" should be placed at the top of the module (wrong-import-position)	
apache_beam/yaml/integration_tests.py:53:0: C0413: Import "from google.cloud import spanner" should be placed at the top of the module (wrong-import-position)	
apache_beam/yaml/integration_tests.py:50:0: C0412: Imports from package contextlib are not grouped (ungrouped-imports)	
apache_beam/yaml/integration_tests.py:51:0: C0412: Imports from package uuid are not grouped (ungrouped-imports)	
apache_beam/yaml/integration_tests.py:52:0: C0412: Imports from package logging are not grouped (ungrouped-imports)	
apache_beam/yaml/integration_tests.py:53:0: W0611: Unused spanner imported from google.cloud (unused-import)

Make modification I added in comments then run:
yapf --in-place --parallel --recursive apache_beam

I also recommend following steps in https://cwiki.apache.org/confluence/display/BEAM/Python+Tips#PythonTips-LintandFormattingChecks

sdks/python/apache_beam/io/gcp/spanner_wrapper.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/yaml/integration_tests.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 48 lines in your changes missing coverage. Please review.

Project coverage is 57.15%. Comparing base (64b4aa6) to head (8f9178e).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
sdks/python/apache_beam/io/gcp/spanner_wrapper.py 0.00% 34 Missing ⚠️
sdks/python/apache_beam/yaml/integration_tests.py 0.00% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #31987      +/-   ##
============================================
- Coverage     57.34%   57.15%   -0.19%     
  Complexity     1474     1474              
============================================
  Files           964      965       +1     
  Lines        153341   153435      +94     
  Branches       1076     1076              
============================================
- Hits          87933    87699     -234     
- Misses        63204    63537     +333     
+ Partials       2204     2199       -5     
Flag Coverage Δ
python 81.15% <0.00%> (-0.45%) ⬇️

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

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

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Try seeing if making these changes fixes test errors

1. Removed serialiazability from ErrorHandling.java
2. Removed double map definitions from MutationUtils.java
3. Added checkNotNull in spanner write provider
4. Modified some variables in spanner wrapper
5. Change instance id in integration tests
1. replace checknotnull with checkargument in spanner read provider
2. use the correct table  name (tmp_table) in integration test
1. Added serializable to error handling
2. Corrected validation methods in spanner read
3. Added retry import and removed default project name in spanner wrapper
4. Corrected instance and database names in spanner integration test
5. Corrected table name in query
Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

Reran the failing jobs to see if we can get them green, but they do seem unrelated to this change

@@ -444,7 +444,7 @@ def get_portability_package_data():
'google-cloud-bigquery-storage>=2.6.3,<3',
'google-cloud-core>=2.0.0,<3',
'google-cloud-bigtable>=2.19.0,<3',
'google-cloud-spanner>=3.0.0,<4',
'google-cloud-spanner>=3.0.0,<3.48',
Copy link
Contributor

Choose a reason for hiding this comment

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

@Polber @reeba212 catching up on this, which suites were failing such that we needed to add this? I'd like to follow up with the spanner folks to make sure they're aware of the breaking change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were two checks that were failing and both had the same underlying error:
ModuleNotFoundError: No module named 'grpc_interceptor'

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

Thanks!

@damccorm damccorm merged commit 173dd48 into apache:master Sep 9, 2024
130 of 134 checks passed
@chamikaramj
Copy link
Contributor

@liferoad
Copy link
Collaborator

cc @Polber

@Polber
Copy link
Contributor

Polber commented Sep 12, 2024

@damccorm was working on rebuilding those - not sure the status

@Polber
Copy link
Contributor

Polber commented Sep 12, 2024

Looks like it is under review still: #32411

@damccorm
Copy link
Contributor

Yep, was just waiting on approval - just merged and it should be back to green

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.

5 participants