Skip to content

Commit 259e859

Browse files
Make eval task worker/orchestrator use the same image, build in github action (#1626)
- Rename (confusing) build-docker-img and Dockerfile.local to policy-evaluator-specific names - Add github action for pushing new image - Update policy evaluator helm charts to only one use image type - Remove kubectl install from app_backend image since we are not using it anymore for orchestrator [Asana Task](https://app.asana.com/1/1209016784099267/project/1210348820405981/task/1210872207013045)
1 parent 36fcf39 commit 259e859

13 files changed

Lines changed: 83 additions & 40 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Build Policy Evaluator Docker Image"
2+
concurrency:
3+
group: ${{ github.workflow }}
4+
cancel-in-progress: true
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- "app_backend/**"
12+
- ".github/workflows/**"
13+
workflow_dispatch: {}
14+
15+
env:
16+
IMAGE_NAME: metta-policy-evaluator
17+
18+
jobs:
19+
build-and-push-image:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
id-token: write
23+
contents: read
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Configure AWS credentials
30+
uses: aws-actions/configure-aws-credentials@v4
31+
with:
32+
role-to-assume: ${{ vars.AWS_ROLE }}
33+
aws-region: us-east-1
34+
35+
- name: Login to Amazon ECR
36+
id: login-ecr
37+
uses: aws-actions/amazon-ecr-login@v2
38+
39+
- name: Extract metadata (tags, labels) for Docker
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=sha
46+
type=sha,format=long
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Build and push Docker image
53+
id: push
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
file: ./devops/docker/Dockerfile.policy_evaluator
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}

app_backend/Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Use Python 3.11 slim image as base
22
FROM python:3.11-slim
33

4-
# Install system dependencies and add Kubernetes apt repository
4+
# Install system dependencies
55
RUN apt-get update && apt-get install -y \
66
curl \
77
git \
8-
apt-transport-https \
9-
ca-certificates \
10-
gnupg \
11-
&& curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg \
12-
&& echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' > /etc/apt/sources.list.d/kubernetes.list \
13-
&& apt-get update \
14-
&& apt-get install -y kubectl \
158
&& rm -rf /var/lib/apt/lists/*
169

1710
# Install uv

app_backend/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Ensure that you have app_backend running. If it is running anywhere except for y
6060
#### Local docker
6161

6262
Getting the service running
63-
- `metta local build-docker-img` to build the `metta-local:latest` image. This will serve as the base for both the orchestrator and the workers
63+
- `metta local build-policy-evaluator-img` to build the `metta-policy-evaluator-local:latest` image. This will serve as the base for both the orchestrator and the workers
6464
- `WANDB_API_KEY=your-key-here docker compose -f app_backend/src/metta/app_backend/docker-compose.yml up`
6565

6666
Viewing logs
@@ -74,7 +74,7 @@ Kind is a tool for running local Kubernetes clusters using Docker container node
7474
- Ensure `metta status` shows that you are connected to `observatory-local-key` and `wandb`
7575
- Run your local app_backend server, which should be serving on `localhost:8000`
7676
- Run your local frontend from `observatory/`
77-
- Build orchestrator and worker images: `metta local build-docker-img`
77+
- Build orchestrator and worker images: `metta local build-policy-evaluator-img`
7878
- Set up helm: `metta local kind build`
7979
- Launch: `metta local kind up`
8080
- Monitor: `metta local kind get-pods` and `metta local kind pods {pod-name}`
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
services:
22
orchestrator:
3-
image: metta-local:latest # metta local build-app-backend-img
3+
image: metta-policy-evaluator-local:latest # metta local build-policy-evaluator-img
44
environment:
55
- BACKEND_URL=${BACKEND_URL:-http://host.docker.internal:8000}
66
- POLL_INTERVAL=${POLL_INTERVAL:-20}
77
- CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}
88
- WANDB_API_KEY=${WANDB_API_KEY}
9-
- DOCKER_IMAGE=${DOCKER_IMAGE:-metta-local:latest}
9+
- DOCKER_IMAGE=${DOCKER_IMAGE:-metta-policy-evaluator-local:latest}
1010
volumes:
1111
- ../../../:/workspace/metta/app_backend
1212
- /var/run/docker.sock:/var/run/docker.sock
13-
command: ["uv", "run", "python", "-m", "metta.app_backend.eval_task_orchestrator"]
13+
command: [ "uv", "run", "python", "-m", "metta.app_backend.eval_task_orchestrator" ]
1414
restart: unless-stopped
1515
# Run as root to access Docker socket - in production, use a proper docker group
1616
user: root

app_backend/src/metta/app_backend/eval_task_orchestrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(
3434
self,
3535
backend_url: str,
3636
machine_token: str,
37-
docker_image: str = "metta-local:latest",
37+
docker_image: str = "metta-policy-evaluator-local:latest",
3838
poll_interval: float = 5.0,
3939
worker_idle_timeout: float = 600.0,
4040
container_manager: AbstractContainerManager | None = None,
@@ -179,7 +179,7 @@ async def main() -> None:
179179
logger = logging.getLogger(__name__)
180180

181181
backend_url = os.environ.get("BACKEND_URL", "http://localhost:8000")
182-
docker_image = os.environ.get("DOCKER_IMAGE", "metta-local:latest")
182+
docker_image = os.environ.get("DOCKER_IMAGE", "metta-policy-evaluator-local:latest")
183183
poll_interval = float(os.environ.get("POLL_INTERVAL", "5"))
184184
worker_idle_timeout = float(os.environ.get("WORKER_IDLE_TIMEOUT", "600"))
185185
machine_token = os.environ["MACHINE_TOKEN"]

app_backend/tests/test_docker_integration.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,6 @@ def test_protected_endpoint_with_auth(self, app_backend_container):
231231
# but not fail due to authentication (401)
232232
assert response.status_code != 401
233233

234-
def test_kubectl_available(self, app_backend_container):
235-
"""Test that kubectl is available in the container."""
236-
container, _, __ = app_backend_container
237-
exit_code, output = container.exec("kubectl version --client")
238-
assert exit_code == 0, f"kubectl command failed with exit code {exit_code}. Output: {output}"
239-
240234

241235
if __name__ == "__main__":
242236
# Simple test runner for debugging

devops/charts/orchestrator/environments/kind.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
image:
2-
repository: metta-local
3-
tag: "latest"
4-
pullPolicy: Never
5-
6-
workerImage:
7-
repository: metta-local
2+
repository: metta-policy-evaluator-local
83
tag: "latest"
94
pullPolicy: Never
105

devops/charts/orchestrator/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
- name: WORKER_IDLE_TIMEOUT
3131
value: {{ .Values.env.WORKER_IDLE_TIMEOUT | quote }}
3232
- name: DOCKER_IMAGE
33-
value: "{{ .Values.workerImage.repository }}:{{ .Values.workerImage.tag }}"
33+
value: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
3434
- name: KUBERNETES_NAMESPACE
3535
valueFrom:
3636
fieldRef:

devops/charts/orchestrator/values.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@ replicaCount: 1
22

33
image:
44
registry: 751442549699.dkr.ecr.us-east-1.amazonaws.com
5-
name: metta-app-backend
5+
name: metta-policy-evaluator
66
tag: "" # set by ci/cd
77

88
serviceAccount:
99
create: true
1010

11-
workerImage:
12-
repository: 751442549699.dkr.ecr.us-east-1.amazonaws.com
13-
name: metta
14-
tag: "latest"
15-
1611
env:
1712
BACKEND_URL: "https://api.observatory.softmax-research.net"
1813
CONTAINER_RUNTIME: "k8s"

0 commit comments

Comments
 (0)