Skip to content

Commit 35f1c78

Browse files
feat: integrate environment substitution, add port polling utility, update Cloud Build symlinks,
1 parent 5a6d865 commit 35f1c78

4 files changed

Lines changed: 50 additions & 20 deletions

File tree

cloudbuild.yaml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ steps:
2626
- '-c'
2727
- |
2828
set -e
29+
# Workaround for evalbench bug: settings are only applied if path basename matches extension ID
30+
ln -s /workspace /workspace/cloud-sql-postgresql
2931
cd /evalbench
3032
3133
export EVAL_GCP_PROJECT_ID=$PROJECT_ID
3234
export EVAL_GCP_PROJECT_REGION=us-central1
3335
# Maps the decrypted DB_PASSWORD to the exact variable expected by gemini_cli and extension skills
3436
export CLOUD_SQL_POSTGRES_PASSWORD=$$DB_PASSWORD
37+
38+
# Substitute environment variables in model_config.yaml
39+
python3 /workspace/evals/substitute_env.py
40+
3541
export EVALBENCH_INSECURE=True
3642
export EVALBENCH_HOST=0.0.0.0
3743
cd evalbench
@@ -42,28 +48,14 @@ steps:
4248
4349
echo "Starting Evaluation Server in background..."
4450
python3 -u ./eval_server.py --localhost </dev/null 2>&1 | tee server.log &
45-
51+
4652
echo "Waiting for port 50051 to open..."
47-
python3 -c "
48-
import socket
49-
import time
50-
for i in range(20):
51-
try:
52-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
53-
s.connect(('127.0.0.1', 50051))
54-
print('Port is open!')
55-
exit(0)
56-
except Exception as e:
57-
print(f'Port not open yet: {e}')
58-
time.sleep(1)
59-
print('Port failed to open')
60-
exit(1)
61-
" || { echo "Server failed to bind port. Check logs above."; exit 1; }
62-
53+
python3 /workspace/evals/wait_for_port.py || { echo "Server failed to bind port."; exit 1; }
54+
6355
echo "Server is running. Launching Evaluation Client..."
6456
cd /evalbench
6557
export PYTHONPATH=./evalbench:./evalbench/evalproto
66-
58+
6759
python3 evalbench/client/eval_client.py --experiment=/workspace/evals/run_config.yaml --endpoint=local || { echo "Client failed! Server logs:"; cat /evalbench/evalbench/server.log; exit 1; }
6860
6961
availableSecrets:

evals/model_config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ env:
2020
GOOGLE_GENAI_USE_VERTEXAI: "true"
2121
setup:
2222
extensions:
23-
"/workspace":
23+
# Points to the symlink created in cloudbuild.yaml to match the extension ID
24+
"/workspace/cloud-sql-postgresql":
2425
settings:
2526
CLOUD_SQL_POSTGRES_PROJECT: "ext-test-cloud-sql-postgres"
2627
CLOUD_SQL_POSTGRES_INSTANCE: "daily-ci-evals-db"
2728
CLOUD_SQL_POSTGRES_REGION: "us-central1"
2829
CLOUD_SQL_POSTGRES_DATABASE: "postgres"
2930
CLOUD_SQL_POSTGRES_USER: "postgres"
30-
CLOUD_SQL_POSTGRES_PASSWORD: ${CLOUD_SQL_POSTGRES_PASSWORD}
31+
CLOUD_SQL_POSTGRES_PASSWORD: '${CLOUD_SQL_POSTGRES_PASSWORD}'
3132
CLOUD_SQL_POSTGRES_IP_TYPE: "PUBLIC"

evals/substitute_env.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import re
3+
4+
def main():
5+
yaml_path = '/workspace/evals/model_config.yaml'
6+
if os.path.exists(yaml_path):
7+
with open(yaml_path, 'r') as f:
8+
content = f.read()
9+
content = re.sub(r'\${(\w+)}', lambda m: os.environ.get(m.group(1), m.group(0)), content)
10+
with open(yaml_path, 'w') as f:
11+
f.write(content)
12+
print(f"Successfully substituted environment variables in {yaml_path}")
13+
else:
14+
print(f"File not found: {yaml_path}")
15+
16+
if __name__ == '__main__':
17+
main()

evals/wait_for_port.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import socket
2+
import time
3+
import sys
4+
5+
def main():
6+
for i in range(20):
7+
try:
8+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
9+
s.settimeout(1)
10+
s.connect(('127.0.0.1', 50051))
11+
print('Port 50051 is open!')
12+
sys.exit(0)
13+
except Exception:
14+
print('Port not open yet, retrying...')
15+
time.sleep(1)
16+
print('Port failed to open')
17+
sys.exit(1)
18+
19+
if __name__ == '__main__':
20+
main()

0 commit comments

Comments
 (0)