Skip to content

Commit

Permalink
Add backlog probing to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed Apr 11, 2024
1 parent fdf11f7 commit a8af09f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 4 deletions.
6 changes: 3 additions & 3 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
name = "python"
version = "0.11.0"
version = "0.12.0"
edition = "2021"

[lib]
name = "neuromorphic_drivers"
crate-type = ["cdylib"]

[dependencies]
neuromorphic-drivers = "0.11.0"
neuromorphic-drivers = "0.12.0"
numpy = "0.19"
paste = "1.0"
pyo3 = {version = "0.19", features = ["extension-module"]}

[build-dependencies]
cc = "1.0"
neuromorphic-drivers = "0.11.0"
neuromorphic-drivers = "0.12.0"
paste = "1.0"
reflect = {path = "../reflect"}
serde = {version = "1.0", features = ["derive"]}
Expand Down
6 changes: 6 additions & 0 deletions python/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ macro_rules! generate {
" def __next__(self) -> tuple[{}, {}{}{}]:\n",
" ...\n",
"\n",
" def backlog(self) -> int:\n",
" ...\n",
"\n",
" def clear_backlog(self, until: int):\n",
" ...\n",
"\n",
Expand Down Expand Up @@ -715,6 +718,9 @@ macro_rules! generate {
" def __next__(self) -> tuple[{}, {}{}{}]:\n",
" ...\n",
"\n",
" def backlog(self) -> int:\n",
" ...\n",
"\n",
" def clear_backlog(self, until: int):\n",
" ...\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
{name = "International Centre for Neuromorphic Systems"},
{name = "Alexandre Marcireau"},
]
version = "0.11.0"
version = "0.12.0"
requires-python = ">=3.8"
dependencies = ["numpy>=1.24"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __iter__(self) -> "Device":
def __next__(self) -> tuple[status.StatusNonOptional, dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -166,6 +169,9 @@ def __iter__(self) -> "DeviceOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -209,6 +215,9 @@ def __iter__(self) -> "DeviceRaw":
def __next__(self) -> tuple[status.StatusNonOptional, bytes]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -252,6 +261,9 @@ def __iter__(self) -> "DeviceRawOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[bytes]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def __iter__(self) -> "Device":
def __next__(self) -> tuple[status.StatusNonOptional, dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -206,6 +209,9 @@ def __iter__(self) -> "DeviceOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -251,6 +257,9 @@ def __iter__(self) -> "DeviceRaw":
def __next__(self) -> tuple[status.StatusNonOptional, bytes]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -296,6 +305,9 @@ def __iter__(self) -> "DeviceRawOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[bytes]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down
12 changes: 12 additions & 0 deletions python/python/neuromorphic_drivers/generated/devices_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __iter__(self) -> "GenericDevice":
def __next__(self) -> tuple[status.StatusNonOptional, dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -75,6 +78,9 @@ def __iter__(self) -> "GenericDeviceOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[dict[str, numpy.ndarray[typing.Any, numpy.dtype[numpy.void]]]]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -118,6 +124,9 @@ def __iter__(self) -> "GenericDeviceRaw":
def __next__(self) -> tuple[status.StatusNonOptional, bytes]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down Expand Up @@ -161,6 +170,9 @@ def __iter__(self) -> "GenericDeviceRawOptional":
def __next__(self) -> tuple[status.Status, typing.Optional[bytes]]:
...

def backlog(self) -> int:
...

def clear_backlog(self, until: int):
...

Expand Down
10 changes: 10 additions & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,16 @@ impl Device {
})
}

fn backlog(slf: pyo3::PyRef<Self>) -> pyo3::PyResult<usize> {
Ok(slf
.device
.as_ref()
.ok_or(pyo3::exceptions::PyRuntimeError::new_err(
"backlog called after __exit__",
))?
.backlog())
}

fn clear_backlog(
slf: pyo3::PyRef<Self>,
python: pyo3::Python,
Expand Down

0 comments on commit a8af09f

Please sign in to comment.