Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
77f34ca
build(deps): Bump github/codeql-action from 3.30.6 to 4.30.8 (#299)
dependabot[bot] Oct 16, 2025
e945ee4
build(deps): Bump github/codeql-action from 3.30.6 to 4.30.8 (#299)
dependabot[bot] Oct 16, 2025
be02357
build(deps): Bump d7y.io/api/v2 from 2.1.71 to 2.1.72 (#300)
dependabot[bot] Oct 16, 2025
f7750c8
build(deps): Bump d7y.io/api/v2 from 2.1.71 to 2.1.72 (#300)
dependabot[bot] Oct 16, 2025
efcc788
build(deps): Bump golang.org/x/crypto from 0.42.0 to 0.43.0 (#301)
dependabot[bot] Oct 16, 2025
bb327cf
build(deps): Bump golang.org/x/crypto from 0.42.0 to 0.43.0 (#301)
dependabot[bot] Oct 16, 2025
041150d
build(deps): Bump golang.org/x/sys from 0.36.0 to 0.37.0 (#303)
dependabot[bot] Oct 16, 2025
bd3c8d4
build(deps): Bump golang.org/x/sys from 0.36.0 to 0.37.0 (#303)
dependabot[bot] Oct 16, 2025
b57b1c6
build(deps): Bump github/codeql-action from 4.30.8 to 4.30.9 (#306)
dependabot[bot] Oct 21, 2025
5e0b522
build(deps): Bump github/codeql-action from 4.30.8 to 4.30.9 (#306)
dependabot[bot] Oct 21, 2025
fc9aa78
build(deps): Bump d7y.io/api/v2 from 2.1.72 to 2.1.80 (#305)
dependabot[bot] Oct 21, 2025
c58e9d6
build(deps): Bump d7y.io/api/v2 from 2.1.72 to 2.1.80 (#305)
dependabot[bot] Oct 21, 2025
ecc0d3c
build(deps): Bump github.com/avast/retry-go/v4 from 4.6.1 to 4.7.0 (#…
dependabot[bot] Oct 21, 2025
c73bcf7
build(deps): Bump github.com/avast/retry-go/v4 from 4.6.1 to 4.7.0 (#…
dependabot[bot] Oct 21, 2025
31f3bf6
build(deps): Bump actions/download-artifact from 5 to 6 (#313)
dependabot[bot] Oct 28, 2025
df25c8c
build(deps): Bump actions/download-artifact from 5 to 6 (#313)
dependabot[bot] Oct 28, 2025
cfe2e9a
build(deps): Bump github/codeql-action from 4.30.9 to 4.31.0 (#312)
dependabot[bot] Oct 28, 2025
e3c156f
build(deps): Bump github/codeql-action from 4.30.9 to 4.31.0 (#312)
dependabot[bot] Oct 28, 2025
2032a6d
build(deps): Bump d7y.io/api/v2 from 2.1.80 to 2.1.81 (#311)
dependabot[bot] Oct 28, 2025
cbeea43
build(deps): Bump d7y.io/api/v2 from 2.1.80 to 2.1.81 (#311)
dependabot[bot] Oct 28, 2025
fc2566e
build(deps): Bump actions/upload-artifact from 4 to 5 (#310)
dependabot[bot] Oct 28, 2025
ebe0197
build(deps): Bump actions/upload-artifact from 4 to 5 (#310)
dependabot[bot] Oct 28, 2025
43f4a57
fix(backend): correct auth key handling for token retrieval (#314)
chlins Oct 28, 2025
c1479b8
fix(backend): correct auth key handling for token retrieval (#314)
chlins Oct 28, 2025
3f67446
fix(backend): correct authorization header assembly (#315)
chlins Oct 28, 2025
0a21f6b
fix(backend): correct authorization header assembly (#315)
chlins Oct 28, 2025
96b4595
build(deps): Bump github/codeql-action from 4.31.0 to 4.31.2 (#320)
dependabot[bot] Nov 5, 2025
29dc3dc
build(deps): Bump github/codeql-action from 4.31.0 to 4.31.2 (#320)
dependabot[bot] Nov 5, 2025
55a7d50
docs(getting-started): update install command to use main branch (#318)
chlins Nov 5, 2025
8776dfc
docs(getting-started): update install command to use main branch (#318)
chlins Nov 5, 2025
a44093d
chore(deps): update dependencies to latest versions (#319)
chlins Nov 5, 2025
81618dd
chore(deps): update dependencies to latest versions (#319)
chlins Nov 5, 2025
d68aa0e
feat(remote): add custom headers to HTTP requests (#322)
chlins Nov 5, 2025
66a760e
feat(remote): add custom headers to HTTP requests (#322)
chlins Nov 5, 2025
85b5f1a
feat(cmd): set raw flag default to true for attach, build, upload (#323)
chlins Nov 10, 2025
ee698cb
feat(cmd): set raw flag default to true for attach, build, upload (#323)
chlins Nov 10, 2025
1d6da1f
build(deps): Bump golangci/golangci-lint-action from 8.0.0 to 9.0.0 (…
dependabot[bot] Nov 11, 2025
1ff7523
build(deps): Bump golangci/golangci-lint-action from 8.0.0 to 9.0.0 (…
dependabot[bot] Nov 11, 2025
f958fdc
build(deps): Bump golang.org/x/sync from 0.17.0 to 0.18.0 (#326)
dependabot[bot] Nov 11, 2025
5caf0f3
build(deps): Bump golang.org/x/sync from 0.17.0 to 0.18.0 (#326)
dependabot[bot] Nov 11, 2025
c67486b
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.10.2 to 8.11.2 …
dependabot[bot] Nov 11, 2025
031ed0e
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.10.2 to 8.11.2 …
dependabot[bot] Nov 11, 2025
7f1a23f
build(deps): Bump golang.org/x/sys from 0.37.0 to 0.38.0 (#324)
dependabot[bot] Nov 11, 2025
ba5311d
build(deps): Bump golang.org/x/sys from 0.37.0 to 0.38.0 (#324)
dependabot[bot] Nov 11, 2025
fb924e7
refactor(xattr): extract xattr operations to dedicated package (#331)
chlins Nov 19, 2025
9dddb05
refactor(xattr): extract xattr operations to dedicated package (#331)
chlins Nov 19, 2025
1cc5c0a
refactor(retry): update default retry options (#333)
chlins Nov 20, 2025
0bbbb76
refactor(retry): update default retry options (#333)
chlins Nov 20, 2025
eafb2f3
build(deps): Bump actions/checkout from 5 to 6 (#334)
dependabot[bot] Nov 24, 2025
31e8b94
build(deps): Bump actions/checkout from 5 to 6 (#334)
dependabot[bot] Nov 24, 2025
3bde365
build(deps): Bump github/codeql-action from 4.31.2 to 4.31.4 (#335)
dependabot[bot] Nov 24, 2025
84d4968
build(deps): Bump github/codeql-action from 4.31.2 to 4.31.4 (#335)
dependabot[bot] Nov 24, 2025
444d958
build(deps): Bump golangci/golangci-lint-action from 9.0.0 to 9.1.0 (…
dependabot[bot] Nov 24, 2025
1836744
build(deps): Bump golangci/golangci-lint-action from 9.0.0 to 9.1.0 (…
dependabot[bot] Nov 24, 2025
3ca6862
build(deps): Bump github.com/go-git/go-git/v5 from 5.16.3 to 5.16.4 (…
dependabot[bot] Nov 24, 2025
fd77a8b
build(deps): Bump github.com/go-git/go-git/v5 from 5.16.3 to 5.16.4 (…
dependabot[bot] Nov 24, 2025
4628cb5
build(deps): Bump d7y.io/api/v2 from 2.1.81 to 2.1.83 (#339)
dependabot[bot] Nov 24, 2025
715b906
build(deps): Bump d7y.io/api/v2 from 2.1.81 to 2.1.83 (#339)
dependabot[bot] Nov 24, 2025
e1d2c95
build(deps): Bump golang.org/x/crypto from 0.43.0 to 0.45.0 (#340)
dependabot[bot] Nov 24, 2025
909b7ad
build(deps): Bump golang.org/x/crypto from 0.43.0 to 0.45.0 (#340)
dependabot[bot] Nov 24, 2025
bd2dd97
feat: support modelfile generate with exclude patterns (#332)
qiumuyang Nov 25, 2025
6553087
feat: support modelfile generate with exclude patterns (#332)
qiumuyang Nov 25, 2025
d561edf
feat: support modelfile generate with exclude patterns (#332)
qiumuyang Nov 25, 2025
434949a
fix(processor): correct error handling and annotations logic (#341)
chlins Nov 26, 2025
6d4152e
fix(processor): correct error handling and annotations logic (#341)
chlins Nov 26, 2025
ef23746
fix(processor): correct error handling and annotations logic (#341)
chlins Nov 26, 2025
7c61b99
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] Dec 14, 2025
0b7e3d4
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] Dec 14, 2025
2b37d15
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] Dec 14, 2025
af38ca7
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] Dec 14, 2025
fadbb5d
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] Dec 14, 2025
d1e2b27
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] Dec 14, 2025
3304e7e
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] Dec 14, 2025
5a604e1
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] Dec 14, 2025
90d96cf
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] Dec 14, 2025
b4a2788
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] Dec 14, 2025
433d289
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] Dec 14, 2025
e0d07b6
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] Dec 14, 2025
2ae07f9
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] Dec 15, 2025
337bcad
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] Dec 15, 2025
62abaf5
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] Dec 15, 2025
1d47e59
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] Dec 15, 2025
c270258
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] Dec 15, 2025
32212b9
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] Dec 15, 2025
22ac875
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] Dec 15, 2025
84f32ff
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] Dec 15, 2025
12c5553
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] Dec 15, 2025
e3d6540
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] Dec 15, 2025
9d5a891
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] Dec 15, 2025
614e68a
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] Dec 15, 2025
4d23bb1
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] Dec 15, 2025
e700c1a
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] Dec 15, 2025
78b5889
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] Dec 15, 2025
a0d31ed
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] Dec 15, 2025
7b4f812
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] Dec 15, 2025
d250916
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] Dec 15, 2025
6432f86
add workflow and supporting script
avinashsingh77 Dec 15, 2025
af16098
add workflow and supporting script
avinashsingh77 Dec 15, 2025
c899050
add readme for scripts
avinashsingh77 Dec 15, 2025
ce4c90c
add readme for scripts
avinashsingh77 Dec 15, 2025
0fa1a2c
improve func performance
avinashsingh77 Dec 15, 2025
df4cedf
improve func performance
avinashsingh77 Dec 15, 2025
509ad7d
Add support for modelFile generate via model providers model_url (#329)
avinashsingh77 Dec 16, 2025
62edaef
Add workflow for bilding top models
avinashsingh77 Dec 17, 2025
8ac9452
Add workflow for bilding top models
avinashsingh77 Dec 17, 2025
d791c65
Merge pull request #1 from avinashsingh77/workflow_for_top_models
avinashsingh77 Dec 17, 2025
03bd0f9
Merge pull request #1 from avinashsingh77/workflow_for_top_models
avinashsingh77 Dec 17, 2025
92d6815
Chore: Pin GitHub Actions to commit SHAs with version comments (#360)
bupd Dec 17, 2025
da80a9d
cleanup models after push
avinashsingh77 Dec 18, 2025
0795360
cleanup models after push
avinashsingh77 Dec 18, 2025
f001c44
Merge branch 'main' of github.com:avinashsingh77/modctl
avinashsingh77 Dec 18, 2025
c64bee7
Merge branch 'main' of github.com:avinashsingh77/modctl
avinashsingh77 Dec 18, 2025
4896ddf
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] Dec 15, 2025
954a64e
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] Dec 15, 2025
89198b1
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] Dec 15, 2025
2fbe255
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] Dec 15, 2025
72bec3d
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] Dec 15, 2025
2e31c6b
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] Dec 15, 2025
13cfa04
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] Dec 15, 2025
96e80a4
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] Dec 15, 2025
f74b8a7
Add workflow for bilding top models
avinashsingh77 Dec 17, 2025
3fa954d
Add workflow for bilding top models
avinashsingh77 Dec 17, 2025
611ee4f
cleanup models after push
avinashsingh77 Dec 18, 2025
2eec53c
cleanup models after push
avinashsingh77 Dec 18, 2025
9c95bfc
feat(attach,upload): add destination-dir flag for custom file paths (…
chlins Dec 22, 2025
d1b3576
build(deps): Bump actions/setup-go from 6.0.0 to 6.1.0 (#369)
dependabot[bot] Dec 22, 2025
2f04881
build(deps): Bump actions/checkout from 6.0.0 to 6.0.1 (#367)
dependabot[bot] Dec 22, 2025
fac74bd
build(deps): Bump d7y.io/api/v2 from 2.1.94 to 2.2.1 (#366)
dependabot[bot] Dec 22, 2025
d0fbe57
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.11.2 to 8.11.3 …
dependabot[bot] Dec 22, 2025
cf5e4b6
build(deps): Bump github/codeql-action from 4.31.8 to 4.31.9 (#364)
dependabot[bot] Dec 22, 2025
4b16ee1
add workflow and supporting script
avinashsingh77 Dec 15, 2025
f6e8833
add workflow and supporting script
avinashsingh77 Dec 15, 2025
5c63df5
add readme for scripts
avinashsingh77 Dec 15, 2025
2d38d7e
add readme for scripts
avinashsingh77 Dec 15, 2025
cc7c864
improve func performance
avinashsingh77 Dec 15, 2025
c7b9b6e
improve func performance
avinashsingh77 Dec 15, 2025
cee6eac
Merge branch 'workflow_for_top_models' of github.com:avinashsingh77/m…
avinashsingh77 Dec 22, 2025
b9321bb
Merge branch 'workflow_for_top_models' of github.com:avinashsingh77/m…
avinashsingh77 Dec 22, 2025
c2a7eca
move scripts under contrib
avinashsingh77 Dec 22, 2025
45be889
move scripts under contrib
avinashsingh77 Dec 22, 2025
1989b58
remove modctl and modelfile
avinashsingh77 Dec 22, 2025
7b59e3a
remove modctl and modelfile
avinashsingh77 Dec 22, 2025
ef37971
Merge branch 'main' into workflow_for_top_models
avinashsingh77 Dec 22, 2025
779ea1c
resolving conflicts
avinashsingh77 Dec 22, 2025
8f8fa7b
Merge branch 'modelpack:main' into workflow_for_top_models
avinashsingh77 Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 267 additions & 0 deletions .github/workflows/build-top-models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
name: Build Top HuggingFace Models

on:
schedule:
# Run weekly on Sunday at 00:00 UTC
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
limit:
description: 'Number of models to build'
required: false
default: '10'
type: string
max_size:
description: 'Maximum model size in GB'
required: false
default: '10'
type: string
sort_by:
description: 'Sort criteria'
required: false
default: 'downloads'
type: choice
options:
- downloads
- likes
- trending

permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io
ORGANIZATION: ${{ github.repository_owner }}

jobs:
select-models:
name: Select Top Models
runs-on: ubuntu-latest
outputs:
models: ${{ steps.select-models.outputs.models }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"

- name: Install dependencies
run: |
pip install -r contrib/scripts/requirements.txt

- name: Select compatible models
id: select-models
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
python contrib/scripts/select_top_models.py \
--limit ${{ github.event.inputs.limit || '10' }} \
--max-size ${{ github.event.inputs.max_size || '10' }} \
--sort-by ${{ github.event.inputs.sort_by || 'downloads' }} \
--output models.json

# Convert to single line JSON for GitHub output
echo "models=$(cat models.json | jq -c)" >> $GITHUB_OUTPUT

# Also display selected models for debugging
echo "Selected models:"
cat models.json | jq -r '.[] | "\(.id) (\(.format), \(.size_gb)GB)"'

build-modctl:
name: Build modctl
runs-on: ubuntu-latest
env:
PACKAGE_DIR: modctl-build-package
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Create Cache Dir
run: |
mkdir -p ${{ env.PACKAGE_DIR }}

- name: Cache Package
id: cache-package
uses: actions/cache@v4
with:
path: ${{ env.PACKAGE_DIR }}
key: modctl-build-packages

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential \
cmake pkg-config libssl-dev libssh2-1-dev zlib1g-dev \
libhttp-parser-dev python3 wget tar git
mkdir -p ${{ env.PACKAGE_DIR }}
if [ ! -f "${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz" ]; then
wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.5.1.tar.gz -O ${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz
fi
tar -xzf ${{ env.PACKAGE_DIR }}/libgit2-v1.5.1.tar.gz
cd libgit2-1.5.1 && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
make -j$(nproc)
sudo make install
sudo ldconfig
env:
LIBGIT2_SYS_USE_PKG_CONFIG: "1"

- name: Build modctl
run: |
go build -tags "static system_libgit2 enable_libgit2"

- name: Upload modctl
uses: actions/upload-artifact@v4
with:
name: modctl-artifact
path: modctl

build-and-push-models:
name: Build ${{ matrix.model.id }}
needs: [select-models, build-modctl]
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
max-parallel: 3 # Don't overwhelm GHCR or HuggingFace
matrix:
model: ${{ fromJson(needs.select-models.outputs.models) }}
env:
MODEL_ID: ${{ matrix.model.id }}
MODEL_FAMILY: ${{ matrix.model.family }}
MODEL_FORMAT: ${{ matrix.model.format }}
MODEL_PARAM_SIZE: ${{ matrix.model.param_size }}
MODEL_DIR: model-files
steps:
- name: Download modctl artifact
uses: actions/download-artifact@v4
with:
name: modctl-artifact
path: modctl

- name: Setup modctl
run: |
sudo cp modctl/modctl /bin/modctl
sudo chmod +x /bin/modctl
modctl version
modctl login -u ${{ github.actor }} \
-p ${{ secrets.GITHUB_TOKEN }} \
${{ env.REGISTRY }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Cache model
uses: actions/cache@v4
id: cache-model
with:
path: ${{ env.MODEL_DIR }}
key: model-${{ env.MODEL_ID }}-${{ hashFiles('**/config.json') }}

- name: Download HuggingFace Model
if: steps.cache-model.outputs.cache-hit != 'true'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
pip install 'huggingface_hub'
python << 'EOF'
from huggingface_hub import snapshot_download
import os

model_id = os.environ['MODEL_ID']
model_dir = os.environ['MODEL_DIR']

print(f"Downloading {model_id}...")
snapshot_download(
repo_id=model_id,
local_dir=model_dir,
token=os.environ.get('HF_TOKEN')
)
print(f"Download complete: {model_dir}")
EOF

- name: Generate Modelfile
run: |
cd ${{ env.MODEL_DIR }}
echo "Generating Modelfile for ${{ env.MODEL_ID }}"
modctl modelfile generate \
--arch transformer \
--family ${{ env.MODEL_FAMILY }} \
--format ${{ env.MODEL_FORMAT }} \
--param-size ${{ env.MODEL_PARAM_SIZE }} \
.

echo "Generated Modelfile:"
cat Modelfile

- name: Build and Push Model
run: |
cd ${{ env.MODEL_DIR }}

# Convert model ID to valid image name (lowercase, replace / with -)
IMAGE_NAME=$(echo "${{ env.MODEL_ID }}" | tr '[:upper:]' '[:lower:]' | tr '/' '-')
IMAGE_URL="${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${IMAGE_NAME}:latest"

echo "Building and pushing to ${IMAGE_URL}"

modctl build -f Modelfile \
-t ${IMAGE_URL} \
--raw --output-remote --log-level debug \
.

echo "✅ Successfully pushed ${IMAGE_URL}"

- name: Cleanup HuggingFace Model Files
run: |
echo "Cleaning up HuggingFace model files to free disk space..."
du -sh ${{ env.MODEL_DIR }} || true
rm -rf ${{ env.MODEL_DIR }}
echo "✅ Cleanup complete"
df -h

- name: Verify Pull
run: |
# Convert model ID to valid image name
IMAGE_NAME=$(echo "${{ env.MODEL_ID }}" | tr '[:upper:]' '[:lower:]' | tr '/' '-')
IMAGE_URL="${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${IMAGE_NAME}:latest"

mkdir -p verify-download
echo "Pulling ${IMAGE_URL} to verify"

modctl pull ${IMAGE_URL} \
--extract-dir verify-download \
--log-level debug

echo "✅ Successfully verified pull from ${IMAGE_URL}"

summary:
name: Build Summary
needs: [select-models, build-and-push-models]
runs-on: ubuntu-latest
if: always()
steps:
- name: Generate Summary
run: |
echo "# Build Top Models Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Selected Models" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '${{ needs.select-models.outputs.models }}' | jq -r '.[] | "- **\(.id)** (\(.format), \(.param_size), \(.size_gb)GB) - \(.downloads) downloads"' >> $GITHUB_STEP_SUMMARY || true
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Build Status" >> $GITHUB_STEP_SUMMARY
echo "Check individual job results above." >> $GITHUB_STEP_SUMMARY
131 changes: 131 additions & 0 deletions contrib/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Model Selection Scripts

This directory contains scripts for selecting and filtering HuggingFace models compatible with modctl.

## select_top_models.py

Python script that fetches top models from HuggingFace Hub and filters them based on modctl compatibility criteria.

### Compatibility Criteria

The script filters models based on:

1. **Has config.json** - Required for auto-detection of model metadata
2. **Supported formats** - Must have files in formats like:
- `safetensors` (preferred)
- `gguf`
- `bin` (PyTorch)
- `pt`, `pth` (PyTorch)
- `onnx`
3. **Size limit** - Configurable maximum size (default: 20GB)
4. **Metadata** - Attempts to extract:
- Model family (llama, qwen, gpt2, etc.)
- Parameter size (0.5B, 7B, etc.)
- Format type

### Installation

```bash
pip install -r requirements.txt
```

### Usage

Basic usage (fetch top 10 models by downloads):

```bash
python contrib/scripts/select_top_models.py
```

#### Options

```bash
python contrib/scripts/select_top_models.py \
--limit 10 \ # Number of models to select (default: 10)
--max-size 20.0 \ # Maximum model size in GB (default: 20.0)
--sort-by downloads \ # Sort by: downloads, likes, trending (default: downloads)
--task text-generation \ # Task filter (default: text-generation)
--output models.json # Output file (default: stdout)
```

#### Examples

Get top 5 small models (< 5GB):

```bash
python contrib/scriptsselect_top_models.py --limit 5 --max-size 5
```

Get most liked models:

```bash
python contrib/scripts/select_top_models.py --limit 10 --sort-by likes
```

Save to file:

```bash
python contrib/scripts/select_top_models.py --limit 20 --output top_models.json
```

### Output Format

The script outputs JSON with model metadata:

```json
[
{
"id": "Qwen/Qwen3-0.6B",
"family": "qwen3",
"arch": "transformer",
"format": "safetensors",
"param_size": "0.6B",
"size_gb": 1.41,
"downloads": 7509488,
"likes": 867
}
]
```

### Authentication

Some models require HuggingFace authentication. Set the `HF_TOKEN` environment variable:

```bash
export HF_TOKEN="your_huggingface_token"
python contrib/scripts/select_top_models.py
```

Or use `huggingface-cli`:

```bash
huggingface-cli login
python contrib/scripts/select_top_models.py
```

## GitHub Workflow Integration

The `build-top-models.yml` workflow uses this script to automatically:

1. Select top models from HuggingFace
2. Build them using modctl
3. Push to GitHub Container Registry

### Manual Trigger

You can manually trigger the workflow from GitHub Actions tab with custom parameters:

- **limit**: Number of models to build (default: 10)
- **max_size**: Maximum model size in GB (default: 20)
- **sort_by**: Sort criteria - downloads, likes, or trending

### Scheduled Runs

The workflow runs automatically every Sunday at 00:00 UTC.

### Required Secrets

The workflow requires these GitHub secrets:

- `HF_TOKEN` - HuggingFace API token (for downloading models)
- `GITHUB_TOKEN` - Automatically provided by GitHub Actions
Loading