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-5878] add tests for kwonly args in python 3 #8505

Merged
merged 3 commits into from
May 31, 2019
Merged

Conversation

Juta
Copy link
Contributor

@Juta Juta commented May 6, 2019

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java 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 --- --- ---

Pre-Commit Tests Status (on master branch)

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

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

@Juta
Copy link
Contributor Author

Juta commented May 6, 2019

R: @tvalentyn


result3 = pcol | 'compute3' >> beam.FlatMap(
sort_with_side_inputs)
assert_that(result3, equal_to([]), label='assert3')
Copy link
Contributor

Choose a reason for hiding this comment

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

(didn't look into the logic in detail yet) is the result supposed to be empty here and in line 64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes because it joins with the side input and in this case there is no side input

@Juta
Copy link
Contributor Author

Juta commented May 7, 2019

@tvalentyn The test currently fails on pylint 2.7 because the syntax of keyword only args gives a syntax-error in python 2. Should I add a pylint disable syntax-error comment or is there an other way to skip this file for python 2?

@tvalentyn
Copy link
Contributor

Let's try to disable a particular pylint warning and add a comment.
# Keyword-only arguments are not available on Python 2
# pylint: disable=wrong-....

@Juta
Copy link
Contributor Author

Juta commented May 7, 2019

@tvalentyn Apparently # pylint disable=syntax-error is not possible: pylint-dev/pylint#986. I can only think of fixing it by adding it as an exception in pylint2.7: https://github.com/apache/beam/blob/master/sdks/python/scripts/run_pylint.sh#L73. What do you think?

@tvalentyn
Copy link
Contributor

Adding as exception sounds good to me. Is it possible to add and exception on Python 2 lint only? If that's hard, you can file a Jira and add a comment to clean this up eventually.

@Juta Juta force-pushed the keywords branch 3 times, most recently from a4796f6 to 7a169c2 Compare May 10, 2019 14:42
@tvalentyn
Copy link
Contributor

It looks like the suite still fails on Py2 due to unsupported syntax.

@Juta Juta force-pushed the keywords branch 4 times, most recently from 1960b43 to 403b5ed Compare May 20, 2019 12:09
@Juta
Copy link
Contributor Author

Juta commented May 20, 2019

@tvalentyn PTAL

Copy link
Contributor

@tvalentyn tvalentyn left a comment

Choose a reason for hiding this comment

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

Thanks a lot, this is great! Left a few minor comments.

pipeline = TestPipeline()

# Keyword-only arguments are not available on Python 2
# pylint: disable=syntax-error
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover comment?

result1 = pcoll | 'sum1' >> beam.ParDo(MyDoFn(), 5, 8, bound=15)
result2 = pcoll | 'sum2' >> beam.ParDo(MyDoFn(), 5, 8)
result3 = pcoll | 'sum3' >> beam.ParDo(MyDoFn())
result4 = pcoll | 'sum4' >> beam.ParDo(MyDoFn(), bound=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could select a smaller bound (5) here for result4 to be different.

result1 = pcoll | 'sum1' >> beam.CombineGlobally(bounded_sum, 5, 8, bound=20)
result2 = pcoll | 'sum2' >> beam.CombineGlobally(bounded_sum, 5, 8)
result3 = pcoll | 'sum3' >> beam.CombineGlobally(bounded_sum)
result4 = pcoll | 'sum4' >> beam.CombineGlobally(bounded_sum, bound=12)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could select a smaller bound here for result4 to be different.

@@ -60,8 +60,15 @@ EXCLUDED_GENERATED_FILES=(
apache_beam/portability/api/*pb2*.py
)

# Following files contain python 3 syntax and are excluded from pylint in python 2
EXCLUDED_PYTHON3_FILES=(
"apache_beam/transforms/transforms_keyword_only_args_py3_test.py"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add # TODO(BEAM-7372): Remove this list once Python 2 is no longer supported and drop _py3_test suffix.

@@ -60,8 +60,15 @@ EXCLUDED_GENERATED_FILES=(
apache_beam/portability/api/*pb2*.py
)

# Following files contain python 3 syntax and are excluded from pylint in python 2
EXCLUDED_PYTHON3_FILES=(
"apache_beam/transforms/transforms_keyword_only_args_py3_test.py"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think _py3_only_test may be a more explicit suffix, how about we use that?
Also could this be a regex pattern .*_py3_only_test.py?

@Juta Juta force-pushed the keywords branch 2 times, most recently from e113e64 to ae5da58 Compare May 21, 2019 11:32
@Juta
Copy link
Contributor Author

Juta commented May 21, 2019

Run Python PreCommit

@Juta Juta force-pushed the keywords branch 2 times, most recently from c0c5abd to 5f0c245 Compare May 21, 2019 16:19
@Juta
Copy link
Contributor Author

Juta commented May 27, 2019

@tvalentyn PTAL

Copy link
Contributor

@tvalentyn tvalentyn left a comment

Choose a reason for hiding this comment

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

Thanks, @Juta.
@aaltay could you please help with the merge?

@aaltay aaltay merged commit 15d0341 into apache:master May 31, 2019
@apilloud
Copy link
Member

apilloud commented Jun 3, 2019

After this change beam_PostCommit_Python_Verify :sdks:python:postCommitIT and other tests are failing due to a syntax error. I filed an issue: https://issues.apache.org/jira/browse/BEAM-7481

tvalentyn added a commit to tvalentyn/beam that referenced this pull request Jun 3, 2019
lazylynx added a commit to lazylynx/beam that referenced this pull request Aug 2, 2019
lazylynx added a commit to lazylynx/beam that referenced this pull request Aug 3, 2019
lazylynx added a commit to lazylynx/beam that referenced this pull request Aug 3, 2019
tvalentyn pushed a commit that referenced this pull request Sep 3, 2019
* Also add back the unit tests introduced in #8505 with minor changes.
soyrice pushed a commit to soyrice/beam that referenced this pull request Sep 19, 2019
* Also add back the unit tests introduced in apache#8505 with minor changes.
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