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

[Python]Don't stage beam SDK in Stager #27436

Merged
merged 21 commits into from
Aug 4, 2023
Merged

Conversation

AnandInguva
Copy link
Contributor

@AnandInguva AnandInguva commented Jul 10, 2023

Fixes: #26996

Support for DataflowRunner v1 will be deprecated from the version 2.50.0. As part of the effort, we can remove staging the beam SDK that is downloaded from pypi by default.

This PR changes the default value of sdk_container to container


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.

@AnandInguva AnandInguva force-pushed the unstage_sdk branch 3 times, most recently from 89abd9b to 44b3984 Compare July 10, 2023 20:09
@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #27436 (708f058) into master (488279c) will decrease coverage by 0.01%.
Report is 2 commits behind head on master.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##           master   #27436      +/-   ##
==========================================
- Coverage   70.88%   70.87%   -0.01%     
==========================================
  Files         861      861              
  Lines      105040   104999      -41     
==========================================
- Hits        74454    74415      -39     
+ Misses      29027    29025       -2     
  Partials     1559     1559              
Flag Coverage Δ
python 79.83% <87.50%> (-0.01%) ⬇️

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

Files Changed Coverage Δ
...dks/python/apache_beam/options/pipeline_options.py 94.20% <ø> (ø)
...s/python/apache_beam/runners/portability/stager.py 84.39% <87.50%> (-2.65%) ⬇️

... and 3 files with indirect coverage changes

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

@AnandInguva AnandInguva marked this pull request as ready for review July 10, 2023 20:42
@AnandInguva AnandInguva changed the title Don't stage beam SDK in Stager [Python]Don't stage beam SDK in Stager Jul 10, 2023
@AnandInguva
Copy link
Contributor Author

Run Python 3.10 PostCommit

@AnandInguva
Copy link
Contributor Author

Run Python 3.11 PostCommit

@github-actions
Copy link
Contributor

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

R: @riteshghorse for label python.

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

Copy link
Contributor

@riteshghorse riteshghorse left a comment

Choose a reason for hiding this comment

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

LGTM with minor nits. Thanks!

'The --sdk_location option was used with an unsupported '
'type of location: %s' % sdk_location)

elif sdk_location == 'default' or sdk_location == 'container':
Copy link
Contributor

Choose a reason for hiding this comment

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

can we still keep the comment here

# Use the SDK that's built into the container, rather than re-staging it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sg. I will re-add the comment along with some more context

Copy link
Contributor

Choose a reason for hiding this comment

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

  elif sdk_location == 'default':
    # Use default location for a runner.
    pass
  elif sdk_location == 'container':
    # Used in the past to indicate that SDK should be used from container image instead of being staged.
    # Equivalent to 'default' now, leaving for backwards compatibility reasons.
    pass

@AnandInguva
Copy link
Contributor Author

R: @tvalentyn

@github-actions
Copy link
Contributor

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

@tvalentyn
Copy link
Contributor

  • let's announce a breaking change in changes.md
  • let's add a check in boot.go that would fail with a meaningful error if a (custom) container doesn't include beam.

Copy link
Contributor

@riteshghorse riteshghorse left a comment

Choose a reason for hiding this comment

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

changes to go files looks good

@AnandInguva
Copy link
Contributor Author

Run Python Dataflow ValidatesContainer

1 similar comment
@AnandInguva
Copy link
Contributor Author

Run Python Dataflow ValidatesContainer

@AnandInguva
Copy link
Contributor Author

Run Python RC Dataflow ValidatesContainer

@AnandInguva AnandInguva requested a review from tvalentyn July 26, 2023 09:03
'Override the default location from where the Beam SDK is '
'downloaded. It can be a URL, a GCS path, or a local path to an '
'Override the default location of the beam SDK. '
'It can be a URL, a GCS path, or a local path to an '
'SDK tarball. Workflow submissions will download or copy an SDK '
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this flag when running pipelines with an unreleased or manually patched version of Beam SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reworded

'tarball from here. If set to the string "default", a standard '
'SDK location is used. If empty, no SDK is copied.'))
'tarball from here. If set to the string "default", '
'the beam SDK in the default container will be used.'))
Copy link
Contributor

Choose a reason for hiding this comment

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

