Establish actual relationship of the Python binding's `LogEntry`, `StateMachine` types
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- distributed-systems
Research direction
Start by comparing the temporary AbstractLogEntry and AbstractStateMachine declarations in the .pyi file with the installed raftify/init.py and the Python wheel contents. Reproduce the shown import error, then verify that the two types are available from raftify and support the sample SetCommand and HashStore relationships without import errors.
Written by the indexing model from the issue text.
Description
Ideally, the SetCommand and LogEntry in the sample code should be represented as shown below.
class SetCommand(AbstractLogEntry):
"""
Represent simple key-value command.
Use pickle to serialize the data.
"""
def __init__(self, key: str, value: str) -> None:
self.key = key
self.value = value
@override
def encode(self) -> bytes:
return pickle.dumps(self.__dict__)
@override
@classmethod
def decode(cls, packed: bytes) -> "SetCommand":
unpacked = pickle.loads(packed)
return cls(unpacked["key"], unpacked["value"])
class HashStore(AbstractStateMachine):
"""
A simple key-value store that stores data in memory.
Use pickle to serialize the data.
"""
def __init__(self):
self._store = dict()
self._loop = asyncio.get_running_loop()
def get(self, key: str) -> Optional[str]:
return self._store.get(key)
def as_dict(self) -> dict:
return self._store
@override
async def apply(self, msg: bytes) -> bytes:
message = SetCommand.decode(msg)
self._store[message.key] = message.value
return msg
@override
async def snapshot(self) -> bytes:
return pickle.dumps(self._store)
@override
async def restore(self, snapshot: bytes) -> None:
self._store = pickle.loads(snapshot)
However, for now, these two types are only temporarily defined in the .pyi file and are not actually included in the whl, resulting in an import error.
from raftify import AbstractLogEntry, AbstractStateMachine
ImportError: cannot import name 'AbstractLogEntry' from 'raftify' (/opt/homebrew/lib/python3.12/site-packages/raftify/__init__.py)
- Dominant language
- Rust
- Stars
- 44
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lablup/raftify
-
integration-test
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
dx
Difficulty 5/5 Over a week Newbie friendliness 32/100
-
feature log-storage snapshot
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
good first issue log-storage test
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
feature
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Similar issues
-
area:ui effort:medium enhancement P7 source:agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
documentation priority: low tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
nledford/Ladderback#1823 ·
Maintainers usually reply within 1 day
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Possibly taken @ealwanlee claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
psmux/psmux-plugins#47 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day