2021-02-05 21:03:04 -08:00
|
|
|
from typing import Iterable
|
2021-02-11 21:59:54 -08:00
|
|
|
from gometa.ingestion.api.source import Extractor
|
2021-02-02 18:47:02 -08:00
|
|
|
from gometa.ingestion.api import RecordEnvelope
|
2021-02-05 21:03:04 -08:00
|
|
|
from gometa.ingestion.api.common import PipelineContext
|
|
|
|
|
from gometa.metadata.com.linkedin.pegasus2avro.mxe import MetadataChangeEvent
|
2021-02-02 18:47:02 -08:00
|
|
|
|
2021-02-11 21:34:36 -08:00
|
|
|
|
2021-02-02 18:47:02 -08:00
|
|
|
class WorkUnitMCEExtractor(Extractor):
|
|
|
|
|
"""An extractor that simply returns MCE-s inside workunits back as records"""
|
|
|
|
|
|
2021-02-05 21:03:04 -08:00
|
|
|
def configure(self, config_dict: dict, ctx: PipelineContext):
|
|
|
|
|
pass
|
2021-02-02 18:47:02 -08:00
|
|
|
|
2021-02-05 21:03:04 -08:00
|
|
|
def get_records(self, workunit) -> Iterable[RecordEnvelope[MetadataChangeEvent]]:
|
2021-02-10 16:27:23 -08:00
|
|
|
if len(workunit.mce.proposedSnapshot.aspects) == 0:
|
|
|
|
|
raise AttributeError('every mce must have at least one aspect')
|
2021-02-05 21:03:04 -08:00
|
|
|
yield RecordEnvelope(workunit.mce, {})
|
2021-02-02 18:47:02 -08:00
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
pass
|