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-3738] Enable py3 lint and cleanup tox.ini. #4877

Merged
merged 3 commits into from
Mar 23, 2018

Conversation

udim
Copy link
Member

@udim udim commented Mar 16, 2018

The important change here is renaming the lint environments such that Tox will magically use the requested Python version.

@udim udim force-pushed the tox-cleanup branch 3 times, most recently from 7e223cf to f59b8ca Compare March 16, 2018 18:23
@udim udim changed the title [BEAM-3738] Cleanup tox.ini. [BEAM-3738] Enable py3 lint and cleanup tox.ini. Mar 16, 2018
@udim
Copy link
Member Author

udim commented Mar 16, 2018

R: @holdenk @cclauss @aaltay

@udim
Copy link
Member Author

udim commented Mar 16, 2018

run python postcommit

@udim
Copy link
Member Author

udim commented Mar 16, 2018

Missing license was fixed in #4881, retest this please

@holdenk
Copy link
Contributor

holdenk commented Mar 16, 2018

Love the refactor, thanks @udim!

@@ -64,7 +64,7 @@ build.dependsOn buildPython
task lint (dependsOn: 'setupTest') {
doLast {
exec {
commandLine 'tox', '-e', 'lint', '-c', 'tox.ini'
commandLine 'tox', '-e', 'py27-lint', '-c', 'tox.ini'
Copy link
Member

Choose a reason for hiding this comment

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

Should we also run the py3 lint?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@@ -113,11 +113,8 @@ def get_version():
'futures>=3.1.1,<4.0.0',
]

REQUIRED_SETUP_PACKAGES = [
'nose>=1.0',
Copy link
Member

Choose a reason for hiding this comment

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

Is not this required by setup, because test_suite references it?

Copy link

@cclauss cclauss Mar 17, 2018

Choose a reason for hiding this comment

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

Does it make sense to raise REQUIRED_PIP_VERSION = '7.0.0' to something a closer to the current 9.0.3 or do we leave that alone for now? Alternatively, should the process do pip install --upgrade pip?

Copy link
Member Author

Choose a reason for hiding this comment

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

@aaltay setup_requires= lists packages required to run setup.py. I couldn't see why nose is required for that.
Specifying nose in the tests_require= keyword arg is sufficient.

@cclauss I would like to leave it alone in this PR, and I don't have any objection to raising the required version.
Note that creating a new virtualenv installs (at least for me) a version of pip that's newer than the system installed version (9.0.2 vs 9.0.1).

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for us to raise the required version?

Alternatively, should the process do pip install --upgrade pip?
Which process? As far as I know, virtualenv brings a new version of pip with it.

Copy link

Choose a reason for hiding this comment

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

Python packaging has changed a lot in the past three years especially in relation to Python 3 requirements https://pip.pypa.io/en/stable/news We want to avoid compatibility issues in the migration to https://github.com/pypa/warehouse

Copy link

@cclauss cclauss Mar 22, 2018

Choose a reason for hiding this comment

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

The virtualenv does bring a pip but it can be upgraded by pip (bootstrapping).

Copy link
Member

Choose a reason for hiding this comment

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

@cclauss Are you referring to a specific issue? REQUIRED_PIP_VERSION is just the minimum version we require, we are not force downgrading to that version. If there is a known issue in compatibility we can consider raising the minimum supported version

Copy link
Member

Choose a reason for hiding this comment

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

@udim Is it required to run python setup.py test. If not we can drop it.

# Set [] options for pip install, e.g., pip install apache-beam[test].
extras = test
# Always recreate the virtual environment.
recreate = True
Copy link
Member

Choose a reason for hiding this comment

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

Is there a need for this? Would not affect local development?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed. It was convenient for me but I realized it adds 15s to the run.
You can always pass --recreate on the command line.

# Always recreate the virtual environment.
recreate = True
# Pass these environment variables to the test environment.
passenv = TRAVIS*
Copy link
Member

Choose a reason for hiding this comment

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

I believe we do not need this anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed.

commands =
python --version
Copy link
Member

Choose a reason for hiding this comment

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

Printing python and pip version was very useful in debugging issues. Can we keep them?

Copy link

Choose a reason for hiding this comment

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

+1 on this request.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Sphinx==1.6.5
sphinx_rtd_theme==0.2.4
whitelist_externals=time
commands =
python --version
pip --version
time pip install -e .[test,gcp,docs]
Copy link
Member

Choose a reason for hiding this comment

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

Should we use extras instead of [test,gcp,docs]?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

# Shared environment options.
[testenv]
# Set [] options for pip install, e.g., pip install apache-beam[test].
extras = test
Copy link
Member

Choose a reason for hiding this comment

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

How are these extra packages installed? Is it a tox feature?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are not packages, but options for pip when installing the dist tarball. I reworded the comment above.

@udim udim force-pushed the tox-cleanup branch 4 times, most recently from c314f70 to 7d002dc Compare March 22, 2018 02:06
{toxinidir}/run_tox_cleanup.sh
python apache_beam/examples/complete/autocomplete_test.py
python setup.py test
#python setup.py test
Copy link
Member

Choose a reason for hiding this comment

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

left over?

{toxinidir}/run_tox_cleanup.sh
python apache_beam/examples/complete/autocomplete_test.py
python setup.py test
#python setup.py test
{toxinidir}/run_tox_cleanup.sh

[testenv:py27-cython]
Copy link
Member

Choose a reason for hiding this comment

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

What is py27-cython, py27-cython2, py27-cython3 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Please ignore. Testing.

@@ -17,7 +17,8 @@

[tox]
# new environments will be excluded by default unless explicitly added to envlist.
envlist = py27,py27-{gcp,cython,lint},py3-lint,docs
#envlist = py27,py27-{gcp,cython,lint},py3-lint,docs
envlist = py27-cython{,2,3}
Copy link
Member

Choose a reason for hiding this comment

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

left over comment?

@udim
Copy link
Member Author

udim commented Mar 22, 2018

@aaltay the changes you're seeing in the second commit are my attempts at debugging Jenkins runs.

@aaltay
Copy link
Member

aaltay commented Mar 22, 2018

@udim Thank you. Let me know when it is ready for review.

@udim udim force-pushed the tox-cleanup branch 3 times, most recently from 51a14ad to 0e9f1ba Compare March 23, 2018 01:39
- Add BEAM_EXPERIMENTAL_PY3 environment variable. Currently only used to
run the Tox py3-lint environment.
- Rename environments to use factors, such that py27-lint and py3-lint
use Python versions 2.7.x and 3.x.x respectively.
- Remove some redundant package requirements such as nose from being
specified in tox.ini if already present in setup.py.
- Use shared environment settings in tox.ini, under "[testenv]".
- Factor out *.{pyc,c,so} cleanup into a separate script.
@udim
Copy link
Member Author

udim commented Mar 23, 2018

Ready for review and merging if Python checks pass.

Copy link
Member

@aaltay aaltay left a comment

Choose a reason for hiding this comment

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

Thank you @udim. I asked some question for my own learning. I can merge after tests pass.

whitelist_externals=
find
time
cython==0.26.1
Copy link
Member

Choose a reason for hiding this comment

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

Curious why this version? Latest is 0.28.1.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the minimum version required by setup.py (REQUIRED_CYTHON_VERSION). I didn't want to increase the version beyond that and risk breaking things in this PR.

Side note: sdks/python/container/Dockerfile specifies 0.27.2. shrug
I wish all these pinned versions were synced to a single requirements.txt file. (see pip-compile)

Copy link

@cclauss cclauss Mar 23, 2018

Choose a reason for hiding this comment

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

+1 on a single requirements.txt file.

Copy link
Member

Choose a reason for hiding this comment

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

That is fair to not change the version in this PR. We should consider upgrading it.

It would be nice to have a single source of truth. Although I do not see how pip-compile can update the Dockerfile. It is worth filing a JIRA for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

pip-compile can generate requirements.txt from setup.py, and the docker image can pull that in.
The only problem is that we have a different set of requirements depending on the extras specified (such as [test] and [gcp]), or whether cython is used.
So the solution is probably to use a script to generate a set of requirements files, using pip-compile output as an intermediate step. setup.py will be used as the single source of truth for version pinning.


[testenv:py27cython]
# This environment will fail in Jenkins if named "py27-cython".
Copy link
Member

Choose a reason for hiding this comment

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

For my education, do you know why it fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

No bleeding clue. Since I don't have ssh access I can't really debug it.
Honestly I'm glad I got it working.

REQUIRED_TEST_PACKAGES = [
'nose>=1.3.7',
Copy link
Member

Choose a reason for hiding this comment

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

Why are we increasing the required version for nose?

Copy link
Member Author

Choose a reason for hiding this comment

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

tox.ini already required 1.3.7. I thought this would be a no-op.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also wanted to merge requirements. Now only setup.py has the nose requirement.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

@aaltay aaltay merged commit dbadcab into apache:master Mar 23, 2018
@udim udim deleted the tox-cleanup branch March 23, 2018 18:42
tvalentyn added a commit to tvalentyn/beam-site that referenced this pull request Apr 10, 2018
Changes to tox.ini were done in apache/beam#4877.
asfgit pushed a commit to apache/beam-site that referenced this pull request Apr 11, 2018
Changes to tox.ini were done in apache/beam#4877.
kennknowles pushed a commit to kennknowles/beam that referenced this pull request Jun 1, 2018
Changes to tox.ini were done in apache#4877.
robertwb pushed a commit to robertwb/incubator-beam that referenced this pull request Jun 5, 2018
Changes to tox.ini were done in apache#4877.
robertwb pushed a commit to robertwb/incubator-beam that referenced this pull request Jun 5, 2018
Changes to tox.ini were done in apache#4877.
melap pushed a commit that referenced this pull request Jun 20, 2018
Changes to tox.ini were done in #4877.
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.

None yet

4 participants