-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathrun-demo.sh
More file actions
141 lines (131 loc) Β· 3.44 KB
/
run-demo.sh
File metadata and controls
141 lines (131 loc) Β· 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# Agent OS Demo Runner
# Usage: ./run-demo.sh <demo-name> [options]
set -e
DEMO_NAME="${1:-carbon-auditor}"
shift || true
DEMOS="carbon-auditor grid-balancing defi-sentinel pharma-compliance"
usage() {
echo "Agent OS Demo Runner"
echo ""
echo "Usage: ./run-demo.sh <demo-name> [options]"
echo ""
echo "Available demos:"
echo " carbon-auditor - Carbon credit fraud detection"
echo " grid-balancing - Energy trading swarm"
echo " defi-sentinel - DeFi attack response"
echo " pharma-compliance - Document contradiction finder"
echo ""
echo "Options:"
echo " --docker Run with Docker (default)"
echo " --local Run locally with Python"
echo " --k8s Deploy to Kubernetes"
echo ""
echo "Examples:"
echo " ./run-demo.sh carbon-auditor"
echo " ./run-demo.sh grid-balancing --local"
echo " ./run-demo.sh defi-sentinel --k8s"
}
if [[ "$DEMO_NAME" == "-h" || "$DEMO_NAME" == "--help" ]]; then
usage
exit 0
fi
# Check if demo exists
if [[ ! -d "examples/$DEMO_NAME" ]]; then
echo "Error: Demo '$DEMO_NAME' not found"
echo "Available demos: $DEMOS"
exit 1
fi
cd "examples/$DEMO_NAME"
# Parse mode
MODE="docker"
for arg in "$@"; do
case $arg in
--docker) MODE="docker" ;;
--local) MODE="local" ;;
--k8s) MODE="k8s" ;;
esac
done
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β Agent OS Demo: $DEMO_NAME"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
case $MODE in
docker)
echo "π³ Running with Docker..."
docker-compose up --build
;;
local)
echo "π Running locally..."
pip install -e . -q
python demo.py "$@"
;;
k8s)
echo "βΈοΈ Deploying to Kubernetes..."
if [[ -d "k8s" ]]; then
kubectl apply -f k8s/
else
echo "Creating k8s manifests..."
mkdir -p k8s
cat > k8s/deployment.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-os-$DEMO_NAME
labels:
app: agent-os
demo: $DEMO_NAME
spec:
replicas: 1
selector:
matchLabels:
app: agent-os
demo: $DEMO_NAME
template:
metadata:
labels:
app: agent-os
demo: $DEMO_NAME
spec:
containers:
- name: demo
image: agent-os/$DEMO_NAME:latest
ports:
- containerPort: 8080
name: http
- containerPort: 9090
name: metrics
env:
- name: AGENT_OS_METRICS_PORT
value: "9090"
resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "500m"
memory: "512Mi"
---
apiVersion: v1
kind: Service
metadata:
name: agent-os-$DEMO_NAME
spec:
selector:
app: agent-os
demo: $DEMO_NAME
ports:
- name: http
port: 8080
targetPort: 8080
- name: metrics
port: 9090
targetPort: 9090
EOF
kubectl apply -f k8s/
fi
echo ""
echo "Deployment created. Access metrics at:"
echo " kubectl port-forward svc/agent-os-$DEMO_NAME 9090:9090"
;;
esac