labs/aicharts: live at aicharts.<venture domain>, like ventures (#36)

The account has no workers.dev subdomain; use TIME_VENTURE_DOMAIN when set.
Deploy step fails on its own error (pipefail); smoke waits up to 3 min for the cert.


Claude-Session: https://claude.ai/code/session_01VDkN7ukK1kXkqov8FaZxva

Co-authored-by: Claude <noreply@anthropic.com>
This commit was merged in pull request #36.
This commit is contained in:
teahubxyzandClaude authored and GitHub committed 2026-10-13 13:42:56 +00:00
1 parent ba4174326a
commit 8eff78170b
2 files changed
+10 -6

No files matched your search

+6 -4
View File
@@ -1,9 +1,10 @@
"""Deploy the AICharts demo: one Worker (`time-aicharts`), one D1 database, Workers AI, on workers.dev only.
"""Deploy the AICharts demo: one Worker (`time-aicharts`), one D1 database, Workers AI.
python3 .github/time/labs/aicharts/deploy.py # prints {url, worker, db, rev}
Reuses cloudflare.py (token, account, database, workers.dev). No DNS and no custom domain. Idempotent: the same
database is reused and the script is replaced in place.
Reuses cloudflare.py. Lives where ventures live: aicharts.<TIME_VENTURE_DOMAIN> when that is set (a Workers custom
domain; Cloudflare adds the record and the cert), the account's workers.dev otherwise. Idempotent: the same database is
reused and the script is replaced in place.
"""
from __future__ import annotations
@@ -41,7 +42,8 @@ def deploy() -> dict:
+ [{"type": "plain_text", "name": k, "text": str(v)} for k, v in vars_.items()]}
data, ctype = cf.multipart([("metadata", "application/json", json.dumps(meta).encode()), *code])
cf.cf("PUT", f"{cf.account()}/workers/scripts/{NAME}", data=data, ctype=ctype)
return {"url": cf.workers_dev(NAME), "worker": NAME, "db": db, "rev": rev}
hostname = cf.host("aicharts")
return {"url": cf.attach(NAME, hostname) if hostname else cf.workers_dev(NAME), "worker": NAME, "db": db, "rev": rev}
if __name__ == "__main__":
+4 -2
View File
@@ -1,5 +1,5 @@
name: labs-aicharts
# Deploy the AICharts demo Worker (workers.dev, one D1, Workers AI), then smoke-test it. Manual only.
# Deploy the AICharts demo Worker (aicharts.<venture domain>, one D1, Workers AI), then smoke-test it. Manual only.
on: workflow_dispatch
permissions:
contents: read
@@ -17,15 +17,17 @@ jobs:
- run: node .github/time/labs/aicharts/test_aicharts.mjs
- id: deploy
run: |
set -o pipefail
python3 .github/time/labs/aicharts/deploy.py | tee out.json
echo "url=$(python3 -c 'import json; print(json.load(open("out.json"))["url"])')" >> "$GITHUB_OUTPUT"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
TIME_VENTURE_DOMAIN: ${{ vars.TIME_VENTURE_DOMAIN }}
- name: smoke
run: |
u="${{ steps.deploy.outputs.url }}"
for i in 1 2 3 4 5 6; do curl -fsS "${u}api/health" && break; sleep 10; done
for i in $(seq 1 18); do curl -fsS "${u}api/health" && break; sleep 10; done
curl -fsS "${u}api/schema?dataset=orders" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert len(d["sample"])==5, d; print("schema ok")'
curl -fsS -X POST "${u}api/spec" -H 'content-type: application/json' \
-d '{"dataset":"orders","prompt":"total revenue by region"}' | tee spec.json