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

Add Lineage metrics to Python PubsubIO, BigtableIO, FileIO #32430

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Sep 11, 2024

Please add a meaningful description for your change here


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

  • 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 or the workflows README to see a list of phrases to trigger workflows.

@Abacn
Copy link
Contributor Author

Abacn commented Sep 12, 2024

For PubsubIO and BigtableIO, unit test added. For FileIO, because it needs real gcs, and Dataflow runner currently does not return metrics back, tested locally with the following pipeline

with beam.Pipeline("DirectRunner", options) as p:
    p_read = p | ReadFromText(file_pattern='gs://dataflow-samples/shakespeare/kinghenry*') \
       | WriteToText(file_path_prefix='gs://clouddfe-yihu-test/tmp/fileiolineage')
    print(Lineage.query(p.result.metrics(), Lineage.SOURCE))
    print(Lineage.query(p.result.metrics(), Lineage.SINK))

see output:

{'gcs:dataflow-samples.`shakespeare/kinghenryviii.txt`', 'gcs:dataflow-samples.`shakespeare/kinghenryv.txt`'}
{'gcs:clouddfe-yihu-test.tmp/fileiolineage-00000-of-00001'}

@Abacn Abacn marked this pull request as ready for review September 12, 2024 02:07
Copy link
Contributor

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

R: @shunping for label python.
R: @shunping for label io.
R: @igorbernstein2 for label bigtable.

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).

self.report_lineage_once()
yield self.fn(element)

def report_lineage_once(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to ensure read/write on report_lineage is atomic? In other words, is it possible that multiple threads read and write reported_lineage at the same time leading to a race condition?

Copy link
Contributor Author

@Abacn Abacn Sep 12, 2024

Choose a reason for hiding this comment

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

It does not matter because Lineage is backed by a String Set, report once or multiple times has the same result (idempotent). Here I use a local variable to reduce the overhead a little bit (do not do set add operation on every element)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This pretty much mirrors Java SDK change of #32068 (BigtableIO), #32090 (FileIO), #32381 (PubSubIO, final version after feedbacks)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, i see.

@Abacn
Copy link
Contributor Author

Abacn commented Sep 13, 2024

python ml precommit and python test were breakages on base branch and fixed on latest master now, not related to this change, and merging for now

@Abacn Abacn merged commit 9a524cc into apache:master Sep 13, 2024
98 of 105 checks passed
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.

2 participants