Establish actual relationship of the Python binding's `LogEntry`, `StateMachine` types

オープン
#99 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

.pyi ファイル内の一時的な AbstractLogEntry と AbstractStateMachine の宣言を、インストールされている raftify/init.py および Python wheel の内容と比較することから始めます。示されている import エラーを再現し、その後、2 つの型が raftify から利用でき、SetCommand と HashStore のサンプルの関係を import エラーなしでサポートしていることを確認します。

索引モデルが issue の本文から書いたものです。

説明

low-priority python

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)
主要言語
Rust
スター
44
フォーク
14
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lablup/raftify のほかの issue

lablup/raftify の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。