[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! |
| doLast { | ||
| exec { | ||
| commandLine 'tox', '-e', 'lint', '-c', 'tox.ini' | ||
| commandLine 'tox', '-e', 'py27-lint', '-c', 'tox.ini' |
There was a problem hiding this comment.
Should we also run the py3 lint?
| ] | ||
|
|
||
| REQUIRED_SETUP_PACKAGES = [ | ||
| 'nose>=1.0', |
There was a problem hiding this comment.
Is not this required by setup, because test_suite references it?
There was a problem hiding this comment.
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.
@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.
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.
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.
The virtualenv does bring a pip but it can be upgraded by pip (bootstrapping).
There was a problem hiding this comment.
@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.
@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 |
There was a problem hiding this comment.
Is there a need for this? Would not affect local development?
There was a problem hiding this comment.
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* |
There was a problem hiding this comment.
I believe we do not need this anymore.
| grpcio-tools==1.3.5 | ||
| whitelist_externals=find | ||
| commands = | ||
| python --version |
There was a problem hiding this comment.
Printing python and pip version was very useful in debugging issues. Can we keep them?
| commands = | ||
| python --version | ||
| pip --version | ||
| time pip install -e .[test,gcp,docs] |
There was a problem hiding this comment.
Should we use extras instead of [test,gcp,docs]?
| # 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.
How are these extra packages installed? Is it a tox feature?
There was a problem hiding this comment.
These are not packages, but options for pip when installing the dist tarball. I reworded the comment above.
c314f70 to
7d002dc
Compare
| {toxinidir}/run_tox_cleanup.sh | ||
| python apache_beam/examples/complete/autocomplete_test.py | ||
| python setup.py test | ||
| #python setup.py test |
| #python setup.py test | ||
| {toxinidir}/run_tox_cleanup.sh | ||
|
|
||
| [testenv:py27-cython] |
There was a problem hiding this comment.
What is py27-cython, py27-cython2, py27-cython3 ?
| # 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} |
|
@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. |
| whitelist_externals= | ||
| find | ||
| time | ||
| cython==0.26.1 |
There was a problem hiding this comment.
Curious why this version? Latest is 0.28.1.
There was a problem hiding this comment.
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.
+1 on a single requirements.txt file.
There was a problem hiding this comment.
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.
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.
| {toxinidir}/run_tox_cleanup.sh | ||
|
|
||
| [testenv:py27cython] | ||
| # This environment will fail in Jenkins if named "py27-cython". |
There was a problem hiding this comment.
For my education, do you know why it fails?
There was a problem hiding this comment.
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.
Why are we increasing the required version for nose?
There was a problem hiding this comment.
tox.ini already required 1.3.7. I thought this would be a no-op.
There was a problem hiding this comment.
I also wanted to merge requirements. Now only setup.py has the nose requirement.
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.