-
Notifications
You must be signed in to change notification settings - Fork 69
add_cache_stream_state_get_setter_api #828
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,6 +280,37 @@ def get_state_writer( | |
| destination_name=destination_name, | ||
| ) | ||
|
|
||
| def get_state( | ||
| stream_name: str, | ||
| ) -> StreamState | None: | ||
| """Return a stream state object for the provided stream name. | ||
|
|
||
| This is a thin wrapper around the internal `StateProvider` interface. | ||
| """ | ||
| return self.get_state_provider(stream_name=stream_name) | ||
|
|
||
| def set_state( | ||
| stream_name: str, | ||
| stream_state: StreamState | dict, | ||
| ) -> None: | ||
| """Set a stream state object for the provided stream name. | ||
|
|
||
| This is a thin wrapper around the internal `StateWriter` interface. | ||
| """ | ||
| ... | ||
|
Comment on lines
+292
to
+300
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusiveMissing The method signature has the same critical issues as
Additionally, the method body is a placeholder ( def set_state(
self,
stream_name: str,
stream_state: StreamState | dict,
source_name: str,
) -> None:
"""Set a stream state object for the provided stream name.
This is a thin wrapper around the internal `StateWriter` interface.
"""
state_writer = self.get_state_writer(source_name=source_name)
state_writer.write_state(stream_name, stream_state) # Assuming such a method existsDoes that align with your intended design? wdyt? Add missing
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def migrate_state( | ||
| streams: list[str] | Literal["*"], | ||
| to_cache: CacheBase, | ||
| ) -> None: | ||
| """Copies all matching stream states to the specified `Cache` object. | ||
|
|
||
| This is a thin wrapper around the respective `Cache` objects' | ||
| `get_state` and `set_state` methods. | ||
| """ | ||
| ... | ||
|
Comment on lines
+302
to
+312
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainMissing A few issues to address:
When implementing, this could iterate over the streams and copy state from this cache to the target cache. Something like: def migrate_state(
self,
streams: list[str] | Literal["*"],
to_cache: CacheBase,
source_name: str,
) -> None:
"""Copies all matching stream states to the specified `Cache` object.
This is a thin wrapper around the respective `Cache` objects'
`get_state` and `set_state` methods.
"""
stream_list = self._catalog_backend.stream_names if streams == "*" else streams
for stream_name in stream_list:
state = self.get_state(stream_name, source_name)
if state is not None:
to_cache.set_state(stream_name, state, source_name)Would this match your vision for the feature? wdyt? 🏁 Script executed: #!/bin/bash
rg -nP 'from\s+typing\s+import.*\bLiteral\b' -n airbyte/caches/base.py || true
rg -nP 'import\s+typing.*\bLiteral\b' -n airbyte/caches/base.py || trueLength of output: 0 🏁 Script executed: #!/bin/bash
sed -n '1,50p' airbyte/caches/base.pyLength of output: 1920 🏁 Script executed: #!/bin/bash
sed -n '260,360p' airbyte/caches/base.pyLength of output: 3443 Add missing
|
||
|
|
||
| def register_source( | ||
| self, | ||
| source_name: str, | ||
|
|
||
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.
Critical issues: Missing
self, undefined type, and incorrect logic.This method has several blockers preventing it from working:
selfparameter: Line 284 needsselfas the first parameterStreamStatetype: Need to importStreamStatefrom the appropriate moduleget_state_provider(stream_name=stream_name)but that method expectssource_name, notstream_name(see lines 253-266)get_state_provider()returnsStateProviderBase, notStreamState | NoneThe intent seems to be retrieving state for a specific stream, but
get_state_provider()requires a source name and returns a provider interface, not individual stream state. Would you like to clarify the intended behavior here? Perhaps this should delegate to a method on theStateProviderBaseto extract a specific stream's state? wdyt?Here's a potential fix assuming
StateProviderBasehas a method to get individual stream state:Note: You'll also need to add the import for
StreamStateat the top of the file.