Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile_processor
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY . /app
# RUN pip install ./arroyo
RUN pip install --no-cache-dir --upgrade .

CMD ["python", "-m", "tr_ap_xps.apps.processor_cli"]
ENTRYPOINT ["arroyo", "run"]
18 changes: 18 additions & 0 deletions block_configs/labview_processor_block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
blocks:
- name: XPS LabVIEW Operator
description: Real-time AP-XPS processor for LabVIEW data

operator:
class: tr_ap_xps.pipeline.xps_operator.build_xps_operator
kwargs:
build_heatmaps: true

listeners:
- class: tr_ap_xps.labview.xps_labview_listener_factory
kwargs:
zmq_connection_address: "tcp://localhost:5555"

publishers:
- class: tr_ap_xps.websockets.xps_ws_publisher_factory
kwargs:
ws_url: "ws://0.0.0.0:8001/xps_operator"
18 changes: 18 additions & 0 deletions block_configs/timepix_processor_block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
blocks:
- name: XPS Timepix Operator
description: Real-time AP-XPS processor for Timepix data

operator:
class: tr_ap_xps.pipeline.xps_operator.build_xps_operator
kwargs:
build_heatmaps: false

listeners:
- class: tr_ap_xps.timepix.xps_timepix_listener_factory
kwargs:
zmq_connection_address: "tcp://host.docker.internal:5657"

publishers:
- class: tr_ap_xps.websockets.xps_ws_publisher_factory
kwargs:
ws_url: "ws://0.0.0.0:8001/xps_operator"
51 changes: 25 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
services:
tiled:
# see the file ./tiled/deploy/config.yml for detailed configuration of tiled
image: ghcr.io/bluesky/tiled:main
ports:
- "8000:8000"
environment:
- TILED_SINGLE_USER_API_KEY=${TILED_SINGLE_USER_API_KEY}
volumes:
- ./services/tiled/deploy:/deploy:Z
- ./data:/data:Z
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://tiled:8000/healthz"]
interval: 10s
timeout: 5s
retries: 3
networks:
aps_net:
# see the file ./tiled/deploy/config.yml for detailed configuration of tiled
image: ghcr.io/bluesky/tiled:main
ports:
- "8000:8000"
environment:
- TILED_SINGLE_USER_API_KEY=${TILED_SINGLE_USER_API_KEY}
volumes:
- ./services/tiled/deploy:/deploy:Z
- ./data:/data:Z
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://tiled:8000/healthz"]
interval: 10s
timeout: 5s
retries: 3
networks:
- mle_net


processor:
command: python -m tr_ap_xps.apps.processor_cli_tpx
timepix_processor:
build:
context: .
dockerfile: Dockerfile_processor
command: "block_configs/timepix_processor_block.yaml"
restart: unless-stopped
ports:
- "8001:8001"
volumes:
- .:/app:Z
- ./settings_container.yaml:/app/settings.yaml:Z
networks:
aps_net:
depends_on:
tiled:
condition: service_healthy
mle_net:


frontend:
build:
Expand All @@ -45,8 +43,9 @@ services:
volumes:
- .:/app:Z
networks:
aps_net:
mle_net:

networks:
aps_net:
mle_net:
name: mle_net
driver: bridge
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classifiers = [
]

dependencies = [
"arroyopy",
"arroyopy @ git+https://github.com/als-computing/arroyopy.git",
"astropy",
"dynaconf",
"python-dotenv",
Expand Down
23 changes: 0 additions & 23 deletions settings.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions settings_container.yaml

This file was deleted.

Empty file removed src/tr_ap_xps/apps/__init__.py
Empty file.
77 changes: 0 additions & 77 deletions src/tr_ap_xps/apps/processor_cli.py

This file was deleted.

78 changes: 0 additions & 78 deletions src/tr_ap_xps/apps/processor_cli_tpx.py

This file was deleted.

25 changes: 14 additions & 11 deletions src/tr_ap_xps/labview.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from arroyopy.zmq import ZMQListener

from .config import settings
from .schemas import NumpyArrayModel, XPSImageInfo, XPSRawEvent, XPSStart, XPSStop

# Maintain a map of LabView datatypes. LabView sends BigE,
Expand All @@ -26,25 +25,21 @@
"Double Float": np.dtype(np.double).newbyteorder(">"),
}

app_settings = settings.xps_operator

logger = logging.getLogger(__name__)


def setup_zmq():
# removed app_settings; accepts zmq_connection_address as parameters instead
def setup_zmq(
Comment thread
xiaoyachong marked this conversation as resolved.
zmq_connection_address: str = "tcp://localhost:5555",
):
ctx = zmq.asyncio.Context()
lv_zmq_socket = ctx.socket(zmq.SUB)
lv_zmq_socket.setsockopt(zmq.RCVHWM, 100000)
logger.info(
f"binding to: {app_settings.lv_zmq_listener.zmq_pub_address}:{app_settings.lv_zmq_listener.zmq_pub_port}"
)
lv_zmq_socket.connect(
f"{app_settings.lv_zmq_listener.zmq_pub_address}:{app_settings.lv_zmq_listener.zmq_pub_port}"
)
logger.info(f"connecting to: {zmq_connection_address}")
lv_zmq_socket.connect(zmq_connection_address)
lv_zmq_socket.setsockopt(zmq.SUBSCRIBE, b"")
return lv_zmq_socket


class XPSLabviewZMQListener(ZMQListener):
stop_signal = False

Expand Down Expand Up @@ -135,3 +130,11 @@ def _build_stop(message: dict) -> XPSStop:
if logger.getEffectiveLevel() == logging.DEBUG:
logger.debug(f"stop: {message}")
return XPSStop(**message)


def xps_labview_listener_factory(
operator,
zmq_connection_address: str = "tcp://localhost:5555",
) -> XPSLabviewZMQListener:
socket = setup_zmq(zmq_connection_address)
return XPSLabviewZMQListener(operator=operator, zmq_socket=socket)
Loading
Loading