-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
7e223cf
to
f59b8ca
Compare
run python postcommit |
Missing license was fixed in #4881, retest this please |
Love the refactor, thanks @udim! |
sdks/python/build.gradle
Outdated
@@ -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' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
sdks/python/tox.ini
Outdated
# Set [] options for pip install, e.g., pip install apache-beam[test]. | ||
extras = test | ||
# Always recreate the virtual environment. | ||
recreate = True |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
sdks/python/tox.ini
Outdated
# Always recreate the virtual environment. | ||
recreate = True | ||
# Pass these environment variables to the test environment. | ||
passenv = TRAVIS* |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
sdks/python/tox.ini
Outdated
commands = | ||
python --version |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on this request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
sdks/python/tox.ini
Outdated
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] |
There was a problem hiding this comment.
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]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sdks/python/tox.ini
Outdated
# Shared environment options. | ||
[testenv] | ||
# Set [] options for pip install, e.g., pip install apache-beam[test]. | ||
extras = test |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c314f70
to
7d002dc
Compare
sdks/python/tox.ini
Outdated
{toxinidir}/run_tox_cleanup.sh | ||
python apache_beam/examples/complete/autocomplete_test.py | ||
python setup.py test | ||
#python setup.py test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
sdks/python/tox.ini
Outdated
{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] |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ignore. Testing.
sdks/python/tox.ini
Outdated
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over comment?
@aaltay the changes you're seeing in the second commit are my attempts at debugging Jenkins runs. |
@udim Thank you. Let me know when it is ready for review. |
51a14ad
to
0e9f1ba
Compare
- 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.
Ready for review and merging if Python checks pass. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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". |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
Changes to tox.ini were done in apache/beam#4877.
Changes to tox.ini were done in apache/beam#4877.
Changes to tox.ini were done in apache#4877.
Changes to tox.ini were done in apache#4877.
Changes to tox.ini were done in apache#4877.
Changes to tox.ini were done in #4877.
The important change here is renaming the lint environments such that Tox will magically use the requested Python version.