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-11608] Add a local setup shell script for Linux and Mac #14475

Closed

Conversation

ebarreraWL
Copy link
Contributor

Added local-env-setup.sh to automate the installation of local environment dependencies for new Beam users.

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.

Post-Commit Tests Status (on master branch)

Lang SDK ULR Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status Build Status --- Build Status ---
Java Build Status Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status --- Build Status Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

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.

@ebarreraWL
Copy link
Contributor Author

@tysonjh

@tysonjh
Copy link
Contributor

tysonjh commented Apr 9, 2021

Is it possible to add tests for this? For example, can we run this using github actions in a linux/mac environment and then run a few of the gradle check commands?

Will it be possible for this script to be used for snippets in the documentation in the contributor guide?

@ebarreraWL
Copy link
Contributor Author

@tysonjh added the GitHub actions tests for Linux and Mac.

@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #14475 (b9b87bd) into master (985e2f0) will decrease coverage by 0.13%.
The diff coverage is n/a.

❗ Current head b9b87bd differs from pull request most recent head c8b71d5. Consider uploading reports for the commit c8b71d5 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14475      +/-   ##
==========================================
- Coverage   83.61%   83.48%   -0.14%     
==========================================
  Files         445      449       +4     
  Lines       59025    59014      -11     
==========================================
- Hits        49355    49269      -86     
- Misses       9670     9745      +75     
Impacted Files Coverage Δ
...cp/internal/clients/bigquery/bigquery_v2_client.py
...ache_beam/runners/interactive/caching/cacheable.py
...srcs/sdks/python/apache_beam/dataframe/__init__.py
...on/apache_beam/portability/api/metrics_pb2_grpc.py
...s/python/apache_beam/ml/gcp/videointelligenceml.py
...ks/python/apache_beam/runners/worker/statecache.py
...thon/apache_beam/runners/worker/channel_factory.py
...eam/runners/portability/fn_api_runner/execution.py
...uild/srcs/sdks/python/apache_beam/io/gcp/pubsub.py
...beam/runners/dataflow/internal/clients/__init__.py
... and 884 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 3d4db26...c8b71d5. Read the comment docs.

Copy link
Contributor

@tysonjh tysonjh left a comment

Choose a reason for hiding this comment

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

Looking good! A few comments, plus I'd like Robert to take a look at the Go related config.

R: @lostluck

Comment on lines 30 to 32
# The following source command will not work if executed in a subshell like $ ./this_script.sh. Instead, we need to run it in the current shell as $ . ./this_script.sh.
# However, this is just to load the GOPATH env variable from the previosu command into the current shell. If that's not required, then we can suggest a terminal reload after the execution?
#source ~/.bashrc
Copy link
Contributor

Choose a reason for hiding this comment

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

Is any of this relevant any more or can it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not relevant anymore, removed.

echo "Installing goavro"
go get github.com/linkedin/goavro
# As we are using bash, we are assuming .bashrc exists.
grep -qxF "export GOPATH='${pwd}/sdks/go/examples/.gogradle/project_gopath'" ~/.bashrc || echo "export GOPATH='${pwd}/sdks/go/examples/.gogradle/project_gopath'" >> ~/.bashrc
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to set GOPATH in this script, but not write it to .bashrc? I'm a little worried about messing around with .bashrc files automatically.

We could,

  1. check if GOPATH is set already
  2. if not, set it locally in this script, print out a line to the user telling them to add it to their bashrc file

@lostluck could you review the go related config please?

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 the logic to set the GOPATH variable only for the script session if it's not found in .bashrc and added an echo to remind the user to add it manually.

echo "Installing grpcio-tools and mypy-protobuf"
pip3 install grpcio-tools mypy-protobuf virtualenv
else
echo "Python3 and pip3 are required. Installation Failed."
Copy link
Contributor

Choose a reason for hiding this comment

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

These were installed earlier on line 41 right? That means the installation failed for some reason. Maybe a bit more info in the message would be helpful:

Suggested change
echo "Python3 and pip3 are required. Installation Failed."
echo "Python3 and pip3 are required but failed to install. Install them manually and rerun the script."

Copy link
Contributor Author

@ebarreraWL ebarreraWL Apr 16, 2021

Choose a reason for hiding this comment

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

Line 41 installed pip3 and other tools, then we use pip3 to install additional libraries with it.

Added additional info to the echo to make it explicit that the library is required.

if [ $goExists -eq 0 ]; then
install_go_packages
else
echo "Go is required. Installation Failed."
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, add more info in the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

if [ $python3Exists -eq 0 -a $pip3Exists -eq 0 ]; then
darwin_install_pip3_packages
else
echo "Python3 and pip3 are required. Installation Failed."
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, add more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

if [ $goExists -eq 0 ]; then
install_go_packages
else
echo "Go is required. Installation Failed."
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, add more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -77,3 +77,10 @@ golang {
continueOnFailure = true
}
}

// Run this task to validate the Go environment setup for contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add these any more since they're added in https://github.com/apache/beam/pull/14467/files ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I merged the master (which already has these changes) with this branch to remove this from my PR.

@@ -110,3 +110,15 @@ task startPortableRunner {
}
}
}

// Run this task to validate the python environment setup for contributors
task wordCount {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

if [ $goExists -eq 0 ]; then
install_go_packages
else
echo "Go is required. Install it manually and rerun the script."
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding the link to the install docs: https://golang.org/doc/install

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I will continue the work from here.
Solved in #14584

if [ $goExists -eq 0 ]; then
install_go_packages
else
echo "Go is required. Install it manually and rerun the script."
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding the link to the install docs: https://golang.org/doc/install

Copy link
Contributor

Choose a reason for hiding this comment

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

Solved in #14584

Copy link
Contributor

@tysonjh tysonjh left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you.

@TheNeuralBit
Copy link
Member

TheNeuralBit commented Apr 28, 2021

Is it possible to de-dupe this with the logic for the development container defined in start-build-env.sh? I think there could be value in having both 1) a development docker container, and 2) a script for installing build requirements locally if using a compatible OS (this) , but we should strive to define the requirements in one place.

For example, could we use this script to install requirements within the development container?

@TheNeuralBit
Copy link
Member

Closing this in favor of #14584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants