From 42211ca07cad4c7e5b1a9bb3d04ff230f26f62a1 Mon Sep 17 00:00:00 2001 From: Phillip Maffettone Date: Wed, 10 Apr 2024 13:14:47 -0400 Subject: [PATCH] fix: changes to nginx and compose and publishing agents --- containers/mmm5-tax-day-compose.yaml | 18 +++++++++++++++-- containers/nginx/html/index.html | 20 ++++++++++++++----- pdf_agents/agents.py | 5 ++--- .../startup_scripts/mmm5-tax-day/gsas.py | 5 +++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/containers/mmm5-tax-day-compose.yaml b/containers/mmm5-tax-day-compose.yaml index f77b394..0dfac9e 100644 --- a/containers/mmm5-tax-day-compose.yaml +++ b/containers/mmm5-tax-day-compose.yaml @@ -8,21 +8,35 @@ services: build: context: ../gsas dockerfile: Containerfile-conda - command: /bin/bash -c "export BS_AGENT_STARTUP_SCRIPT_PATH=/src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py && exec conda run -n GSASII --no-capture-output uvicorn bluesky_adaptive.server:app" + command: conda run -n GSASII --no-capture-output uvicorn bluesky_adaptive.server:app --host 0.0.0.0 + environment: + - TILED_API_KEY=$TILED_API_KEY + - BS_AGENT_STARTUP_SCRIPT_PATH=/src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py volumes: - type: bind source: ../pdf_agents target: /src/pdf-agents/pdf_agents read_only: true + - type: bind + source: /etc/bluesky/kafka.yml + target: /etc/bluesky/kafka.yml + read_only: true kmeans-gsas: image: bluesky:latest - command: /bin/bash -c "BS_AGENT_STARTUP_SCRIPT_PATH=/src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/kmeans-gsas.py uvicorn bluesky_adaptive.server:app" + command: uvicorn bluesky_adaptive.server:app --host 0.0.0.0 + environment: + - TILED_API_KEY=$TILED_API_KEY + - BS_AGENT_STARTUP_SCRIPT_PATH=/src/pdf-agents/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py volumes: - type: bind source: ../pdf_agents target: /src/pdf-agents/pdf_agents read_only: true + - type: bind + source: /etc/bluesky/kafka.yml + target: /etc/bluesky/kafka.yml + read_only: true depends_on: gsas: condition: service_started diff --git a/containers/nginx/html/index.html b/containers/nginx/html/index.html index 97a00fc..e1e6561 100644 --- a/containers/nginx/html/index.html +++ b/containers/nginx/html/index.html @@ -57,16 +57,26 @@
-

Welcome!

-

This is the default landing page for our service. Please check back soon for updates.

+

Landing Page for Agent Services!

+

This is the default landing page for the agent services.

-

Our Services

+

Available Agents

+ +

Available Agent User Interfaces

+ diff --git a/pdf_agents/agents.py b/pdf_agents/agents.py index 3727d00..4be6b35 100644 --- a/pdf_agents/agents.py +++ b/pdf_agents/agents.py @@ -370,13 +370,12 @@ def generate_report(self, **kwargs): self.close_and_restart(clear_tell_cache=False, retell_all=False, reason="Per-Run Subscribers") @classmethod - def get_beamline_objects(cls) -> dict: - ret = super().get_beamline_objects() + def get_default_producer(cls) -> Publisher: beamline_tla = "pdf" kafka_config = nslsii.kafka_utils._read_bluesky_kafka_config_file( config_file_path="/etc/bluesky/kafka.yml" ) - ret["report_producer"] = Publisher( + ret = Publisher( topic=f"{beamline_tla}.mmm.bluesky.agents", bootstrap_servers=",".join(kafka_config["bootstrap_servers"]), key="{beamline_tla}.key", diff --git a/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py b/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py index dc1f910..9c7a683 100644 --- a/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py +++ b/pdf_agents/startup_scripts/mmm5-tax-day/gsas.py @@ -20,11 +20,16 @@ } } +report_producer = RefinementAgent.get_default_producer() + + agent = RefinementAgent( # GSAS Args cif_paths=["/src/pdf-agents/assets/fcc.cif"], refinement_params=[param_dict_phase1], inst_param_path="/src/pdf-agents/assets/LaB6_IPF.instprm", + # Required report producer + report_producer=report_producer, # BS Adaptive Args ask_on_tell=False, report_on_tell=True,