diff --git a/docker/clustering_service/Dockerfile b/docker/clustering_service/Dockerfile index a71caa9..3f777f9 100644 --- a/docker/clustering_service/Dockerfile +++ b/docker/clustering_service/Dockerfile @@ -1,22 +1,15 @@ # docker build -t kmeans_service:latest . -FROM fedora -# Lock in a python version because of some backward compatability issues -RUN dnf update -y \ - && dnf install -y \ - python3.9 \ - g++ \ - gcc \ - git \ - && dnf clean all +FROM python:3.10 -RUN python3.9 -m ensurepip --upgrade -RUN pip3 install 'bluesky-adaptive[all]' +RUN pip3 install bluesky-adaptive RUN pip3 install uvicorn fastapi caproto nslsii -RUN pip3 install git+https://github.com/NSLS-II-PDF/pdf-agents.git@main +RUN pip3 install git+https://github.com/NSLS-II-PDF/pdf-agents.git@enh-container-service RUN pip3 install git+https://github.com/bluesky/databroker.git@v2.0.0b13#egg=databroker +RUN pip3 install scikit-learn COPY kmeans_service.py /src/kmeans_service.py ENV BS_AGENT_STARTUP_SCRIPT_PATH=/src/kmeans_service.py +ENV OFFLINE_MODE="TRUE" -CMD uvicorn bluesky_adaptive.server:app --host 127.0.0.1 --port 60610 \ No newline at end of file +CMD uvicorn bluesky_adaptive.server:app --host 127.0.0.1 --port 60610 diff --git a/docker/clustering_service/build_and_run.sh b/docker/clustering_service/build_and_run.sh index ec41eec..932f590 100644 --- a/docker/clustering_service/build_and_run.sh +++ b/docker/clustering_service/build_and_run.sh @@ -1,2 +1,2 @@ -docker build -t kmeans_service:latest . -docker-compose up \ No newline at end of file +docker build -t kmeans-service:pdf . +docker-compose up diff --git a/docker/clustering_service/docker-compose.yml b/docker/clustering_service/docker-compose.yml index a089065..2c356f7 100644 --- a/docker/clustering_service/docker-compose.yml +++ b/docker/clustering_service/docker-compose.yml @@ -1,8 +1,8 @@ version: '3' services: - your-service: - image: kmeans_service:latest + kmeans-service: + image: kmeans-service:pdf ports: - 60281:60610 volumes: - - /etc/bluesky:/etc/bluesky \ No newline at end of file + - /etc/bluesky:/etc/bluesky diff --git a/docker/clustering_service/kmeans_service.py b/docker/clustering_service/kmeans_service.py index 4505cbf..4d9d7fc 100644 --- a/docker/clustering_service/kmeans_service.py +++ b/docker/clustering_service/kmeans_service.py @@ -1,3 +1,5 @@ +import os + from bluesky_adaptive.server import register_variable, shutdown_decorator, startup_decorator from pdf_agents.sklearn import PassiveKmeansAgent @@ -14,7 +16,7 @@ def __init__(self, *args, **kwargs): @property def name(self): - return "KmeansAgent" + return "KmeansAgentService" @property def running(self): @@ -63,7 +65,9 @@ def server_registrations(self) -> None: return super().server_registrations() -agent = Agent(k_clusters=3, report_on_tell=True, ask_on_tell=False, direct_to_queue=False) +offline_mode = str(os.getenv("OFFLINE_MODE", "False")).lower() in ["true", "1", "yes"] +print(offline_mode) +agent = Agent(k_clusters=3, report_on_tell=True, ask_on_tell=False, direct_to_queue=False, offline=offline_mode) @startup_decorator diff --git a/pdf_agents/sklearn.py b/pdf_agents/sklearn.py index 3020987..9a513a4 100644 --- a/pdf_agents/sklearn.py +++ b/pdf_agents/sklearn.py @@ -19,8 +19,6 @@ class PassiveKmeansAgent(PDFBaseAgent, ClusterAgentBase): def __init__(self, k_clusters, *args, **kwargs): estimator = KMeans(k_clusters) - _default_kwargs = self.get_beamline_objects() - _default_kwargs.update(kwargs) super().__init__(*args, estimator=estimator, **kwargs) def clear_caches(self):