Skip to content

Commit

Permalink
Feat/all grab registry as dict (#7)
Browse files Browse the repository at this point in the history
* add value method to metadata

* ruff

* bump ver
  • Loading branch information
camfairchild authored Oct 22, 2024
1 parent 0a92c3c commit 4b2a41d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
13 changes: 12 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bt_decode"
version = "0.0.1"
version = "0.1.0"
edition = "2021"

[lib]
Expand Down Expand Up @@ -30,3 +30,4 @@ scale-info = { version = "2.11.2", features = [ "serde" ], default-features = fa
serde_json = { version = "1.0.127", features = [ "alloc" ], default-features = false }
scale-bits = { version = "0.4.0", default-features = false }
scale-value = { version = "0.16.2", default-features = false }
pythonize = "0.22.0"
12 changes: 5 additions & 7 deletions bt_decode.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple

class AxonInfo:
# Axon serving block.
Expand Down Expand Up @@ -69,12 +69,8 @@ class NeuronInfo:
dividends: int
last_update: int
validator_permit: bool
weights: List[
Tuple[int, int] # Vec of (uid, weight)
]
bonds: List[
Tuple[int, int] # Vec of (uid, bond)
]
weights: List[Tuple[int, int]] # Vec of (uid, weight)
bonds: List[Tuple[int, int]] # Vec of (uid, bond)
pruning_score: int

@staticmethod
Expand Down Expand Up @@ -316,6 +312,8 @@ class MetadataV15:
Returns a JSON representation of the metadata.
"""
pass
def value(self) -> Dict[str, Any]:
pass

class PortableRegistry:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bt-decode"
version = "0.2.1a"
version = "0.3.0a"
description = "A wrapper around the scale-codec crate for fast scale-decoding of Bittensor data structures."
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ mod bt_decode {
_ => panic!("Invalid metadata version"),
}
}

#[pyo3(name = "value")]
fn value(&self, py: Python) -> PyResult<Py<PyAny>> {
let dict = pythonize::pythonize(py, &self.metadata)?;
Ok(dict.into())
}
}

#[pyclass(name = "PortableRegistry")]
Expand Down

0 comments on commit 4b2a41d

Please sign in to comment.