Download code/gke/settings.py from EdwardoSunny/agent-cwm-rubrics-debug: direct link, hf CLI and curl.
- Browser
- Download file 3.12 kB
-
https://huggingface.co/datasets/EdwardoSunny/agent-cwm-rubrics-debug/resolve/main/code/gke/settings.py
- Command line
-
hf download hf://datasets/EdwardoSunny/agent-cwm-rubrics-debug/code/gke/settings.py
-
curl -L -o settings.py https://huggingface.co/datasets/EdwardoSunny/agent-cwm-rubrics-debug/resolve/main/code/gke/settings.py
3.12 kB
| """Central constants + GCP client helpers for the agent-cwm GKE eval fleet. | |
| Everything here is deliberately DISJOINT from the probe-factory/qd-bloom | |
| deployment in this project: different region (us-east1 vs us-central1, so the | |
| two never contend for regional CPU/GPU quota), different cluster, different | |
| bucket, and a dedicated service account whose only grant is objectAdmin on our | |
| own bucket. Do not point any of these names at probe-factory resources. | |
| """ | |
| from __future__ import annotations | |
| import base64 | |
| import tempfile | |
| PROJECT = "edward-sun" | |
| REGION = "us-east1" # probe-factory lives in us-central1 — kept apart on purpose | |
| CLUSTER = "agent-cwm-evals" | |
| NAMESPACE = "agent-cwm" | |
| KSA = "eval-worker" # k8s service account, Workload-Identity-bound to the GSA | |
| GSA_NAME = "agent-cwm-evals" | |
| GSA = f"{GSA_NAME}@{PROJECT}.iam.gserviceaccount.com" | |
| BUCKET = "edward-sun-agent-cwm-evals" | |
| AR_REPO = "agent-cwm" | |
| IMAGE = f"{REGION}-docker.pkg.dev/{PROJECT}/{AR_REPO}/worker:latest" | |
| # Same pin as rubric_gen/SETUP_NEW_POD.sh (with LFS leaderboards for grading). | |
| MLEBENCH_PIN = "507f92e1138bb6e40dac5c6ee7a6758e6424bf97" | |
| # GCS layout (all under gs://BUCKET/): | |
| # data/<comp>/prepared.tar.gz + meta.json one tarball per prepared competition | |
| # code/<run>.tar.gz working-tree snapshot per run | |
| # runs/<run>/manifest.json shard grid for the Indexed Job | |
| # runs/<run>/shards/<idx>.jsonl result rows (append/overwrite per shard) | |
| # runs/<run>/shards/<idx>.gymlog.jsonl gym event logs | |
| # runs/<run>/logs/<idx>.log worker stdout/stderr | |
| def adc(): | |
| import google.auth | |
| creds, _ = google.auth.default( | |
| scopes=["https://www.googleapis.com/auth/cloud-platform"] | |
| ) | |
| return creds.with_quota_project(PROJECT) | |
| def authed_session(): | |
| from google.auth.transport.requests import AuthorizedSession | |
| return AuthorizedSession(adc()) | |
| def storage_client(): | |
| from google.cloud import storage | |
| return storage.Client(project=PROJECT, credentials=adc()) | |
| def container_client(): | |
| from google.cloud import container_v1 | |
| return container_v1.ClusterManagerClient(credentials=adc()) | |
| def kube_api(): | |
| """Kubernetes clients for CLUSTER via ADC bearer token (no kubectl needed). | |
| The token lives ~1h; long watch loops should call this again rather than | |
| holding one client forever. | |
| """ | |
| import kubernetes.client as k8s | |
| from google.auth.transport.requests import Request | |
| creds = adc() | |
| creds.refresh(Request()) | |
| cl = container_client().get_cluster( | |
| name=f"projects/{PROJECT}/locations/{REGION}/clusters/{CLUSTER}" | |
| ) | |
| ca = tempfile.NamedTemporaryFile(delete=False, suffix=".crt") | |
| ca.write(base64.b64decode(cl.master_auth.cluster_ca_certificate)) | |
| ca.flush() | |
| conf = k8s.Configuration() | |
| conf.host = f"https://{cl.endpoint}" | |
| conf.ssl_ca_cert = ca.name | |
| conf.api_key = {"authorization": "Bearer " + creds.token} | |
| client = k8s.ApiClient(conf) | |
| return k8s.CoreV1Api(client), k8s.BatchV1Api(client) | |
| def bucket(): | |
| return storage_client().bucket(BUCKET) | |