Skip to content

Commit

Permalink
Merge pull request #241 from vkottler/dev/5.3.1
Browse files Browse the repository at this point in the history
5.3.1 - Minor Serializable update
  • Loading branch information
vkottler authored Jul 9, 2024
2 parents 66b88e2 + bfe7d31 commit 43bddbd
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=runtimepy version=5.3.0
repo=runtimepy version=5.3.1
if: |
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=5d2077f589ab71dc3657c502813d4784
hash=80ff32f18958cf12959d97ebc77f4c32
=====================================
-->

# runtimepy ([5.3.0](https://pypi.org/project/runtimepy/))
# runtimepy ([5.3.1](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 5
minor: 3
patch: 0
patch: 1
entry: runtimepy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "5.3.0"
version = "5.3.1"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=ec0d70a1963b4f2d02aa421f4d961643
# hash=231380c332c2ef6a1d5009c0a20aed5c
# =====================================

"""
Expand All @@ -10,7 +10,7 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "5.3.0"
VERSION = "5.3.1"

# runtimepy-specific content.
METRICS_NAME = "metrics"
Expand Down
19 changes: 11 additions & 8 deletions runtimepy/primitives/serializable/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,28 @@ def to_stream(self, stream: _BinaryIO) -> int:
return result

@abstractmethod
def update(self, data: bytes) -> int:
def update(self, data: bytes, timestamp_ns: int = None) -> int:
"""Update this serializable from a bytes instance."""

def update_str(self, data: str) -> int:
def update_str(self, data: str, timestamp_ns: int = None) -> int:
"""Update this serializable from string data."""
return self.update(data.encode(encoding=DEFAULT_ENCODING))

def _from_stream(self, stream: _BinaryIO) -> int:
return self.update(
data.encode(encoding=DEFAULT_ENCODING), timestamp_ns=timestamp_ns
)

def _from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int:
"""Update just this instance from a stream."""

return self.update(stream.read(self.size))
return self.update(stream.read(self.size), timestamp_ns=timestamp_ns)

def from_stream(self, stream: _BinaryIO) -> int:
def from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int:
"""Update this serializable from a stream."""

result = self._from_stream(stream)
result = self._from_stream(stream, timestamp_ns=timestamp_ns)

if self.chain is not None:
result += self.chain.from_stream(stream)
result += self.chain.from_stream(stream, timestamp_ns=timestamp_ns)

return result

Expand Down
4 changes: 3 additions & 1 deletion runtimepy/primitives/serializable/fixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def __bytes__(self) -> bytes:
"""Get this serializable as a bytes instance."""
return self.data

def update(self, data: bytes) -> int:
def update(self, data: bytes, timestamp_ns: int = None) -> int:
"""Update this serializable from a bytes instance."""

del timestamp_ns

self.data = data
self.size = len(self.data)
return self.size
9 changes: 5 additions & 4 deletions runtimepy/primitives/serializable/prefixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def __str__(self) -> str:
"""Get this chunk as a string."""
return str(self.chunk)

def update(self, data: bytes) -> int:
def update(self, data: bytes, timestamp_ns: int = None) -> int:
"""Update this serializable from a bytes instance."""

size = self.chunk.update(data)
size = self.chunk.update(data, timestamp_ns=timestamp_ns)
self.prefix.value = size
return self._update_size()

Expand All @@ -73,13 +73,14 @@ def __bytes__(self) -> bytes:
self.chunk
)

def _from_stream(self, stream: _BinaryIO) -> int:
def _from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int:
"""Update just this instance from a stream."""

self.chunk.update(
stream.read(
self.prefix.from_stream(stream, byte_order=self.byte_order)
)
),
timestamp_ns=timestamp_ns,
)
return self._update_size()

Expand Down

0 comments on commit 43bddbd

Please sign in to comment.