Skip to content

Commit

Permalink
Merge branch 'main' into 2045-validate-records-with-fastjsonschema
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 23, 2024
2 parents a727cae + 47609eb commit fe43b36
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 36 deletions.
15 changes: 15 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage:
precision: 2
range: "70...100"
round: down
status:
project:
default:
target: auto
threshold: 1%
base: auto
patch:
default:
target: 100%
threshold: 1%
base: auto
9 changes: 9 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ class MyStream(Stream):
super().__init__(tap)
self.conn...
```

## I'm seeing `Note: Progress is not resumable if interrupted.` in my state files

If the stream attribute [`is_sorted`](singer_sdk.Stream.is_sorted) (default: `False`) is not set to `True`, the records are assumed not to be monotonically increasing, i.e. there's no guarantee that newer records always come later and the tap has to run to completion so the state can safely reflect the largest replication value seen. If you know that the records are monotonically increasing, you can set `is_sorted` to `True` and the sync will be resumable if it's interrupted at any point and the state file will reflect this.

```python
class MyStream(Stream):
is_sorted = True
```
90 changes: 55 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ click = "~=8.0"
cryptography = ">=3.4.6"
fastjsonschema = ">=2.19.0"
fs = ">=2.4.16"
importlib-metadata = {version = "<7.0.0", python = "<3.12"}
importlib-metadata = {version = "<8.0.0", python = "<3.12"}
importlib-resources = {version = ">=5.12.0", python = "<3.9"}
inflection = ">=0.5.1"
joblib = ">=1.0.1"
Expand Down
8 changes: 8 additions & 0 deletions singer_sdk/helpers/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import logging
import typing as t

from singer_sdk.exceptions import InvalidStreamSortException
Expand All @@ -17,6 +18,8 @@
SIGNPOST_MARKER = "replication_key_signpost"
STARTING_MARKER = "starting_replication_value"

logger = logging.getLogger("singer_sdk")


def get_state_if_exists(
tap_state: dict,
Expand Down Expand Up @@ -207,6 +210,11 @@ def increment_state(
stream_or_partition_state[PROGRESS_MARKERS] = {
PROGRESS_MARKER_NOTE: "Progress is not resumable if interrupted.",
}
logger.warning(
"Stream is assumed to be unsorted, progress is not resumable if "
"interrupted",
extra={"replication_key": replication_key},
)
progress_dict = stream_or_partition_state[PROGRESS_MARKERS]
old_rk_value = to_json_compatible(progress_dict.get("replication_key_value"))
new_rk_value = to_json_compatible(latest_record[replication_key])
Expand Down
Loading

0 comments on commit fe43b36

Please sign in to comment.