-
Notifications
You must be signed in to change notification settings - Fork 20
Update .cnb.yml to fetch en-zh model URLs from new models.json API #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,21 +6,47 @@ main: | |||||||||||||||||
| stages: | ||||||||||||||||||
| - name: download models | ||||||||||||||||||
| script: | | ||||||||||||||||||
| set -e | ||||||||||||||||||
| mkdir -p models-enzh/enzh | ||||||||||||||||||
| base_url="https://github.com/mozilla/firefox-translations-models/raw/refs/heads/main/models/base/enzh" | ||||||||||||||||||
| models_json_url="https://storage.googleapis.com/moz-fx-translations-data--303e-prod-translations-data/db/models.json" | ||||||||||||||||||
| echo "Fetching models.json from $models_json_url" | ||||||||||||||||||
| curl -fsSL "$models_json_url" -o models.json || { echo "Failed to download models.json"; exit 1; } | ||||||||||||||||||
| base_url=$(jq -r '.baseUrl' models.json) | ||||||||||||||||||
| if [ -z "$base_url" ] || [ "$base_url" = "null" ]; then | ||||||||||||||||||
| echo "Failed to extract baseUrl from models.json" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
| echo "Base URL: $base_url" | ||||||||||||||||||
| # Get the first en-zh model (architecture: base) | ||||||||||||||||||
| model_data=$(jq -r '.models."en-zh"[0]' models.json) | ||||||||||||||||||
| if [ -z "$model_data" ] || [ "$model_data" = "null" ]; then | ||||||||||||||||||
| echo "No en-zh model found in models.json" | ||||||||||||||||||
|
Comment on lines
+20
to
+23
|
||||||||||||||||||
| # Get the first en-zh model (architecture: base) | |
| model_data=$(jq -r '.models."en-zh"[0]' models.json) | |
| if [ -z "$model_data" ] || [ "$model_data" = "null" ]; then | |
| echo "No en-zh model found in models.json" | |
| # Select the en-zh model with architecture "base" and releaseStatus "released" | |
| model_data=$(jq -r '.models["en-zh"] | map(select(.architecture == "base" and .releaseStatus == "released")) | .[0]' models.json) | |
| if [ -z "$model_data" ] || [ "$model_data" = "null" ]; then | |
| echo "No matching en-zh model (architecture=base, releaseStatus=released) found in models.json" |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "$model_data" | jq ... can be unsafe because echo behavior is shell-dependent (it may interpret backslashes or -n/-e sequences), which can corrupt JSON before it reaches jq. Prefer extracting fields directly with jq from models.json (or use printf '%s' "$model_data").
| lex_path=$(echo "$model_data" | jq -r '.files.lexicalShortlist.path') | |
| model_path=$(echo "$model_data" | jq -r '.files.model.path') | |
| src_vocab_path=$(echo "$model_data" | jq -r '.files.srcVocab.path') | |
| trg_vocab_path=$(echo "$model_data" | jq -r '.files.trgVocab.path') | |
| lex_path=$(printf '%s' "$model_data" | jq -r '.files.lexicalShortlist.path') | |
| model_path=$(printf '%s' "$model_data" | jq -r '.files.model.path') | |
| src_vocab_path=$(printf '%s' "$model_data" | jq -r '.files.srcVocab.path') | |
| trg_vocab_path=$(printf '%s' "$model_data" | jq -r '.files.trgVocab.path') |
Uh oh!
There was an error while loading. Please reload this page.