Skip to content

Commit

Permalink
remove logger setup (acquire-project#73)
Browse files Browse the repository at this point in the history
closes acquire-project#71 

I also unexpectedly ran into rust complaining about a misaligned pointer
read. So I fixed that. I can't quite figure out why it manifested now,
but it was quite repeatable.
  • Loading branch information
nclack authored Aug 21, 2023
1 parent d45613d commit e2fb7ec
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ name = "acquire"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.18", features = [
pyo3 = { version = "0.19", features = [
"extension-module",
"anyhow",
"abi3-py38",
"serde",
] }
pyo3-log = "0.8"
numpy = "0.18"
numpy = "0.19"
log = "0.4"
anyhow = "1.0"
parking_lot = "0.12"
serde = { version = "1.0", features = ["derive"] }
pythonize = "0.18"
pythonize = "0.19"

[build-dependencies]
bindgen = "0.65"
bindgen = "0.66"
cmake = "0.1"
http = "0.2"
json = "0.12"
Expand Down
30 changes: 19 additions & 11 deletions python/acquire/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import time
from typing import TYPE_CHECKING, Any, Generator, List, Literal, Optional, Tuple, Union
from typing import (
TYPE_CHECKING,
Any,
Generator,
List,
Literal,
Optional,
Tuple,
Union,
)

import numpy.typing as npt

Expand All @@ -14,13 +23,6 @@
import napari # type: ignore


FORMAT: str = (
"%(levelname)s %(name)s %(asctime)-15s %(filename)s:%(lineno)d %(message)s"
)
logging.basicConfig(format=FORMAT)
logging.getLogger().setLevel(logging.INFO)


g_runtime: Optional[Runtime] = None
"""The global acquire runtime."""

Expand Down Expand Up @@ -159,7 +161,9 @@ def update_layer(args: Tuple[npt.NDArray[Any], int]) -> None:
viewer.add_image(new_image, name=layer_key)

@thread_worker(connect={"yielded": update_layer})
def do_acquisition() -> Generator[Tuple[npt.NDArray[Any], int], None, None]:
def do_acquisition() -> (
Generator[Tuple[npt.NDArray[Any], int], None, None]
):
logging.basicConfig(level=logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)

Expand Down Expand Up @@ -188,9 +192,13 @@ def next_frame() -> Optional[npt.NDArray[Any]]:
if packet := runtime.get_available_data(stream_id):
n = packet.get_frame_count()
nframes[stream_id] += n
logging.info(f"[stream {stream_id}] frame count: {nframes}")
logging.info(
f"[stream {stream_id}] frame count: {nframes}"
)
f = next(packet.frames())
logging.debug(f"stream {stream_id} frame {f.metadata().frame_id}")
logging.debug(
f"stream {stream_id} frame {f.metadata().frame_id}"
)
return f.data().squeeze().copy()
return None

Expand Down
6 changes: 3 additions & 3 deletions python/acquire/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import napari # type: ignore

from .acquire import *

FORMAT: str

def setup(
runtime: Runtime,
camera: Union[str, List[str]] = ...,
Expand All @@ -17,4 +15,6 @@ def setup_two_streams(runtime: Runtime, frame_count: int) -> Properties: ...

g_runtime: Optional[Runtime]

def gui(viewer: "napari.Viewer", frame_count: int = ..., stream_count: int = ...) -> None: ...
def gui(
viewer: "napari.Viewer", frame_count: int = ..., stream_count: int = ...
) -> None: ...
2 changes: 1 addition & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl RawAvailableData {
let mut cur = self.beg.as_ptr();
let end = self.end.as_ptr();
while cur < end {
let frame: &capi::VideoFrame = &*cur;
let frame: &capi::VideoFrame = &std::ptr::read_unaligned(cur);
log::trace!(
"[stream {}] Advancing count for frame {} w size {}",
self.stream_id,
Expand Down

0 comments on commit e2fb7ec

Please sign in to comment.