-
Notifications
You must be signed in to change notification settings - Fork 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
feat(ingestion/airflow): Add support for mutiple datahub emitter #12398
Merged
treff7es
merged 22 commits into
datahub-project:master
from
treff7es:airflow_multiple_datahub_emitter_support
Jan 29, 2025
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
72738da
Add support for mutiple datahub emitter
treff7es 44a0d34
fix for old plugin
treff7es 947f983
Lint fix
treff7es f4f47aa
Add lint fixes
treff7es 8b1ec7a
Fix list
treff7es 1a85c3a
Add test
treff7es b5ef539
Only check multiple connection golden if not on v1
treff7es 31c07ce
Add composite emitter instead of multi listener
treff7es cbdf21e
fix for older plugin
treff7es ee896db
fix for v22
treff7es 3f94b82
Pr review fixes
treff7es b85655d
lint fix
treff7es 46aa5ed
Formatting
treff7es 530f299
Fix test
treff7es d3901b8
lintfix
treff7es be77ad4
Couple of more fixes
treff7es df7d16a
more fixes
treff7es 4ff8aa5
lint fix
treff7es c0fa009
Fix tests
treff7es c0205cd
Couple of small fixes
treff7es d31fae9
lint
treff7es 64f1d2d
Add tests
treff7es File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
metadata-ingestion/src/datahub/emitter/composite_emitter.py
treff7es marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Callable, List, Optional, Union | ||
|
||
from datahub.emitter.generic_emitter import Emitter | ||
from datahub.emitter.mcp import MetadataChangeProposalWrapper | ||
from datahub.metadata.com.linkedin.pegasus2avro.mxe import ( | ||
MetadataChangeEvent, | ||
MetadataChangeProposal, | ||
) | ||
|
||
|
||
# Experimental composite emitter that allows multiple emitters to be used in a single ingestion job | ||
class CompositeEmitter(Emitter): | ||
treff7es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__(self, emitters: List[Emitter]) -> None: | ||
self.emitters = emitters | ||
|
||
def emit( | ||
self, | ||
item: Union[ | ||
MetadataChangeEvent, | ||
MetadataChangeProposal, | ||
MetadataChangeProposalWrapper, | ||
], | ||
callback: Optional[Callable[[Exception, str], None]] = None, | ||
) -> None: | ||
callback_called = False | ||
for emitter in self.emitters: | ||
if not callback_called: | ||
# We want to ensure that the callback is only called once and we tie it to the first emitter that | ||
treff7es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
emitter.emit(item, callback) | ||
callback_called = True | ||
else: | ||
emitter.emit(item) | ||
|
||
def flush(self) -> None: | ||
for emitter in self.emitters: | ||
emitter.flush() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 a thought, not necessary to do: should the
DatahubGenericHook
be the thing responsible for constructing the composite emitter?e.g. you can pass it either a string or a list of strings, and it does the right thing