feat(taps): Abstract streams#2888
Conversation
Reviewer's Guide by SourceryThis pull request introduces an Updated class diagram for the Stream classclassDiagram
class Stream {
+selected_by_default: bool
+__abstract__: bool
+__init__(tap: Tap, name: str, schema: dict, ...)
+selected(): bool
}
note for Stream "Added __abstract__ flag and updated selected() method"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2888 +/- ##
==========================================
+ Coverage 91.93% 91.94% +0.01%
==========================================
Files 62 62
Lines 5295 5302 +7
Branches 681 683 +2
==========================================
+ Hits 4868 4875 +7
Misses 299 299
Partials 128 128 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #2888 will not alter performanceComparing Summary
|
| raise | ||
|
|
||
| if selected: | ||
| if not self.__abstract__ and selected: |
There was a problem hiding this comment.
| if not self.__abstract__ and selected: | |
| if not selected: |
There was a problem hiding this comment.
Personally, I would remove the redundant assignment
selected = self.selectedabove for clarity. Then this becomes
| if not self.__abstract__ and selected: | |
| if not self.selected: |
as below.
|
|
||
| # Send a SCHEMA message to the downstream target: | ||
| if self.selected: | ||
| if not self.__abstract__ and self.selected: |
There was a problem hiding this comment.
| if not self.__abstract__ and self.selected: | |
| if not self.selected: |
| class MyTap(tap_class): | ||
| def discover_streams(self): | ||
| return [SelectedStream(self), UnselectedStream(self)] | ||
| return [SelectedStream(self), UnselectedStream(self), AbstractStream(self)] |
There was a problem hiding this comment.
Would it be possible to avoid this somehow? As in, auto-discover/instantiate any parent streams that are abstract?
There was a problem hiding this comment.
That's a very good point. I'll try to do that.
| return Catalog( | ||
| (stream.tap_stream_id, stream._singer_catalog_entry) # noqa: SLF001 | ||
| for stream in self.streams.values() | ||
| if not stream.__abstract__ |
There was a problem hiding this comment.
Advantages/disadvantages of filtering out abstract streams here vs in self.streams?
| def get_records(self, context): # noqa: ARG002 | ||
| yield {"id": 1} | ||
| yield {"id": 2} | ||
|
|
||
| def generate_child_contexts(self, record, context): # noqa: ARG002 | ||
| yield {"pid": record["id"]} |
There was a problem hiding this comment.
Wondering if there is a better way to support this... It would be good if this could be encapsulated into generate_child_contexts only, but that currently requires at least one record (hence get_records implementation).
Related
Summary by Sourcery
Add support for abstract streams, which are not included in the catalog.
📚 Documentation preview 📚: https://meltano-sdk--2888.org.readthedocs.build/en/2888/