Skip to content
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

fix: can't read records #145

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/tsn_adapters/blocks/tn_access.py
Original file line number Diff line number Diff line change
@@ -800,6 +800,45 @@ def task_read_records(
is_unix: Literal[True],
) -> DataFrame[TnRecordModel]: ...

@task(retries=UNUSED_INFINITY_RETRIES, retry_delay_seconds=10, retry_condition_fn=tn_special_retry_condition(5))
def task_read_records(
block: TNAccessBlock,
stream_id: str,
data_provider: Optional[str] = None,
date_from: Union[ShortIso8601Date, int, None] = None,
date_to: Union[ShortIso8601Date, int, None] = None,
*, # Force is_unix to be keyword-only
is_unix: bool = False,
) -> DataFrame[TnRecordModel]:
"""Read records from TSN with support for both ISO dates and Unix timestamps.
Args:
block: The TNAccessBlock instance
stream_id: The stream ID to read from
data_provider: Optional data provider
date_from: Start date (ISO string or Unix timestamp)
date_to: End date (ISO string or Unix timestamp)
is_unix: If True, treat dates as Unix timestamps
Returns:
DataFrame containing the records
"""
if is_unix:
return block.read_records(
stream_id=stream_id,
data_provider=data_provider,
date_from=cast(Optional[int], date_from),
date_to=cast(Optional[int], date_to),
is_unix=True,
)
else:
return block.read_records(
stream_id=stream_id,
data_provider=data_provider,
date_from=cast(Optional[ShortIso8601Date], date_from),
date_to=cast(Optional[ShortIso8601Date], date_to),
is_unix=False,
)

@task(retries=UNUSED_INFINITY_RETRIES, retry_delay_seconds=10, retry_condition_fn=tn_special_retry_condition(5))
def task_insert_tn_records(