Skip to content

Commit

Permalink
logic fix for squashing deltas on file subscribe reply (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Kafonek authored May 8, 2023
1 parent dbaf26d commit 5e6d7e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.0.26] - 2023-05-08
### Fixed
- Logic error in squashing "deltas-to-apply" during file subscribe reply
- Return value from `RTUManager.register_callback` to support unregistering callbacks (one-shot callbacks)

## [0.0.25] - 2023-05-05
## Added
- Moved `RTUClient` and `NotebookBuilder` (with Pydantic models for a Notebook) into `origami`.
Expand Down
10 changes: 8 additions & 2 deletions origami/rtu_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def predicate_fn(topic: Literal[""], msg: rtu.GenericRTUReply):
return True
return False

self.manager.register_callback(fn, on_predicate=predicate_fn)
return self.manager.register_callback(fn, on_predicate=predicate_fn)

def register_delta_callback(self, fn: Callable, delta_type: str = "*", delta_action: str = "*"):
"""
Expand Down Expand Up @@ -330,7 +330,13 @@ async def queue_or_apply_delta(self, delta: deltas.FileDelta):
If it is not a match, we may have received out of order deltas and we
queue it to be replayed later
"""
if delta.parent_delta_id == self.builder.last_applied_delta_id:
if self.builder.last_applied_delta_id is None:
# We need this for situations where we've downloaded the seed notebook and gotten deltas
# to apply from file subscribe reply, but do not have information about what the first
# delta in that deltas-to-apply list is.
await self.apply_delta(delta=delta)

elif delta.parent_delta_id == self.builder.last_applied_delta_id:
# For logging related to applying delta, override .pre_apply_delta
await self.apply_delta(delta=delta)
await self.replay_unapplied_deltas()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tool.poetry]
name = "noteable-origami"
version = "0.0.25"
version = "0.0.26"
description = "The Noteable API interface"
authors = ["Matt Seal <[email protected]>"]
maintainers = ["Matt Seal <[email protected]>"]
Expand Down

0 comments on commit 5e6d7e4

Please sign in to comment.