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
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest

env:
DASHBOARD_IMAGE_NAME: intersect-dashboard
DASHBOARD_SERVICE_IMAGE_NAME: intersect-service
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_STORE
__pycache__
.pytest_cache
*.tgz
Chart.lock
.env.*
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile.dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apt-get update && apt-get install -y \
wget \
&& rm -rf /var/lib/apt/lists/*

COPY environment.yaml ./environment.yaml
COPY ./config/environment.yaml ./environment.yaml

RUN conda env create -f ./environment.yaml && \
conda clean -a -y && \
Expand All @@ -17,16 +17,15 @@ FROM python:3.10-slim
ENV PATH=/opt/conda/bin:$PATH

COPY --from=build /opt/conda /opt/conda
COPY config_dashboard.yaml /app/config_dashboard_default.yaml
COPY ./config/config_dashboard.yaml /app/config_dashboard_default.yaml

WORKDIR /usr/src/dashboard
COPY dashboard.py ./dashboard.py
COPY constants.py ./constants.py
COPY load_gsas.py ./load_gsas.py
COPY ./services/dashboard.py ./dashboard.py
COPY ./services/constants.py ./constants.py
COPY ./services/gsa_loader.py ./gsa_loader.py

EXPOSE 10042

ENV BOKEH_ALLOW_WS_ORIGIN="*"

CMD ["conda", "run", "--no-capture-output", "-n", "espd_mantid", "python", "-m", "panel", "serve", "dashboard.py", "--address", "0.0.0.0", "--allow-websocket-origin", "*", "--port", "10042"]

9 changes: 4 additions & 5 deletions Dockerfile.dashboard_service
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ WORKDIR /usr/src/dashboard_service
RUN python -m pip install intersect-sdk[amqp]
RUN python -m pip install pyyaml

COPY dashboard_service.py ./dashboard_service.py
COPY constants.py ./constants.py
COPY config_service.yaml /app/config_default.yaml
COPY config_dashboard.yaml /app/config_dashboard_default.yaml
COPY ./services/dashboard_service.py ./dashboard_service.py
COPY ./services/constants.py ./constants.py
COPY ./config/config_service.yaml /app/config_default.yaml
COPY ./config/config_dashboard.yaml /app/config_dashboard_default.yaml

EXPOSE 10043

ENTRYPOINT ["python", "dashboard_service.py"]

4 changes: 2 additions & 2 deletions Dockerfile.storage_service
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ WORKDIR /usr/src/storage_service

RUN python -m pip install python-dotenv boto3==1.35.99

COPY storage_service.py ./storage_service.py
COPY constants.py ./constants.py
COPY ./services/storage_service.py ./storage_service.py
COPY ./services/constants.py ./constants.py

EXPOSE 10044

Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Local
dev:
@panel serve ./src/dashboard.py --show --dev
# Docker
dashboard:
@docker build --platform linux/amd64 -t intersect-dashboard -f Dockerfile.dashboard .
@docker build -t intersect-dashboard -f Dockerfile.dashboard .

service:
@docker build -t intersect-service -f Dockerfile.dashboard_service .
Expand All @@ -21,3 +25,10 @@ undeploy:

rmvolumes:
@docker volume rm nsdf-intersect_intersect_bragg_volume nsdf-intersect_intersect_transition_volume nsdf-intersect_intersect_andie_volume nsdf-intersect_intersect_scientist_cloud_volume

# clients

realtime:
@python clients/realtime_client.py
transition:
@python clients/transition_client.py
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<p align="center">
<a href="https://www.python.org/downloads/release/python-310/"><img alt="Python 3.10" src="https://img.shields.io/badge/Python-3.10-3776AB.svg?style=flat&logo=python&logoColor=white"></a>
<a href="https://www.docker.com"><img alt="Docker" src="https://badges.aleen42.com/src/docker.svg"></a>
<img src="https://github.com/nsdf-fabric/NSDF-INTERSECT/actions/workflows/test.yml/badge.svg" alt="test status badge">
<img src="https://github.com/nsdf-fabric/NSDF-INTERSECT/actions/workflows/publish.yml/badge.svg" alt="publish status badge">
<img src="https://github.com/nsdf-fabric/NSDF-INTERSECT/actions/workflows/deploy-linode.yml/badge.svg" alt="linode intersect chart cluster deployment status badge">
</p>
Expand Down Expand Up @@ -113,19 +114,19 @@ To run this client make sure you have the service running, then you can execute
- For bragg data

```bash
python single_client.py --bragg
python clients/single_client.py --bragg
```

- For transition data

```bash
python single_client.py --transition
python clients/single_client.py --transition
```

- For next temperature data

```bash
python single_client.py --next-temp --val 30.0
python clients/single_client.py --next-temp --val 30.0
```

### realtime_client.py
Expand All @@ -136,7 +137,7 @@ on this type of client here [counting example](https://intersect-python-sdk.read
To run this client make sure you have the service running, then you can execute the following:

```bash
python realtime_client.py
python clients/realtime_client.py
```

### transition_client.py
Expand All @@ -146,11 +147,11 @@ The client can simulate a full campaign for the transition plot via its two argu

```bash
# default --n is 10 --ny is 3
python transition_client.py
python clients/transition_client.py
```

```bash
python transition_client.py --ny 5
python clients/transition_client.py --ny 5
```

## 📦 Running all services
Expand Down
Empty file added clients/__init__.py
Empty file.
7 changes: 4 additions & 3 deletions realtime_client.py → clients/realtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
default_intersect_lifecycle_loop,
)

from dashboard_service import FileType, NextTemperature, TransitionData
from schema import FileType, TransitionData, NextTemperature

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -63,7 +63,8 @@
]


CONFIG_CLIENT = "config_client.yaml"
CONFIG_CLIENT = os.path.join(os.getcwd(), "config/config_client.yaml")
DATA_PATH = os.path.join(os.getcwd(), "clients/short_list_of_data.txt")


class SampleOrchestrator:
Expand Down Expand Up @@ -111,7 +112,7 @@ def __init__(self) -> None:
)

# bragg data
with open("./short_list_of_data.txt") as f:
with open(DATA_PATH) as f:
for line in f:
filepath = line.strip()
with open(filepath, "rb") as file:
Expand Down
49 changes: 49 additions & 0 deletions clients/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing_extensions import Annotated
from pydantic import BaseModel, Field
from typing import List


SerializedBase64 = Annotated[bytes, Field(json_schema_extra={"format": "base64"})]


class FileType(BaseModel):
"""
Represents a gsa file.

Attributes:
filename (str): The name of the file.
file (SerializedBase64): The file content serialized in Base64 format.
"""

filename: str
file: SerializedBase64


class TransitionData(BaseModel):
"""
Represents a transition data record.

Attributes:
id (str): The campaign id for the transition data record.
temp (float): The temperature value associated with the transition.
ylist (List[float]): A list of float values representing the observed peaks (d-Spacing) associated with temp.
"""

id: str
temp: float
ylist: List[float]


class NextTemperature(BaseModel):
"""
Represents the next temperature record (ANDiE prediction).

Attributes:
id (str): The campaign id for the next temperature data record.
data (float): The predicted temperature value.
timestamp (int): The timestamp when the prediction was recorded.
"""

id: str
data: float
timestamp: int
File renamed without changes.
4 changes: 2 additions & 2 deletions single_client.py → clients/single_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
default_intersect_lifecycle_loop,
)

from dashboard_service import FileType, TransitionData, NextTemperature
from schema import FileType, TransitionData, NextTemperature

logging.basicConfig(level=logging.INFO)
CONFIG_CLIENT = "config_client.yaml"
CONFIG_CLIENT = "config/config_client.yaml"

transition_data = [
[284.89, 0.9353496748096445, 1.5583828040832086],
Expand Down
4 changes: 2 additions & 2 deletions transition_client.py → clients/transition_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
default_intersect_lifecycle_loop,
)

from dashboard_service import NextTemperature, TransitionData
from schema import TransitionData, NextTemperature

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -64,7 +64,7 @@
[200.00, 1.426667976082179, 0.16991445836095545],
]

CONFIG_CLIENT = "config_client.yaml"
CONFIG_CLIENT = "config/config_client.yaml"


def generate_y_list(ylen: int) -> List[float]:
Expand Down
3 changes: 3 additions & 0 deletions compose_local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
services:
broker:
image: "bitnami/rabbitmq:3.13.3"
container_name: rabbitmq
ports:
- "1883:1883" # MQTT port
- "5672:5672" # AMQP port
Expand All @@ -24,6 +25,7 @@ services:

dashboard:
image: "intersect-dashboard:latest"
container_name: dashboard
ports:
- "10042:10042"
depends_on:
Expand All @@ -44,6 +46,7 @@ services:
- intersect_scientist_cloud_volume:/usr/src/dashboard/scientist_cloud_volume
dashboard_service:
image: "intersect-service:latest"
container_name: dashboard_service
ports:
- "10043:10043"
environment:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions environment.yaml → config/environment.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: espd_mantid
channels:
- mantid
- conda-forge
dependencies:
- pyyaml
- mantid=6.11.0
- numpy
- python=3.10
- plotly==6.0.0
- panel==1.6.0
Expand Down
52 changes: 0 additions & 52 deletions load_gsas.py

This file was deleted.

2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath=services
3 changes: 3 additions & 0 deletions services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .dashboard import AppState, App

__all__ = ["AppState", "App"]
File renamed without changes.
Loading