Skip to content

Commit 4b2a41d

Browse files
authored
Feat/all grab registry as dict (#7)
* add value method to metadata * ruff * bump ver
1 parent 0a92c3c commit 4b2a41d

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

Cargo.lock

+12-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bt_decode"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
edition = "2021"
55

66
[lib]
@@ -30,3 +30,4 @@ scale-info = { version = "2.11.2", features = [ "serde" ], default-features = fa
3030
serde_json = { version = "1.0.127", features = [ "alloc" ], default-features = false }
3131
scale-bits = { version = "0.4.0", default-features = false }
3232
scale-value = { version = "0.16.2", default-features = false }
33+
pythonize = "0.22.0"

bt_decode.pyi

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Optional, Tuple
1+
from typing import Any, Dict, List, Optional, Tuple
22

33
class AxonInfo:
44
# Axon serving block.
@@ -69,12 +69,8 @@ class NeuronInfo:
6969
dividends: int
7070
last_update: int
7171
validator_permit: bool
72-
weights: List[
73-
Tuple[int, int] # Vec of (uid, weight)
74-
]
75-
bonds: List[
76-
Tuple[int, int] # Vec of (uid, bond)
77-
]
72+
weights: List[Tuple[int, int]] # Vec of (uid, weight)
73+
bonds: List[Tuple[int, int]] # Vec of (uid, bond)
7874
pruning_score: int
7975

8076
@staticmethod
@@ -316,6 +312,8 @@ class MetadataV15:
316312
Returns a JSON representation of the metadata.
317313
"""
318314
pass
315+
def value(self) -> Dict[str, Any]:
316+
pass
319317

320318
class PortableRegistry:
321319
"""

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bt-decode"
3-
version = "0.2.1a"
3+
version = "0.3.0a"
44
description = "A wrapper around the scale-codec crate for fast scale-decoding of Bittensor data structures."
55
readme = "README.md"
66
license = {file = "LICENSE"}

src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ mod bt_decode {
329329
_ => panic!("Invalid metadata version"),
330330
}
331331
}
332+
333+
#[pyo3(name = "value")]
334+
fn value(&self, py: Python) -> PyResult<Py<PyAny>> {
335+
let dict = pythonize::pythonize(py, &self.metadata)?;
336+
Ok(dict.into())
337+
}
332338
}
333339

334340
#[pyclass(name = "PortableRegistry")]

0 commit comments

Comments
 (0)