Skip to content

Commit

Permalink
add: kmeans agent containe
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Dec 11, 2023
1 parent 8babff3 commit b435f52
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docker/kmeans-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.10

RUN mkdir /root/src -p
WORKDIR /root/src
RUN git clone https://github.com/NSLS-II-PDF/pdf-agents.git

RUN pip3 install --upgrade pip setuptools
RUN pip3 install scikit-learn bluesky-adaptive uvicorn fastapi
RUN pip3 install caproto ophyd
RUN pip3 install git+https://github.com/bluesky/[email protected]#egg=databroker
RUN pip3 install nslsii
RUN pip3 install -e pdf-agents

COPY ./startup_script.py /root/src/startup_script.py

ENV BS_AGENT_STARTUP_SCRIPT_PATH=/root/src/startup_script.py
CMD uvicorn bluesky_adaptive.server:app --host 0.0.0.0 --port 60610
26 changes: 26 additions & 0 deletions docker/kmeans-agent/startup_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from bluesky_adaptive.server import register_variable, shutdown_decorator, startup_decorator

from pdf_agents.sklearn import PassiveKmeansAgent


class ContainerKmeansAgent(PassiveKmeansAgent):
@property
def name(self):
return "ContainerKmeansAgent"


agent = ContainerKmeansAgent(k_clusters=3, report_on_tell=False)


@startup_decorator
def startup():
agent.start()


@shutdown_decorator
def shutdown_agent():
return agent.stop()


register_variable("Known UUIDs", agent, "tell_cache")
register_variable("Agent Name", agent, "instance_name")

0 comments on commit b435f52

Please sign in to comment.