diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..9ecbe53 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,27 @@ +name: Run pre-commit + +on: + pull_request: + push: + branches: [ main ] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install + run: | + pip install --upgrade pip + pip install -e '.[testing]' + + - name: Run pre-commit + uses: pre-commit/action@v3.0.0 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f7826f..c20d0ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,8 +110,8 @@ jobs: - name: Test artifact run: | - python -m pytest -k test_basic --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 - python -m pytest -k test_zarr --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 + python -m pytest -k test_basic + python -m pytest -k test_zarr - name: Upload wheels uses: actions/upload-artifact@v3 diff --git a/.github/workflows/test_pr.yml b/.github/workflows/test_pr.yml index 2abe67d..7d14f0a 100644 --- a/.github/workflows/test_pr.yml +++ b/.github/workflows/test_pr.yml @@ -55,8 +55,8 @@ jobs: ZARR_V3_EXPERIMENTAL_API: "1" ZARR_V3_SHARDING: "1" run: | - python -m pytest -k test_basic --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 - python -m pytest -k test_zarr --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 + python -m pytest -k test_basic + python -m pytest -k test_zarr dcam: name: Python ${{ matrix.python }} (DCAM) @@ -102,7 +102,7 @@ jobs: - name: Test run: | - python -m pytest -k test_dcam --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 + python -m pytest -k test_dcam egrabber: name: Python ${{ matrix.python }} (eGrabber) @@ -148,7 +148,7 @@ jobs: - name: Test run: | - python -m pytest -k test_egrabber --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 + python -m pytest -k test_egrabber spinnaker: @@ -196,7 +196,7 @@ jobs: - name: Test run: | - python -m pytest -k test_spinnaker --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 + python -m pytest -k test_spinnaker typing: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78b0c03..f27be6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,37 @@ repos: -- repo: https://github.com/psf/black + - repo: https://github.com/psf/black rev: 22.6.0 hooks: - - id: black - pass_filenames: true -- repo: https://github.com/PyCQA/flake8 + - id: black + pass_filenames: true + - repo: https://github.com/PyCQA/flake8 rev: 5.0.4 hooks: - - id: flake8 - additional_dependencies: [flake8-typing-imports] - pass_filenames: true - exclude: __init__.py -- repo: https://github.com/asottile/pyupgrade + - id: flake8 + additional_dependencies: [ flake8-typing-imports ] + pass_filenames: true + exclude: __init__.py + - repo: https://github.com/asottile/pyupgrade rev: v2.37.3 hooks: - - id: pyupgrade - args: ["--py38-plus", "--keep-runtime-typing"] -- repo: https://github.com/seddonym/import-linter + - id: pyupgrade + args: [ "--py38-plus", "--keep-runtime-typing" ] + - repo: https://github.com/seddonym/import-linter rev: v1.2.7 hooks: - - id: import-linter - stages: [manual] \ No newline at end of file + - id: import-linter + stages: [ manual ] + - repo: local + hooks: + - id: ruff + name: Lint Python files + entry: python -m ruff check . + language: system + types: [ file ] + files: \.py$ + - id: cargo-fmt + name: Format Rust files + entry: cargo fmt --all -- --check + language: system + types: [ file ] + files: \.rs$ diff --git a/pyproject.toml b/pyproject.toml index 0225aa2..22a5c57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ testing = [ "zarr", "dask", "ome-zarr", + "ruff", ] [project.entry-points."napari.manifest"] @@ -57,7 +58,17 @@ profile = "black" [tool.pytest.ini_options] minversion = "7.0" -addopts = "--tb=short -s" +addopts = '--tb=short -s --color=yes --cov-report=xml --cov=acquire --maxfail=5 --log-cli-level=0 --doctest-glob="*.pyi" --doctest-glob="*.md"' # log_format = "%(asctime)s %(levelname)s %(message)s" # log_date_format = "%Y-%m-%d %H:%M:%S" log_cli = true # when true, messages are printed immediately + +[tool.ruff] +exclude = [ + "__init__.py" +] + +ignore = [ + "F403", + "F405", +] \ No newline at end of file diff --git a/python/acquire/__init__.pyi b/python/acquire/__init__.pyi index ae5aeb4..3c40e76 100644 --- a/python/acquire/__init__.pyi +++ b/python/acquire/__init__.pyi @@ -2,7 +2,7 @@ from typing import List, Optional, Union import napari # type: ignore -from .acquire import * +from .acquire import Runtime, Properties def setup( runtime: Runtime, diff --git a/python/acquire/acquire.pyi b/python/acquire/acquire.pyi index 8d48643..e8e8ac6 100644 --- a/python/acquire/acquire.pyi +++ b/python/acquire/acquire.pyi @@ -91,11 +91,11 @@ class DeviceIdentifier: @final class DeviceKind: - Camera: ClassVar[DeviceKind] = DeviceKind.Camera - NONE: ClassVar[DeviceKind] = DeviceKind.NONE - Signals: ClassVar[DeviceKind] = DeviceKind.Signals - StageAxis: ClassVar[DeviceKind] = DeviceKind.StageAxis - Storage: ClassVar[DeviceKind] = DeviceKind.Storage + Camera: ClassVar[DeviceKind] + NONE: ClassVar[DeviceKind] + Signals: ClassVar[DeviceKind] + StageAxis: ClassVar[DeviceKind] + Storage: ClassVar[DeviceKind] def __init__(self, *args: None, **kwargs: Any) -> None: ... def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... @@ -120,12 +120,10 @@ class DeviceManager: @final class DeviceState: - Closed: ClassVar[DeviceState] = DeviceState.Closed - AwaitingConfiguration: ClassVar[ - DeviceState - ] = DeviceState.AwaitingConfiguration - Armed: ClassVar[DeviceState] = DeviceState.Armed - Running: ClassVar[DeviceState] = DeviceState.Running + Closed: ClassVar[DeviceState] + AwaitingConfiguration: ClassVar[DeviceState] + Armed: ClassVar[DeviceState] + Running: ClassVar[DeviceState] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -142,8 +140,8 @@ class DigitalLineCapabilities: @final class Direction: - Backward: ClassVar[Direction] = Direction.Backward - Forward: ClassVar[Direction] = Direction.Forward + Backward: ClassVar[Direction] + Forward: ClassVar[Direction] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -196,10 +194,10 @@ class Property: @final class PropertyType: - FixedPrecision: ClassVar[PropertyType] = PropertyType.FixedPrecision - FloatingPrecision: ClassVar[PropertyType] = PropertyType.FloatingPrecision - Enum: ClassVar[PropertyType] = PropertyType.Enum - String: ClassVar[PropertyType] = PropertyType.String + FixedPrecision: ClassVar[PropertyType] + FloatingPrecision: ClassVar[PropertyType] + Enum: ClassVar[PropertyType] + String: ClassVar[PropertyType] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -237,14 +235,14 @@ class SampleRateHz: @final class SampleType: - F32: ClassVar[SampleType] = SampleType.F32 - I16: ClassVar[SampleType] = SampleType.I16 - I8: ClassVar[SampleType] = SampleType.I8 - U16: ClassVar[SampleType] = SampleType.U16 - U8: ClassVar[SampleType] = SampleType.U8 - U10: ClassVar[SampleType] = SampleType.U10 - U12: ClassVar[SampleType] = SampleType.U12 - U14: ClassVar[SampleType] = SampleType.U14 + F32: ClassVar[SampleType] + I16: ClassVar[SampleType] + I8: ClassVar[SampleType] + U16: ClassVar[SampleType] + U8: ClassVar[SampleType] + U10: ClassVar[SampleType] + U12: ClassVar[SampleType] + U14: ClassVar[SampleType] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -270,8 +268,8 @@ class ShardingCapabilities: @final class SignalIOKind: - Input: ClassVar[SignalIOKind] = SignalIOKind.Input - Output: ClassVar[SignalIOKind] = SignalIOKind.Output + Input: ClassVar[SignalIOKind] + Output: ClassVar[SignalIOKind] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -282,8 +280,8 @@ class SignalIOKind: @final class SignalType: - Analog: ClassVar[SignalType] = SignalType.Analog - Digital: ClassVar[SignalType] = SignalType.Digital + Analog: ClassVar[SignalType] + Digital: ClassVar[SignalType] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -334,12 +332,12 @@ class TriggerCapabilities: @final class TriggerEdge: - Falling: ClassVar[TriggerEdge] = TriggerEdge.Falling - NotApplicable: ClassVar[TriggerEdge] = TriggerEdge.NotApplicable - Rising: ClassVar[TriggerEdge] = TriggerEdge.Rising - AnyEdge: ClassVar[TriggerEdge] = TriggerEdge.AnyEdge - LevelLow: ClassVar[TriggerEdge] = TriggerEdge.LevelLow - LevelHigh: ClassVar[TriggerEdge] = TriggerEdge.LevelHigh + Falling: ClassVar[TriggerEdge] + NotApplicable: ClassVar[TriggerEdge] + Rising: ClassVar[TriggerEdge] + AnyEdge: ClassVar[TriggerEdge] + LevelLow: ClassVar[TriggerEdge] + LevelHigh: ClassVar[TriggerEdge] def __eq__(self, other: object) -> bool: ... def __ge__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... diff --git a/src/camera.rs b/src/camera.rs index 46e3769..638f851 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,10 +1,10 @@ use crate::{ capi, - components::{macros::impl_plain_old_dict, Property, Direction, SampleType, Trigger}, + components::{macros::impl_plain_old_dict, Direction, Property, SampleType, Trigger}, }; use pyo3::prelude::*; use serde::{Deserialize, Serialize}; -use std::ffi::{CStr, c_char, c_void}; +use std::ffi::{c_char, c_void, CStr}; #[pyclass] #[derive(Debug, Default, Clone, Serialize, Deserialize)] @@ -289,7 +289,9 @@ impl Default for OffsetShapeCapabilities { } } -impl TryFrom for OffsetShapeCapabilities { +impl TryFrom + for OffsetShapeCapabilities +{ type Error = anyhow::Error; fn try_from( @@ -304,7 +306,9 @@ impl TryFrom f } } -impl TryFrom for OffsetShapeCapabilities { +impl TryFrom + for OffsetShapeCapabilities +{ type Error = anyhow::Error; fn try_from( @@ -341,7 +345,9 @@ impl Default for DigitalLineCapabilities { } } -impl TryFrom for DigitalLineCapabilities { +impl TryFrom + for DigitalLineCapabilities +{ type Error = anyhow::Error; fn try_from( @@ -350,7 +356,9 @@ impl TryFrom PyResult<_> { let mut names: [String; 8] = Default::default(); for (i, name) in value.names.iter().enumerate() { - let name = unsafe { CStr::from_ptr(name.as_ptr()) }.to_str()?.to_owned(); + let name = unsafe { CStr::from_ptr(name.as_ptr()) } + .to_str()? + .to_owned(); names[i] = name; } Ok(Self { @@ -565,7 +573,9 @@ impl Default for capi::CameraPropertyMetadata_camera_properties_metadata_offset_ } } -impl TryFrom<&OffsetShapeCapabilities> for capi::CameraPropertyMetadata_camera_properties_metadata_offset_s { +impl TryFrom<&OffsetShapeCapabilities> + for capi::CameraPropertyMetadata_camera_properties_metadata_offset_s +{ type Error = anyhow::Error; fn try_from(value: &OffsetShapeCapabilities) -> Result { @@ -587,7 +597,9 @@ impl Default for capi::CameraPropertyMetadata_camera_properties_metadata_shape_s } } -impl TryFrom<&OffsetShapeCapabilities> for capi::CameraPropertyMetadata_camera_properties_metadata_shape_s { +impl TryFrom<&OffsetShapeCapabilities> + for capi::CameraPropertyMetadata_camera_properties_metadata_shape_s +{ type Error = anyhow::Error; fn try_from(value: &OffsetShapeCapabilities) -> Result { @@ -605,33 +617,21 @@ impl Default for capi::CameraPropertyMetadata_CameraPropertyMetadataDigitalLineM Self { line_count: Default::default(), names: [ - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], + [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], ], } } } -impl TryFrom<&DigitalLineCapabilities> for capi::CameraPropertyMetadata_CameraPropertyMetadataDigitalLineMetadata { +impl TryFrom<&DigitalLineCapabilities> + for capi::CameraPropertyMetadata_CameraPropertyMetadataDigitalLineMetadata +{ type Error = anyhow::Error; fn try_from(value: &DigitalLineCapabilities) -> Result { Ok(Python::with_gil(|_| -> PyResult<_> { let mut names: [[c_char; 64]; 8] = [ - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], - [0; 64], + [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], [0; 64], ]; for (i, name) in value.names.iter().enumerate() { let name = std::ffi::CString::new(name.as_str())?; @@ -685,7 +685,9 @@ impl Default for capi::CameraPropertyMetadata_CameraPropertiesTriggerMetadata { } } -impl TryFrom<&TriggerCapabilities> for capi::CameraPropertyMetadata_CameraPropertiesTriggerMetadata { +impl TryFrom<&TriggerCapabilities> + for capi::CameraPropertyMetadata_CameraPropertiesTriggerMetadata +{ type Error = anyhow::Error; fn try_from(value: &TriggerCapabilities) -> Result { @@ -696,14 +698,12 @@ impl TryFrom<&TriggerCapabilities> for capi::CameraPropertyMetadata_CameraProper })?; let exposure = Python::with_gil(|py| -> PyResult<_> { - let exposure: TriggerInputOutputCapabilities = - value.exposure.extract(py)?; + let exposure: TriggerInputOutputCapabilities = value.exposure.extract(py)?; Ok(exposure) })?; let frame_start = Python::with_gil(|py| -> PyResult<_> { - let frame_start: TriggerInputOutputCapabilities = - value.frame_start.extract(py)?; + let frame_start: TriggerInputOutputCapabilities = value.frame_start.extract(py)?; Ok(frame_start) })?; @@ -772,4 +772,4 @@ impl TryFrom<&CameraCapabilities> for capi::CameraPropertyMetadata { triggers: (&triggers).try_into()?, }) } -} \ No newline at end of file +} diff --git a/src/capabilities.rs b/src/capabilities.rs index cbe5476..7d3c0e6 100644 --- a/src/capabilities.rs +++ b/src/capabilities.rs @@ -2,10 +2,10 @@ use pyo3::prelude::*; use serde::{Deserialize, Serialize}; use crate::{ - capi, - storage::StorageCapabilities, camera::CameraCapabilities, + capi, components::{macros::impl_plain_old_dict, Property}, + storage::StorageCapabilities, }; #[pyclass] @@ -88,10 +88,7 @@ impl TryFrom<&capi::AcquirePropertyMetadata> for Capabilities { (value.video[0].try_into()?, value.video[1].try_into()?); Ok(Self { - video: ( - Py::new(py, video.0)?, - Py::new(py, video.1)?, - ), + video: (Py::new(py, video.0)?, Py::new(py, video.1)?), }) })?) } @@ -152,11 +149,8 @@ impl TryFrom<&Capabilities> for capi::AcquirePropertyMetadata { (value.video.0.extract(py)?, value.video.1.extract(py)?); Ok(Self { - video: [ - (&video.0).try_into()?, - (&video.1).try_into()?, - ], + video: [(&video.0).try_into()?, (&video.1).try_into()?], }) })?) } -} \ No newline at end of file +} diff --git a/src/components/mod.rs b/src/components/mod.rs index 736ee0d..7d653fa 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,10 +1,10 @@ mod direction; pub(crate) mod macros; +mod property; mod sample_type; mod signal_io_kind; mod signal_type; mod trigger_edge; -mod property; use anyhow::Result; use pyo3::prelude::*; @@ -13,11 +13,11 @@ use serde::{Deserialize, Serialize}; // Exports pub use direction::Direction; +pub use property::{Property, PropertyType}; pub use sample_type::SampleType; pub use signal_io_kind::SignalIOKind; pub use signal_type::SignalType; pub use trigger_edge::TriggerEdge; -pub use property::{Property, PropertyType}; use crate::{capi, components::macros::impl_plain_old_dict}; diff --git a/src/components/property.rs b/src/components/property.rs index 15bd268..a9f2257 100644 --- a/src/components/property.rs +++ b/src/components/property.rs @@ -1,9 +1,9 @@ use pyo3::prelude::*; +use crate::components::macros::impl_plain_old_dict; use crate::{capi, components::macros::cvt}; use anyhow::anyhow; use serde::{Deserialize, Serialize}; -use crate::components::macros::impl_plain_old_dict; /// PropertyType #[pyclass] diff --git a/src/lib.rs b/src/lib.rs index fe49c94..ee08844 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub(crate) mod camera; +pub(crate) mod capabilities; pub(crate) mod capi; pub(crate) mod components; pub(crate) mod core_properties; @@ -6,7 +7,6 @@ pub(crate) mod device; pub(crate) mod device_manager; pub(crate) mod runtime; pub(crate) mod storage; -pub(crate) mod capabilities; use anyhow::{anyhow, Result}; use device_manager::DeviceManager; diff --git a/src/runtime.rs b/src/runtime.rs index 564af84..3bf812e 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -13,11 +13,11 @@ use std::{ sync::Arc, }; +use crate::capabilities::Capabilities; use crate::{ capi, components::macros::impl_plain_old_dict, core_properties::Properties, device::DeviceState, device_manager, Status, }; -use crate::capabilities::Capabilities; unsafe extern "C" fn reporter( is_error: ::std::os::raw::c_int, @@ -159,7 +159,8 @@ impl Runtime { fn get_capabilities(&self, py: Python<'_>) -> PyResult { let mut meta: capi::AcquirePropertyMetadata = Default::default(); Python::allow_threads(py, || { - unsafe { capi::acquire_get_configuration_metadata(self.as_ref().as_ptr(), &mut meta) }.ok() + unsafe { capi::acquire_get_configuration_metadata(self.as_ref().as_ptr(), &mut meta) } + .ok() })?; Ok((&meta).try_into()?) } diff --git a/src/storage.rs b/src/storage.rs index c1d02f9..3de14f9 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -1,9 +1,6 @@ use crate::{ capi, - components::{ - macros::impl_plain_old_dict, - Property, - }, + components::{macros::impl_plain_old_dict, Property}, }; use pyo3::prelude::*; use serde::{Deserialize, Serialize}; @@ -127,7 +124,8 @@ impl TryFrom for StorageProperties { height: value.chunk_dims_px.height, planes: value.chunk_dims_px.planes, }, - ).unwrap() + ) + .unwrap() }); let shard_dims_chunks = Python::with_gil(|py| { @@ -138,7 +136,8 @@ impl TryFrom for StorageProperties { height: value.shard_dims_chunks.height, planes: value.shard_dims_chunks.planes, }, - ).unwrap() + ) + .unwrap() }); Ok(Self { @@ -293,7 +292,9 @@ impl Default for capi::StorageProperties_storage_properties_sharding_s { impl TryFrom for ChunkDims { type Error = anyhow::Error; - fn try_from(value: capi::StorageProperties_storage_properties_chunking_s) -> Result { + fn try_from( + value: capi::StorageProperties_storage_properties_chunking_s, + ) -> Result { Ok(ChunkDims { width: value.width, height: value.height, @@ -317,7 +318,9 @@ impl TryFrom<&ChunkDims> for capi::StorageProperties_storage_properties_chunking impl TryFrom for ShardDims { type Error = anyhow::Error; - fn try_from(value: capi::StorageProperties_storage_properties_sharding_s) -> Result { + fn try_from( + value: capi::StorageProperties_storage_properties_sharding_s, + ) -> Result { Ok(ShardDims { width: value.width, height: value.height, @@ -479,9 +482,12 @@ impl_plain_old_dict!(StorageCapabilities); impl Default for StorageCapabilities { fn default() -> Self { - let chunk_dims_px = Python::with_gil(|py| Py::new(py, ChunkingCapabilities::default()).unwrap()); - let shard_dims_chunks = Python::with_gil(|py| Py::new(py, ShardingCapabilities::default()).unwrap()); - let multiscale = Python::with_gil(|py| Py::new(py, MultiscaleCapabilities::default()).unwrap()); + let chunk_dims_px = + Python::with_gil(|py| Py::new(py, ChunkingCapabilities::default()).unwrap()); + let shard_dims_chunks = + Python::with_gil(|py| Py::new(py, ShardingCapabilities::default()).unwrap()); + let multiscale = + Python::with_gil(|py| Py::new(py, MultiscaleCapabilities::default()).unwrap()); Self { chunk_dims_px, shard_dims_chunks, @@ -547,7 +553,9 @@ impl Default for capi::StoragePropertyMetadata_storage_property_metadata_chunkin } } -impl TryFrom<&ChunkingCapabilities> for capi::StoragePropertyMetadata_storage_property_metadata_chunking_s { +impl TryFrom<&ChunkingCapabilities> + for capi::StoragePropertyMetadata_storage_property_metadata_chunking_s +{ type Error = anyhow::Error; fn try_from(value: &ChunkingCapabilities) -> Result { @@ -578,7 +586,9 @@ impl Default for capi::StoragePropertyMetadata_storage_property_metadata_shardin } } -impl TryFrom<&ShardingCapabilities> for capi::StoragePropertyMetadata_storage_property_metadata_sharding_s { +impl TryFrom<&ShardingCapabilities> + for capi::StoragePropertyMetadata_storage_property_metadata_sharding_s +{ type Error = anyhow::Error; fn try_from(value: &ShardingCapabilities) -> Result { @@ -606,7 +616,9 @@ impl Default for capi::StoragePropertyMetadata_storage_property_metadata_multisc } } -impl TryFrom<&MultiscaleCapabilities> for capi::StoragePropertyMetadata_storage_property_metadata_multiscale_s { +impl TryFrom<&MultiscaleCapabilities> + for capi::StoragePropertyMetadata_storage_property_metadata_multiscale_s +{ type Error = anyhow::Error; fn try_from(value: &MultiscaleCapabilities) -> Result { @@ -630,12 +642,14 @@ impl TryFrom<&StorageCapabilities> for capi::StoragePropertyMetadata { type Error = anyhow::Error; fn try_from(value: &StorageCapabilities) -> Result { - let (chunk_dims_px, shard_dims_chunks, multiscale) = Python::with_gil(|py| -> PyResult<_> { - let chunk_dims_px: ChunkingCapabilities = value.chunk_dims_px.extract(py)?; - let shard_dims_chunks: ShardingCapabilities = value.shard_dims_chunks.extract(py)?; - let multiscale: MultiscaleCapabilities = value.multiscale.extract(py)?; - Ok((chunk_dims_px, shard_dims_chunks, multiscale)) - })?; + let (chunk_dims_px, shard_dims_chunks, multiscale) = + Python::with_gil(|py| -> PyResult<_> { + let chunk_dims_px: ChunkingCapabilities = value.chunk_dims_px.extract(py)?; + let shard_dims_chunks: ShardingCapabilities = + value.shard_dims_chunks.extract(py)?; + let multiscale: MultiscaleCapabilities = value.multiscale.extract(py)?; + Ok((chunk_dims_px, shard_dims_chunks, multiscale)) + })?; Ok(Self { chunk_dims_px: (&chunk_dims_px).try_into()?, @@ -643,4 +657,4 @@ impl TryFrom<&StorageCapabilities> for capi::StoragePropertyMetadata { multiscale: (&multiscale).try_into()?, }) } -} \ No newline at end of file +} diff --git a/tests/test_spinnaker.py b/tests/test_spinnaker.py index 10d7800..7c08be7 100644 --- a/tests/test_spinnaker.py +++ b/tests/test_spinnaker.py @@ -22,4 +22,4 @@ def test_blackfly_camera_is_present(runtime: acquire.Runtime): def test_oryx_camera_is_present(runtime: acquire.Runtime): dm = runtime.device_manager() - assert dm.select(DeviceKind.Camera, ".*ORX-10GS-51S5M.*") \ No newline at end of file + assert dm.select(DeviceKind.Camera, ".*ORX-10GS-51S5M.*")