If set to the string "default", runners will use the SDK provided in the default environment.

'The --sdk_location option was used with an unsupported '
'type of location: %s' % sdk_location)

elif sdk_location == 'default' or sdk_location == 'container':
Copy link
Contributor

Choose a reason for hiding this comment

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

  elif sdk_location == 'default':
    # Use default location for a runner.
    pass
  elif sdk_location == 'container':
    # Used in the past to indicate that SDK should be used from container image instead of being staged.
    # Equivalent to 'default' now, leaving for backwards compatibility reasons.
    pass

pkgName := "apache-beam"
isSdkInstalled, err := isPackageInstalled(pkgName)
if err != nil {
return fmt.Errorf("failed to check if Apache Beam %s is installed: %v", pkgName, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be a hard error, we can attempt to continue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this entirely.

}

if !isSdkInstalled {
log.Printf("Apache Beam is not installed on the custom container. Please make sure Apache Beam is installed in the custom container. Look at the docummentation https://beam.apache.org/documentation/runtime/environments/ on custom containers for more details.")
Copy link
Contributor

Choose a reason for hiding this comment

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

wording suggestion: "Apache Beam is not installed in the runtime environment. If you use a custom container image, you must install apache-beam package in the custom image using same version of Beam as in the pipeline submission environment. For more information, see: the https://beam.apache.org/documentation/runtime/environments/ page."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed wording

@AnandInguva AnandInguva requested a review from tvalentyn July 28, 2023 14:08
@tvalentyn
Copy link
Contributor

Run Python_Runners PreCommit

@tvalentyn
Copy link
Contributor

Thanks, changes look good to me. have you tested them in positive and negative case? Negative case requries building a custom docker image similar to https://cloud.google.com/dataflow/docs/guides/using-custom-containers#use_a_custom_base_image_or_multi-stage_builds but w/o Beam.

If you are already OOO i can TAL next week, np.

@AnandInguva
Copy link
Contributor Author

AnandInguva commented Aug 2, 2023

Thanks, changes look good to me. have you tested them in positive and negative case? Negative case requries building a custom docker image similar to https://cloud.google.com/dataflow/docs/guides/using-custom-containers#use_a_custom_base_image_or_multi-stage_builds but w/o Beam.

If you are already OOO i can TAL next week, np.

This job uses the container gcr.io/google.com/clouddfe/anandinguva:2.50.0.dev with beam installed in it. I can the see the message in the logs but at INFO level.

https://pantheon.corp.google.com/dataflow/jobs/us-central1/2023-08-01_23_06_17-11941549679963536368;mainTab=JOB_GRAPH;bottomTab=WORKER_LOGS;logsSeverity=INFO;graphView=0?project=google.com:clouddfe&pageState=(%22dfTime%22:(%22l%22:%22dfJobMaxTime%22))

@tvalentyn
Copy link
Contributor

tvalentyn commented Aug 2, 2023

hmm.. that job has errors like:

DEBUG 2023-08-02T07:02:33.534971077Z Executing Python (worker sdk-0-0): python -m apache_beam.runners.worker.sdk_worker_main
INFO 2023-08-02T07:02:33.596045792Z /opt/apache/beam-venv/beam-venv-worker-sdk-0-0/bin/python: Error while finding module specification for 'apache_beam.runners.worker.sdk_worker_main' (ModuleNotFoundError: No module named 'apache_beam')
INFO 2023-08-02T07:02:33.596088772Z /opt/apache/beam-venv/beam-venv-worker-sdk-0-0/bin/python: Error while finding module specification for 'apache_beam.runners.worker.sdk_worker_main' (ModuleNotFoundError: No module named 'apache_beam')

we should expect to see Apache Beam is not installed in the runtime environment..

@AnandInguva
Copy link
Contributor Author

@tvalentyn tvalentyn merged commit 408d766 into apache:master Aug 4, 2023
BjornPrime pushed a commit to BjornPrime/my-beam that referenced this pull request Aug 7, 2023
Co-authored-by: tvalentyn <tvalentyn@users.noreply.github.com>
damccorm added a commit that referenced this pull request Aug 22, 2023
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.

[Task]: Reconsider the need to stage Beam SDK to GCS after removing runner v1 support.
3 participants