Skip to content

Conversation

@benEng
Copy link
Contributor

@benEng benEng commented Oct 7, 2022

Resolves #22983


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

@benEng
Copy link
Contributor Author

benEng commented Oct 7, 2022

Run Python Examples_Direct

@benEng
Copy link
Contributor Author

benEng commented Oct 7, 2022

Run Python Examples_Dataflow

@benEng
Copy link
Contributor Author

benEng commented Oct 7, 2022

@tvalentyn could you help me to approve running workflows to test my fixes?

@benEng
Copy link
Contributor Author

benEng commented Oct 7, 2022

Run Python Examples_Flink

@benEng
Copy link
Contributor Author

benEng commented Oct 7, 2022

Run Python Examples_Spark

@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Merging #23546 (08e88a8) into master (9192cb9) will decrease coverage by 0.36%.
The diff coverage is 20.00%.

@@            Coverage Diff             @@
##           master   #23546      +/-   ##
==========================================
- Coverage   73.46%   73.09%   -0.37%     
==========================================
  Files         718      729      +11     
  Lines       95884    98231    +2347     
==========================================
+ Hits        70438    71799    +1361     
- Misses      24135    25121     +986     
  Partials     1311     1311              
Flag Coverage Δ
python 82.36% <20.00%> (-0.86%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
sdks/python/apache_beam/testing/test_utils.py 90.52% <18.18%> (-9.48%) ⬇️
sdks/python/apache_beam/examples/complete/tfidf.py 73.43% <25.00%> (-24.95%) ⬇️
...python/apache_beam/examples/complete/distribopt.py 0.00% <0.00%> (-98.57%) ⬇️
...hon/apache_beam/examples/cookbook/mergecontacts.py 23.21% <0.00%> (-73.22%) ⬇️
...he_beam/examples/cookbook/multiple_output_pardo.py 37.50% <0.00%> (-58.34%) ⬇️
...python/apache_beam/examples/wordcount_debugging.py 38.77% <0.00%> (-57.15%) ⬇️
...python/apache_beam/examples/dataframe/wordcount.py 38.46% <0.00%> (-53.85%) ⬇️
...s/python/apache_beam/examples/wordcount_minimal.py 40.74% <0.00%> (-51.86%) ⬇️
sdks/python/apache_beam/examples/wordcount.py 48.27% <0.00%> (-44.83%) ⬇️
...apache_beam/examples/cookbook/custom_ptransform.py 52.38% <0.00%> (-42.86%) ⬇️
... and 62 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@benEng
Copy link
Contributor Author

benEng commented Oct 10, 2022

Run Python Examples_Spark

@benEng
Copy link
Contributor Author

benEng commented Oct 11, 2022

@tvalentyn I've fixed some of the examples so those can run in Dataflow, but a couple of them are failing https://ci-beam.apache.org/job/beam_PostCommit_Python_Examples_Dataflow_PR/20/ not sure why those are having differences in the assertions, do you have some insight to fix them easily or do you think it is better to sickbay those for the Dataflow suite and fill a new issue?

@benEng
Copy link
Contributor Author

benEng commented Oct 11, 2022

@tvalentyn
Copy link
Contributor

Filing issues and sickbaying sounds good

@tvalentyn
Copy link
Contributor

thank you

@benEng
Copy link
Contributor Author

benEng commented Oct 12, 2022

Run Python Examples_Dataflow

@benEng benEng marked this pull request as ready for review October 12, 2022 21:59
@github-actions
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @TheNeuralBit for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Copy link
Member

@TheNeuralBit TheNeuralBit 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! I have a few suggestions

try:
from apache_beam.io.gcp import gcsio
except ImportError:
gcsio = None
Copy link
Member

Choose a reason for hiding this comment

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

Does this actually protect us? It looks like this would just change the error to a more confusing one: None has no attribure GcsIO, when gcsio is used. I think just letting the ImportError raise would be preferable.

Alternatively we could add a skipIf(gcsio is None), but that might lead to us unintentionally skipping it indefinitely.

logging.info('Creating file: %s', path)
gcs = gcsio.GcsIO()
with gcs.open(path, 'w') as f:
f.write(str.encode(contents, 'utf-8'))
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think it would be better if these utilities used the Filesystems API, see here for an example:

def read_csv(path):
with FileSystems.open(path) as fp:
return pd.read_csv(fp)
result = pd.concat(
read_csv(metadata.path) for metadata in FileSystems.match(
[f'{self.output_path}*'])[0].metadata_list)
result = result.sort_values('Borough').reset_index(drop=True)

It would also be good to extract these out into testing.utils rather than copying them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @TheNeuralBit, I applied some of your suggestions

@benEng
Copy link
Contributor Author

benEng commented Oct 20, 2022

Run Python Examples_Dataflow

@benEng
Copy link
Contributor Author

benEng commented Oct 20, 2022

Run Python Examples_Direct

@TheNeuralBit TheNeuralBit self-requested a review October 20, 2022 21:55
@github-actions
Copy link
Contributor

Reminder, please take a look at this pr: @TheNeuralBit

@benEng
Copy link
Contributor Author

benEng commented Nov 1, 2022

Run Python PreCommit

1 similar comment
@TheNeuralBit
Copy link
Member

Run Python PreCommit

@TheNeuralBit
Copy link
Member

Run Python 3.8 PostCommit

@TheNeuralBit TheNeuralBit merged commit c6f64bb into apache:master Nov 1, 2022
@benEng
Copy link
Contributor Author

benEng commented Nov 1, 2022

Thanks, @TheNeuralBit!

ruslan-ikhsan pushed a commit to akvelon/beam that referenced this pull request Nov 11, 2022
* Fix tests for examples not running in Dataflow

* Remove unused test

* Add todos to enable test for Dataflow

* Refactor utilities functions to create and read files

* Fix lint errors

* Fix lint errors and skip tests that require gcsio and is not available

* Refactor read file function and remove gcsio dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Some test from DataflowExamples suite may not be running on Dataflow.

3 participants