-
Notifications
You must be signed in to change notification settings - Fork 123
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
355 - add computed exhausted property #380
Conversation
✅ Deploy Preview for dlt-hub-docs canceled.
|
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.
please link to issue in PR. maybe we should a template?
dlt/extract/source.py
Outdated
@@ -614,6 +614,15 @@ def root_key(self) -> bool: | |||
config = RelationalNormalizer.get_normalizer_config(self._schema).get("propagation") | |||
return config is not None and "root" in config and "_dlt_id" in config["root"] and config["root"]["_dlt_id"] == "_dlt_root_id" | |||
|
|||
@property | |||
def exhausted(self) -> bool: | |||
# check all selected pipes wether one of them is exhausted |
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.
better to use docstrings
dlt/extract/source.py
Outdated
def exhausted(self) -> bool: | ||
# check all selected pipes wether one of them is exhausted | ||
for resource in self._resources.extracted.values(): | ||
for item in resource._pipe: |
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.
you do not need to enumerate items. Pipe
has gen
property which is the main generator of the pipe. all others are transforms. so check only gen
dlt/extract/source.py
Outdated
# check all selected pipes wether one of them is exhausted | ||
for resource in self._resources.extracted.values(): | ||
for item in resource._pipe: | ||
if isinstance(item, types.GeneratorType): |
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.
interesting! I'm using inspect.isgenerator
and it's probably better to stick to that (or you double check if the above catches all cases of generators)
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.
also the linter is not passing
tests/extract/test_sources.py
Outdated
def some_data(): | ||
yield from [1, 2, 3, 4] | ||
|
||
s = DltSource("source", "module", Schema("source"), [dlt.resource(some_data())]) |
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.
all good, but please add more resource types to source
- a regular list (iterable)
- an iterator (ie. on a list)
- join gen resource to transformer
I just want to make sure all cases are passing, you can do it on one test
946bb52
to
788994f
Compare
c69968e
to
6c7dd39
Compare
…duration of __next__ call
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.
OK! finally we have all the tests and CI is passing!
No description provided.