pigeon-tem-comms 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pigeon_tem_comms-0.1.0/LICENSE +11 -0
- pigeon_tem_comms-0.1.0/PKG-INFO +17 -0
- pigeon_tem_comms-0.1.0/README.md +6 -0
- pigeon_tem_comms-0.1.0/TEM_comms/__init__.py +37 -0
- pigeon_tem_comms-0.1.0/TEM_comms/buffer.py +7 -0
- pigeon_tem_comms-0.1.0/TEM_comms/camera.py +23 -0
- pigeon_tem_comms-0.1.0/TEM_comms/scope.py +21 -0
- pigeon_tem_comms-0.1.0/TEM_comms/stage/__init__.py +3 -0
- pigeon_tem_comms-0.1.0/TEM_comms/stage/aperture.py +10 -0
- pigeon_tem_comms-0.1.0/TEM_comms/stage/motion.py +12 -0
- pigeon_tem_comms-0.1.0/TEM_comms/stage/rotation.py +12 -0
- pigeon_tem_comms-0.1.0/TEM_comms/tile/__init__.py +33 -0
- pigeon_tem_comms-0.1.0/TEM_comms/tile/statistics.py +15 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/PKG-INFO +17 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/SOURCES.txt +21 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/dependency_links.txt +1 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/entry_points.txt +2 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/requires.txt +2 -0
- pigeon_tem_comms-0.1.0/pigeon_tem_comms.egg-info/top_level.txt +1 -0
- pigeon_tem_comms-0.1.0/pyproject.toml +16 -0
- pigeon_tem_comms-0.1.0/setup.cfg +4 -0
- pigeon_tem_comms-0.1.0/tests/test_buffer.py +41 -0
- pigeon_tem_comms-0.1.0/tests/test_scope_command.py +21 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2024 Allen Institute
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pigeon-tem-comms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pigeon messages for the next generation TEM imaging system.
|
|
5
|
+
Author-email: Cameron Devine <cameron.devine@alleninstitute.org>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pigeon-client
|
|
10
|
+
Requires-Dist: pydantic
|
|
11
|
+
|
|
12
|
+
[](https://github.com/AllenInstitute/TEM_comms/actions)
|
|
13
|
+
[](https://pypi.org/project/pigeon-tem-comms/)
|
|
14
|
+
|
|
15
|
+
# TEM Comms
|
|
16
|
+
|
|
17
|
+
TEM Comms is a set of [Pydantic](https://docs.pydantic.dev/latest/) models to be used as messages with [Pigeon](https://github.com/AllenInstitute/pigeon) for the [Allen Institute's](https://alleninstitute.org/) next generation transmission electron microscope (TEM) [image acquisition system](https://alleninstitute.github.io/TEM_architecture/).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[](https://github.com/AllenInstitute/TEM_comms/actions)
|
|
2
|
+
[](https://pypi.org/project/pigeon-tem-comms/)
|
|
3
|
+
|
|
4
|
+
# TEM Comms
|
|
5
|
+
|
|
6
|
+
TEM Comms is a set of [Pydantic](https://docs.pydantic.dev/latest/) models to be used as messages with [Pigeon](https://github.com/AllenInstitute/pigeon) for the [Allen Institute's](https://alleninstitute.org/) next generation transmission electron microscope (TEM) [image acquisition system](https://alleninstitute.github.io/TEM_architecture/).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from . import buffer
|
|
2
|
+
from . import camera
|
|
3
|
+
from . import scope
|
|
4
|
+
from . import stage
|
|
5
|
+
from . import tile
|
|
6
|
+
|
|
7
|
+
import importlib.metadata
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
__version__ = importlib.metadata.version("TEM_comms")
|
|
11
|
+
|
|
12
|
+
topics = {
|
|
13
|
+
"buffer.status": buffer.Status,
|
|
14
|
+
"camera.command": camera.Command,
|
|
15
|
+
"camera.image": camera.Image,
|
|
16
|
+
"camera.settings": camera.Settings,
|
|
17
|
+
"camera.status": camera.Status,
|
|
18
|
+
"scope.command": scope.Command,
|
|
19
|
+
"scope.status": scope.Status,
|
|
20
|
+
"stage.aperture.command": stage.aperture.Command,
|
|
21
|
+
"stage.aperture.status": stage.aperture.Status,
|
|
22
|
+
"stage.motion.command": stage.motion.Command,
|
|
23
|
+
"stage.motion.status": stage.motion.Status,
|
|
24
|
+
"stage.rotation.command": stage.rotation.Command,
|
|
25
|
+
"stage.rotation.status": stage.rotation.Status,
|
|
26
|
+
"tile.jpeg": tile.JPEG,
|
|
27
|
+
"tile.minimap": tile.Minimap,
|
|
28
|
+
"tile.processed": tile.Processed,
|
|
29
|
+
"tile.raw": tile.Raw,
|
|
30
|
+
"tile.statistics.focus": tile.statistics.Focus,
|
|
31
|
+
"tile.statistics.histogram": tile.statistics.Histogram,
|
|
32
|
+
"tile.statistics.min_max_mean": tile.statistics.MinMaxMean,
|
|
33
|
+
"tile.transform": tile.Transform,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
msgs = (topics, __version__)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from emarfarap import BaseMessage
|
|
2
|
+
|
|
3
|
+
class Command(BaseMessage):
|
|
4
|
+
tile_id: str
|
|
5
|
+
|
|
6
|
+
class Image(BaseMessage):
|
|
7
|
+
tile_id: str
|
|
8
|
+
path: str
|
|
9
|
+
|
|
10
|
+
class Settings(BaseMessage):
|
|
11
|
+
exposure: float | None = None
|
|
12
|
+
width: int | None = None
|
|
13
|
+
height: int | None = None
|
|
14
|
+
|
|
15
|
+
class Status(BaseMessage):
|
|
16
|
+
exposure: float
|
|
17
|
+
width: int
|
|
18
|
+
height: int
|
|
19
|
+
temp: float
|
|
20
|
+
target_temp: float
|
|
21
|
+
device_name: str
|
|
22
|
+
device_model_id: int
|
|
23
|
+
device_sn: str
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from emarfarap import BaseMessage
|
|
2
|
+
from typing import Literal
|
|
3
|
+
from pydantic import model_validator
|
|
4
|
+
|
|
5
|
+
class Command(BaseMessage):
|
|
6
|
+
focus: int | None = None
|
|
7
|
+
mag_mode: Literal["LM", "MAG1", "MAG2"] | None = None
|
|
8
|
+
mag: int | None = None
|
|
9
|
+
|
|
10
|
+
@model_validator(mode="after")
|
|
11
|
+
def check_mag(self):
|
|
12
|
+
assert (self.mag_mode is None) == (self.mag is None)
|
|
13
|
+
return self
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Status(BaseMessage):
|
|
17
|
+
focus: int
|
|
18
|
+
aperture: str | None
|
|
19
|
+
mag_mode: str
|
|
20
|
+
mag: int
|
|
21
|
+
tank_voltage: int
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from emarfarap import BaseMessage
|
|
2
|
+
|
|
3
|
+
class Command(BaseMessage):
|
|
4
|
+
angle_x: float | None = None
|
|
5
|
+
angle_y: float | None = None
|
|
6
|
+
calibrate: bool = False
|
|
7
|
+
|
|
8
|
+
class Status(BaseMessage):
|
|
9
|
+
angle_x: float
|
|
10
|
+
angle_y: float
|
|
11
|
+
in_motion: bool
|
|
12
|
+
error: str = ""
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from emarfarap import BaseMessage
|
|
2
|
+
from . import statistics
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class JPEG(BaseMessage):
|
|
6
|
+
tile_id: str
|
|
7
|
+
path: str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Minimap(BaseMessage):
|
|
11
|
+
tile_id: str
|
|
12
|
+
path: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Processed(BaseMessage):
|
|
16
|
+
tile_id: str
|
|
17
|
+
path: str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Raw(BaseMessage):
|
|
21
|
+
tile_id: str
|
|
22
|
+
montage_id: str
|
|
23
|
+
path: str
|
|
24
|
+
row: int
|
|
25
|
+
column: int
|
|
26
|
+
overlap: float
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Transform(BaseMessage):
|
|
30
|
+
tile_id: str
|
|
31
|
+
rotation: float
|
|
32
|
+
x: float
|
|
33
|
+
y: float
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pigeon-tem-comms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pigeon messages for the next generation TEM imaging system.
|
|
5
|
+
Author-email: Cameron Devine <cameron.devine@alleninstitute.org>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pigeon-client
|
|
10
|
+
Requires-Dist: pydantic
|
|
11
|
+
|
|
12
|
+
[](https://github.com/AllenInstitute/TEM_comms/actions)
|
|
13
|
+
[](https://pypi.org/project/pigeon-tem-comms/)
|
|
14
|
+
|
|
15
|
+
# TEM Comms
|
|
16
|
+
|
|
17
|
+
TEM Comms is a set of [Pydantic](https://docs.pydantic.dev/latest/) models to be used as messages with [Pigeon](https://github.com/AllenInstitute/pigeon) for the [Allen Institute's](https://alleninstitute.org/) next generation transmission electron microscope (TEM) [image acquisition system](https://alleninstitute.github.io/TEM_architecture/).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
TEM_comms/__init__.py
|
|
5
|
+
TEM_comms/buffer.py
|
|
6
|
+
TEM_comms/camera.py
|
|
7
|
+
TEM_comms/scope.py
|
|
8
|
+
TEM_comms/stage/__init__.py
|
|
9
|
+
TEM_comms/stage/aperture.py
|
|
10
|
+
TEM_comms/stage/motion.py
|
|
11
|
+
TEM_comms/stage/rotation.py
|
|
12
|
+
TEM_comms/tile/__init__.py
|
|
13
|
+
TEM_comms/tile/statistics.py
|
|
14
|
+
pigeon_tem_comms.egg-info/PKG-INFO
|
|
15
|
+
pigeon_tem_comms.egg-info/SOURCES.txt
|
|
16
|
+
pigeon_tem_comms.egg-info/dependency_links.txt
|
|
17
|
+
pigeon_tem_comms.egg-info/entry_points.txt
|
|
18
|
+
pigeon_tem_comms.egg-info/requires.txt
|
|
19
|
+
pigeon_tem_comms.egg-info/top_level.txt
|
|
20
|
+
tests/test_buffer.py
|
|
21
|
+
tests/test_scope_command.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TEM_comms
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pigeon-tem-comms"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="Cameron Devine", email="cameron.devine@alleninstitute.org" },
|
|
6
|
+
]
|
|
7
|
+
description = "Pigeon messages for the next generation TEM imaging system."
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"pigeon-client",
|
|
12
|
+
"pydantic",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.entry-points."pigeon.msgs"]
|
|
16
|
+
msgs = "TEM_comms:msgs"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from TEM_comms.msgs.buffer import Status
|
|
5
|
+
|
|
6
|
+
from pydantic import ValidationError
|
|
7
|
+
|
|
8
|
+
# Test cases for the Status class
|
|
9
|
+
@pytest.mark.parametrize(
|
|
10
|
+
"queue_length, free_space, upload_rate, test_id",
|
|
11
|
+
[
|
|
12
|
+
(10, 100, 20, "test_id_01"), # Happy path: normal values
|
|
13
|
+
(0, 0, 0, "test_id_02"), # Edge case: zero values
|
|
14
|
+
(100, 500, 100, "test_id_03"), # Happy path: higher values
|
|
15
|
+
(-1, -100, -10, "test_id_04"), # Error case: negative values
|
|
16
|
+
(1e6, 1e6, 1e4, "test_id_05"), # Edge case: very large values
|
|
17
|
+
]
|
|
18
|
+
)
|
|
19
|
+
def test_status_initialization(queue_length, free_space, upload_rate, test_id):
|
|
20
|
+
# Act
|
|
21
|
+
status = Status(queue_length=queue_length, free_space=free_space, upload_rate=upload_rate)
|
|
22
|
+
|
|
23
|
+
# Assert
|
|
24
|
+
assert status.queue_length == queue_length, f"{test_id}: queue_length does not match"
|
|
25
|
+
assert status.free_space == free_space, f"{test_id}: free_space does not match"
|
|
26
|
+
assert status.upload_rate == upload_rate, f"{test_id}: upload_rate does not match"
|
|
27
|
+
|
|
28
|
+
# Test cases for handling type errors
|
|
29
|
+
@pytest.mark.parametrize(
|
|
30
|
+
"queue_length, free_space, upload_rate, test_id",
|
|
31
|
+
[
|
|
32
|
+
("ten", 100, 20, "test_id_06"), # Error case: string instead of int for queue_length
|
|
33
|
+
(10, "hundred", 20, "test_id_07"), # Error case: string instead of int for free_space
|
|
34
|
+
(10, 100, "twenty", "test_id_08"), # Error case: string instead of int for upload_rate
|
|
35
|
+
]
|
|
36
|
+
)
|
|
37
|
+
def test_status_type_errors(queue_length, free_space, upload_rate, test_id):
|
|
38
|
+
# Act and Assert
|
|
39
|
+
expected_error_pattern = re.escape("validation error")
|
|
40
|
+
with pytest.raises(ValidationError, match=expected_error_pattern):
|
|
41
|
+
Status(queue_length=queue_length, free_space=free_space, upload_rate=upload_rate)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from TEM_comms.scope import Command
|
|
2
|
+
from pydantic import ValidationError
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
def test_mag():
|
|
6
|
+
with pytest.raises(ValidationError):
|
|
7
|
+
Command(mag_mode="LM")
|
|
8
|
+
|
|
9
|
+
with pytest.raises(ValidationError):
|
|
10
|
+
Command(mag=10)
|
|
11
|
+
|
|
12
|
+
Command()
|
|
13
|
+
Command(mag_mode="LM", mag=1)
|
|
14
|
+
|
|
15
|
+
def test_mag_mode():
|
|
16
|
+
with pytest.raises(ValidationError):
|
|
17
|
+
Command(mag_mode="test", mag=1)
|
|
18
|
+
|
|
19
|
+
Command(mag_mode="LM", mag=1)
|
|
20
|
+
Command(mag_mode="MAG2", mag=1)
|
|
21
|
+
Command(mag_mode="MAG2", mag=1)
|