-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add pyproject.toml #28385
Add pyproject.toml #28385
Conversation
R : @tvalentyn |
Codecov Report
@@ Coverage Diff @@
## master #28385 +/- ##
===========================================
- Coverage 72.16% 38.36% -33.81%
===========================================
Files 686 686
Lines 101554 101672 +118
===========================================
- Hits 73291 39009 -34282
- Misses 26684 61087 +34403
+ Partials 1579 1576 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 310 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Assigning reviewers. If you would like to opt out of this review, comment R: @riteshghorse for label python. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Run Seed Job |
retest this please |
Run Seed Job |
retest this please |
} | ||
} | ||
|
||
getVersionsAsList('python_versions').each { 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.
left over work. remove this
Run Seed Job |
retest this please |
Run Seed Job |
retest this please |
pip install 'pandas>=1.0,<1.5' | ||
python setup.py develop | ||
python install -e . |
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 this be pip install
?
project.exec { | ||
executable 'sh' | ||
args '-c', ". ${project.ext.envdir}/bin/activate && cd ${copiedPyRoot} && scripts/run_tox.sh $tox_env $distTarBall '$posargs'" | ||
if (project.hasProperty('useWheelDistribution')) { |
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 do we need both modes?
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.
Precommits running unittest will have this flag and we will use wheels to install apache beam for precommit tests. For tasks like pylint, docs, mypy, we don't need installation of wheels. Tox will take care of running these suits by installing required deps.
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.
wdyt about automatically adding useWheelDistribution
whenever platform is linux so that we don't have to add it in individual test suites?
sdks/python/setup.py
Outdated
install_requires=[ | ||
'build>=0.9.0,<0.11.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.
interesting. is it common to add build as a dependency ? Also why not 1.x ?
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.
Since we use it in stager.py, I added it so that it won't cause a breaking change for the users.
It seems 1.x was released recently. I will change the bounds. Thanks for noticing. I made this commit a long time back :p
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 think it should at most be an optional dependency, like snappy
@@ -42,5 +42,5 @@ project.tasks.register("preCommitPy${pythonVersionSuffix}") { | |||
dependsOn = ["testPy38Cython"] | |||
} else { | |||
dependsOn = ["testPy${pythonVersionSuffix}Cloud", "testPy${pythonVersionSuffix}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.
unnecessary change
sdks/python/apache_beam/runners/dataflow/internal/clients/cloudbuild/__init__.py
Outdated
Show resolved
Hide resolved
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 addressed few comments. I need to take a look on the unanswered comments. In the mean time, LMK if you have anymore questions
project.exec { | ||
executable 'sh' | ||
args '-c', ". ${project.ext.envdir}/bin/activate && cd ${copiedPyRoot} && scripts/run_tox.sh $tox_env $distTarBall '$posargs'" | ||
if (project.hasProperty('useWheelDistribution')) { |
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.
Precommits running unittest will have this flag and we will use wheels to install apache beam for precommit tests. For tasks like pylint, docs, mypy, we don't need installation of wheels. Tox will take care of running these suits by installing required deps.
@@ -25,14 +25,17 @@ | |||
from apache_beam.coders.coders_test_common import * | |||
|
|||
|
|||
@unittest.skip( | |||
'Add a test for non-compiled implementation.' | |||
'https://github.com/apache/beam/issues/28307') |
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.
Sg. I will follow up in a different PR
@@ -103,6 +102,51 @@ def _load_or_default(filename): | |||
return {} | |||
|
|||
|
|||
_DESTINATION_ELEMENT_PAIRS = [ |
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.
https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#which-import-mode
_ELEMENTS
is not able to imported. I suspect it's because we use --import-mode=importlib
in pytest command and in the documentation above, they state that test modules are not importable by each other.
sdks/python/setup.py
Outdated
install_requires=[ | ||
'build>=0.9.0,<0.11.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.
Since we use it in stager.py, I added it so that it won't cause a breaking change for the users.
It seems 1.x was released recently. I will change the bounds. Thanks for noticing. I made this commit a long time back :p
args '-c', ". ${project.ext.envdir}/bin/activate && cd ${copiedPyRoot} && scripts/run_tox.sh $tox_env $distTarBall '$posargs'" | ||
if (project.hasProperty('useWheelDistribution')) { | ||
def pythonVersionNumber = project.ext.pythonVersion.replace('.', '') | ||
dependsOn ":sdks:python:bdistPy${pythonVersionNumber}linux" |
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 do we know the platform for the wheel? we have many different test suites.
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.
All the tests that use this flag run on Linux.
@@ -26,11 +26,12 @@ astunparse==1.6.3 | |||
attrs==23.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.
i'd revert changes to these for now while you are iterating on the pr.
16c21e0
to
0014b5a
Compare
Update numpy bounds
Update setup.py Remove ImportError from gen_protos.py Update subprocess run and raise RuntimeError if proto generation fails Print output of setup.py Fix linting issues
Modify buildPython task
Upgrade pip in Dockerfile Move _ELEMENTS to shared file. tests are not importable by each other Add missing element Remove shared_test_variables Remove installing wheel in a test suite Retry run_tox.sh with no installPkg flag Remove natural language test. codepath is covered in the postCommits. Add back tox exit code
FIx toxTask name Add no-extra test suite to precommit and remove GH duplicate ubuntu test Skip failing non-cython test Fix tox test name
0014b5a
to
dad39ec
Compare
Run Seed Job |
Run Python_Coverage PreCommit |
Run Python_PVR_Flink PreCommit |
Run Java PreCommit |
https://ci-beam.apache.org/job/beam_PreCommit_Python_Coverage_Phrase/69/ - python coverage test suite passes with expected changes on Jenkins. For GHA, it will be reflected once it is merged. |
If there are any failures, please comment here and I will try to forward fix it. |
This reverts commit a94d29f.
* Add pyproject.toml Update numpy bounds * Use subprocess to run grpcio since it is not imported in pyproject.toml Update setup.py Remove ImportError from gen_protos.py Update subprocess run and raise RuntimeError if proto generation fails Print output of setup.py Fix linting issues * Remove build-requirements.txt and use build to build the sdist Modify buildPython task * Use wheels to run tox precommit tests Upgrade pip in Dockerfile Move _ELEMENTS to shared file. tests are not importable by each other Add missing element Remove shared_test_variables Remove installing wheel in a test suite Retry run_tox.sh with no installPkg flag Remove natural language test. codepath is covered in the postCommits. Add back tox exit code * Remove cython tests. default tests will run with Cython extensions FIx toxTask name Add no-extra test suite to precommit and remove GH duplicate ubuntu test Skip failing non-cython test Fix tox test name * Force type cast inputs to list * Update stager to use build. If it fails, use legacy setup to build sdist Fix mypy issue * Remove cython env and build-requirements for tox.ini
It seems ARM postcommit were failing after this change: Last passed run https://github.com/apache/beam/actions/runs/6499261265 at 223dded (before it was flaky on some of the py version but at least one py version could succeed) First failing run https://github.com/apache/beam/actions/runs/6502267792/job/17661039890 at 0586161 there are 4 PRs merged and this is the only python change the error message is
|
From this run - https://github.com/apache/beam/actions/runs/6502267792/job/17661040535, I see one of the tests in the postcommits is failing. It was also seen on Jenkins. I have merged the solution 20 hours back. PTAL #28990. That would solve the failing test. let's monitor the tests and see if they go green for the next runs. |
I started a run - https://github.com/apache/beam/actions/runs/6550155250 on the master. Will monitor it for any related failures to this PR. |
{ | ||
'name': 'spark', 'language': 'py' | ||
}, | ||
{ |
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.
Just curious, are lines 117 - 119 here a typo? It seems to be a repeat of 111-113.
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.
_ELEMENTS = [elm[1] for elm in _DESTINATION_ELEMENT_PAIRS] |
it is the same as the above variable. It is defined here because when using pytest with --import-mode=importlib
, the test modules are not importable by each other hence we defined the same variable statically here.
Context
This PR provides
Replace
setup.py sdist
with build. This will install the build dependencies in an isolated environments and then generates sdist. Setuptools itself strongly suggests using this and to avoid usingsetup.py sdist
since it is treated as deprecated. You can find more at https://github.com/pypa/setuptools/blob/245d72a8aa4d47e1811425213aba2a06a0bb64fa/docs/deprecated/commands.rst#L10python -m build
Remove the
build-requirements.txt
since we move those dependencies intopyproject.toml
.Remove the code in
gen_protos.py
where we installbuild dependencies
. This is not required since build-requirements are always installed from pyporject.tomlOther notable changes:
grpcio
is not importable during distribution creation, therefore callgen_protos.py
in a subprocess..zip
to.tar.gz
since we are going to usebuild
module for building sdistFixes: #20051
Fixes: #26266
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
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, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.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)
See CI.md for more information about GitHub Actions CI.