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-13016] Remove avro-python3 dependency from Beam #15900

Merged
merged 12 commits into from
Nov 11, 2021

Conversation

AnandInguva
Copy link
Contributor

@AnandInguva AnandInguva commented Nov 4, 2021

Remove the support for avro and make fastavro as default to read Avro files. use_fastavro=False would still use fastAvro as default and merely kept for backward compatibility .

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).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • 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.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status Build Status Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
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
Build Status Build Status ---
XLang Build Status Build Status Build Status Build Status Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

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

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

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

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

@tvalentyn
Copy link
Contributor

Run Python 3.8 Postcommit

@tvalentyn
Copy link
Contributor

Run Python 3.8 PostCommit

@tvalentyn
Copy link
Contributor

Run PythonLint PreCommit

1 similar comment
@tvalentyn
Copy link
Contributor

Run PythonLint PreCommit

@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #15900 (5c1eb58) into master (c04a2a8) will increase coverage by 0.06%.
The diff coverage is 58.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15900      +/-   ##
==========================================
+ Coverage   83.53%   83.59%   +0.06%     
==========================================
  Files         445      445              
  Lines       61385    61284     -101     
==========================================
- Hits        51278    51231      -47     
+ Misses      10107    10053      -54     
Impacted Files Coverage Δ
sdks/python/apache_beam/examples/avro_bitcoin.py 0.00% <0.00%> (ø)
sdks/python/apache_beam/io/gcp/bigquery.py 62.72% <0.00%> (ø)
...ython/apache_beam/io/gcp/bigquery_read_internal.py 53.92% <0.00%> (ø)
...on/apache_beam/runners/dataflow/dataflow_runner.py 82.34% <ø> (-0.05%) ⬇️
sdks/python/apache_beam/io/avroio.py 97.95% <75.00%> (+37.35%) ⬆️
...hon/apache_beam/runners/dataflow/internal/names.py 100.00% <100.00%> (ø)
...s/python/apache_beam/testing/datatype_inference.py 94.59% <100.00%> (-0.53%) ⬇️
sdks/python/apache_beam/utils/interactive_utils.py 87.80% <0.00%> (-7.32%) ⬇️
...eam/portability/api/beam_expansion_api_pb2_grpc.py 57.89% <0.00%> (-4.02%) ⬇️
...eam/portability/api/beam_provision_api_pb2_grpc.py 73.68% <0.00%> (-2.51%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c04a2a8...5c1eb58. Read the comment docs.

@AnandInguva
Copy link
Contributor Author

retest this please

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.

Let's advertise this change in CHANGES.md so that it is visible in release notes.

sdks/python/setup.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/examples/fastavro_it_test.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/io/avroio.py Show resolved Hide resolved
@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

Even though use_fastavro can be passed as an input parameter, it would have no effect.
@AnandInguva
Copy link
Contributor Author

@pabloem @tvalentyn Can you review the PR? thanks.

@pabloem
Copy link
Member

pabloem commented Nov 8, 2021

Run Python 3.8 PostCommit

sdks/python/apache_beam/io/avroio.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/io/avroio.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/examples/fastavro_it_test.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/examples/fastavro_it_test.py Outdated Show resolved Hide resolved
@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

CHANGES.md Outdated Show resolved Hide resolved
AnandInguva and others added 2 commits November 10, 2021 00:17
Co-authored-by: tvalentyn <tvalentyn@users.noreply.github.com>
@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

1 similar comment
@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

| CoGroupByKey() \
fastavro_read_pipeline \
| 'create-fastavro' >> Create(['%s*' % fastavro_output]) \
| 'read-fastavro' >> ReadAllFromAvro() \
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also compare the values for the keys, to make sure that no values were not lost during write-read operation?
I think it could be accomplished by running co-GBK of a pcollection coming form | 'read-fastavro' >> ReadAllFromAvro() \, and pcollection of generated data. Then, we can extract the set of elements tagged with first pcollection, and the second pcollection, and verify that these sets are the same for all elements in GBK output.

Copy link
Contributor Author

@AnandInguva AnandInguva Nov 11, 2021

Choose a reason for hiding this comment

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

I changed according to the above suggestions. Can you verify if the pipeline looks okay?

@AnandInguva
Copy link
Contributor Author

Run Python 3.8 PostCommit

record_pcoll_values = v['record_pcoll']
fastavro_values = v['fastavro']
assertEqual(record_pcoll_values, fastavro_values)
assertEqual(len(record_pcoll_values), 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

What guarantees that we have unique keys for each record (so that after GBK we only have 1 value per key)?

Copy link
Contributor Author

@AnandInguva AnandInguva Nov 11, 2021

Choose a reason for hiding this comment

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

We will have unique keys for each record as the keys are integers in ascending order. This is an example of the output after CoGroupByKey. Here the number of records are 20 and keys are the integer(number attribute of the pcollection)

(0, {'record_pcoll': [{'label': 'abc', 'number': 0, 'number_str': '0', 'color': 'RED'}], 'fastavro': [{'label': 'abc', 'number': 0, 'number_str': '0', 'color': 'RED'}]}) (1, {'record_pcoll': [{'label': 'def', 'number': 1, 'number_str': '1', 'color': 'ORANGE'}], 'fastavro': [{'label': 'def', 'number': 1, 'number_str': '1', 'color': 'ORANGE'}]}) (2, {'record_pcoll': [{'label': 'ghi', 'number': 2, 'number_str': '2', 'color': 'YELLOW'}], 'fastavro': [{'label': 'ghi', 'number': 2, 'number_str': '2', 'color': 'YELLOW'}]}) (3, {'record_pcoll': [{'label': 'jkl', 'number': 3, 'number_str': '3', 'color': 'GREEN'}], 'fastavro': [{'label': 'jkl', 'number': 3, 'number_str': '3', 'color': 'GREEN'}]}) (4, {'record_pcoll': [{'label': 'mno', 'number': 4, 'number_str': '4', 'color': 'BLUE'}], 'fastavro': [{'label': 'mno', 'number': 4, 'number_str': '4', 'color': 'BLUE'}]}) (5, {'record_pcoll': [{'label': 'pqr', 'number': 5, 'number_str': '5', 'color': 'PURPLE'}], 'fastavro': [{'label': 'pqr', 'number': 5, 'number_str': '5', 'color': 'PURPLE'}]}) (6, {'record_pcoll': [{'label': 'stu', 'number': 6, 'number_str': '6', 'color': None}], 'fastavro': [{'label': 'stu', 'number': 6, 'number_str': '6', 'color': None}]}) (7, {'record_pcoll': [{'label': 'vwx', 'number': 7, 'number_str': '7', 'color': 'RED'}], 'fastavro': [{'label': 'vwx', 'number': 7, 'number_str': '7', 'color': 'RED'}]}) (8, {'record_pcoll': [{'label': 'abc', 'number': 8, 'number_str': '8', 'color': 'ORANGE'}], 'fastavro': [{'label': 'abc', 'number': 8, 'number_str': '8', 'color': 'ORANGE'}]}) (9, {'record_pcoll': [{'label': 'def', 'number': 9, 'number_str': '9', 'color': 'YELLOW'}], 'fastavro': [{'label': 'def', 'number': 9, 'number_str': '9', 'color': 'YELLOW'}]}) (10, {'record_pcoll': [{'label': 'ghi', 'number': 10, 'number_str': '10', 'color': 'GREEN'}], 'fastavro': [{'label': 'ghi', 'number': 10, 'number_str': '10', 'color': 'GREEN'}]}) (11, {'record_pcoll': [{'label': 'jkl', 'number': 11, 'number_str': '11', 'color': 'BLUE'}], 'fastavro': [{'label': 'jkl', 'number': 11, 'number_str': '11', 'color': 'BLUE'}]}) (12, {'record_pcoll': [{'label': 'mno', 'number': 12, 'number_str': '12', 'color': 'PURPLE'}], 'fastavro': [{'label': 'mno', 'number': 12, 'number_str': '12', 'color': 'PURPLE'}]}) (13, {'record_pcoll': [{'label': 'pqr', 'number': 13, 'number_str': '13', 'color': None}], 'fastavro': [{'label': 'pqr', 'number': 13, 'number_str': '13', 'color': None}]}) (14, {'record_pcoll': [{'label': 'stu', 'number': 14, 'number_str': '14', 'color': 'RED'}], 'fastavro': [{'label': 'stu', 'number': 14, 'number_str': '14', 'color': 'RED'}]}) (15, {'record_pcoll': [{'label': 'vwx', 'number': 15, 'number_str': '15', 'color': 'ORANGE'}], 'fastavro': [{'label': 'vwx', 'number': 15, 'number_str': '15', 'color': 'ORANGE'}]}) (16, {'record_pcoll': [{'label': 'abc', 'number': 16, 'number_str': '16', 'color': 'YELLOW'}], 'fastavro': [{'label': 'abc', 'number': 16, 'number_str': '16', 'color': 'YELLOW'}]}) (17, {'record_pcoll': [{'label': 'def', 'number': 17, 'number_str': '17', 'color': 'GREEN'}], 'fastavro': [{'label': 'def', 'number': 17, 'number_str': '17', 'color': 'GREEN'}]}) (18, {'record_pcoll': [{'label': 'ghi', 'number': 18, 'number_str': '18', 'color': 'BLUE'}], 'fastavro': [{'label': 'ghi', 'number': 18, 'number_str': '18', 'color': 'BLUE'}]}) (19, {'record_pcoll': [{'label': 'jkl', 'number': 19, 'number_str': '19', 'color': 'PURPLE'}], 'fastavro': [{'label': 'jkl', 'number': 19, 'number_str': '19', 'color': 'PURPLE'}]})

@tvalentyn tvalentyn merged commit e9ebaa4 into apache:master Nov 11, 2021
)
result = self.test_pipeline.run()
result.wait_until_finish()
fastavro_pcoll = self.test_pipeline \
Copy link
Contributor

Choose a reason for hiding this comment

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

For future changes, prefer not to use \ for concatenating strings, since it's error prone. Using brackets is preferable.
From PEP8: (https://www.python.org/dev/peps/pep-0008/)

The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.

(this was a preexisting issue in this file).

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.

3 participants