-
Notifications
You must be signed in to change notification settings - Fork 21
Workflow for periodically building top models from huggingFace #359
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
Closed
avinashsingh77
wants to merge
145
commits into
modelpack:main
from
avinashsingh77:workflow_for_top_models
+728
−0
Closed
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] e945ee4
build(deps): Bump github/codeql-action from 3.30.6 to 4.30.8 (#299)
dependabot[bot] be02357
build(deps): Bump d7y.io/api/v2 from 2.1.71 to 2.1.72 (#300)
dependabot[bot] f7750c8
build(deps): Bump d7y.io/api/v2 from 2.1.71 to 2.1.72 (#300)
dependabot[bot] efcc788
build(deps): Bump golang.org/x/crypto from 0.42.0 to 0.43.0 (#301)
dependabot[bot] bb327cf
build(deps): Bump golang.org/x/crypto from 0.42.0 to 0.43.0 (#301)
dependabot[bot] 041150d
build(deps): Bump golang.org/x/sys from 0.36.0 to 0.37.0 (#303)
dependabot[bot] bd3c8d4
build(deps): Bump golang.org/x/sys from 0.36.0 to 0.37.0 (#303)
dependabot[bot] b57b1c6
build(deps): Bump github/codeql-action from 4.30.8 to 4.30.9 (#306)
dependabot[bot] 5e0b522
build(deps): Bump github/codeql-action from 4.30.8 to 4.30.9 (#306)
dependabot[bot] fc9aa78
build(deps): Bump d7y.io/api/v2 from 2.1.72 to 2.1.80 (#305)
dependabot[bot] c58e9d6
build(deps): Bump d7y.io/api/v2 from 2.1.72 to 2.1.80 (#305)
dependabot[bot] ecc0d3c
build(deps): Bump github.com/avast/retry-go/v4 from 4.6.1 to 4.7.0 (#…
dependabot[bot] c73bcf7
build(deps): Bump github.com/avast/retry-go/v4 from 4.6.1 to 4.7.0 (#…
dependabot[bot] 31f3bf6
build(deps): Bump actions/download-artifact from 5 to 6 (#313)
dependabot[bot] df25c8c
build(deps): Bump actions/download-artifact from 5 to 6 (#313)
dependabot[bot] cfe2e9a
build(deps): Bump github/codeql-action from 4.30.9 to 4.31.0 (#312)
dependabot[bot] e3c156f
build(deps): Bump github/codeql-action from 4.30.9 to 4.31.0 (#312)
dependabot[bot] 2032a6d
build(deps): Bump d7y.io/api/v2 from 2.1.80 to 2.1.81 (#311)
dependabot[bot] cbeea43
build(deps): Bump d7y.io/api/v2 from 2.1.80 to 2.1.81 (#311)
dependabot[bot] fc2566e
build(deps): Bump actions/upload-artifact from 4 to 5 (#310)
dependabot[bot] ebe0197
build(deps): Bump actions/upload-artifact from 4 to 5 (#310)
dependabot[bot] 43f4a57
fix(backend): correct auth key handling for token retrieval (#314)
chlins c1479b8
fix(backend): correct auth key handling for token retrieval (#314)
chlins 3f67446
fix(backend): correct authorization header assembly (#315)
chlins 0a21f6b
fix(backend): correct authorization header assembly (#315)
chlins 96b4595
build(deps): Bump github/codeql-action from 4.31.0 to 4.31.2 (#320)
dependabot[bot] 29dc3dc
build(deps): Bump github/codeql-action from 4.31.0 to 4.31.2 (#320)
dependabot[bot] 55a7d50
docs(getting-started): update install command to use main branch (#318)
chlins 8776dfc
docs(getting-started): update install command to use main branch (#318)
chlins a44093d
chore(deps): update dependencies to latest versions (#319)
chlins 81618dd
chore(deps): update dependencies to latest versions (#319)
chlins d68aa0e
feat(remote): add custom headers to HTTP requests (#322)
chlins 66a760e
feat(remote): add custom headers to HTTP requests (#322)
chlins 85b5f1a
feat(cmd): set raw flag default to true for attach, build, upload (#323)
chlins ee698cb
feat(cmd): set raw flag default to true for attach, build, upload (#323)
chlins 1d6da1f
build(deps): Bump golangci/golangci-lint-action from 8.0.0 to 9.0.0 (…
dependabot[bot] 1ff7523
build(deps): Bump golangci/golangci-lint-action from 8.0.0 to 9.0.0 (…
dependabot[bot] f958fdc
build(deps): Bump golang.org/x/sync from 0.17.0 to 0.18.0 (#326)
dependabot[bot] 5caf0f3
build(deps): Bump golang.org/x/sync from 0.17.0 to 0.18.0 (#326)
dependabot[bot] c67486b
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.10.2 to 8.11.2 …
dependabot[bot] 031ed0e
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.10.2 to 8.11.2 …
dependabot[bot] 7f1a23f
build(deps): Bump golang.org/x/sys from 0.37.0 to 0.38.0 (#324)
dependabot[bot] ba5311d
build(deps): Bump golang.org/x/sys from 0.37.0 to 0.38.0 (#324)
dependabot[bot] fb924e7
refactor(xattr): extract xattr operations to dedicated package (#331)
chlins 9dddb05
refactor(xattr): extract xattr operations to dedicated package (#331)
chlins 1cc5c0a
refactor(retry): update default retry options (#333)
chlins 0bbbb76
refactor(retry): update default retry options (#333)
chlins eafb2f3
build(deps): Bump actions/checkout from 5 to 6 (#334)
dependabot[bot] 31e8b94
build(deps): Bump actions/checkout from 5 to 6 (#334)
dependabot[bot] 3bde365
build(deps): Bump github/codeql-action from 4.31.2 to 4.31.4 (#335)
dependabot[bot] 84d4968
build(deps): Bump github/codeql-action from 4.31.2 to 4.31.4 (#335)
dependabot[bot] 444d958
build(deps): Bump golangci/golangci-lint-action from 9.0.0 to 9.1.0 (…
dependabot[bot] 1836744
build(deps): Bump golangci/golangci-lint-action from 9.0.0 to 9.1.0 (…
dependabot[bot] 3ca6862
build(deps): Bump github.com/go-git/go-git/v5 from 5.16.3 to 5.16.4 (…
dependabot[bot] fd77a8b
build(deps): Bump github.com/go-git/go-git/v5 from 5.16.3 to 5.16.4 (…
dependabot[bot] 4628cb5
build(deps): Bump d7y.io/api/v2 from 2.1.81 to 2.1.83 (#339)
dependabot[bot] 715b906
build(deps): Bump d7y.io/api/v2 from 2.1.81 to 2.1.83 (#339)
dependabot[bot] e1d2c95
build(deps): Bump golang.org/x/crypto from 0.43.0 to 0.45.0 (#340)
dependabot[bot] 909b7ad
build(deps): Bump golang.org/x/crypto from 0.43.0 to 0.45.0 (#340)
dependabot[bot] bd2dd97
feat: support modelfile generate with exclude patterns (#332)
qiumuyang 6553087
feat: support modelfile generate with exclude patterns (#332)
qiumuyang d561edf
feat: support modelfile generate with exclude patterns (#332)
qiumuyang 434949a
fix(processor): correct error handling and annotations logic (#341)
chlins 6d4152e
fix(processor): correct error handling and annotations logic (#341)
chlins ef23746
fix(processor): correct error handling and annotations logic (#341)
chlins 7c61b99
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] 0b7e3d4
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] 2b37d15
build(deps): Bump golangci/golangci-lint-action from 9.1.0 to 9.2.0 (…
dependabot[bot] af38ca7
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] fadbb5d
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] d1e2b27
build(deps): Bump github/codeql-action from 4.31.4 to 4.31.7 (#347)
dependabot[bot] 3304e7e
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] 5a604e1
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] 90d96cf
build(deps): Bump d7y.io/api/v2 from 2.1.83 to 2.1.89 (#348)
dependabot[bot] b4a2788
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] 433d289
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] e0d07b6
build(deps): Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#349)
dependabot[bot] 2ae07f9
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] 337bcad
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] 62abaf5
build(deps): Bump actions/download-artifact from 6 to 7 (#351)
dependabot[bot] 1d47e59
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] c270258
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] 32212b9
build(deps): Bump actions/upload-artifact from 5 to 6 (#352)
dependabot[bot] 22ac875
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] 84f32ff
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] 12c5553
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] e3d6540
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] 9d5a891
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] 614e68a
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] 4d23bb1
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] e700c1a
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] 78b5889
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] a0d31ed
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] 7b4f812
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] d250916
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] 6432f86
add workflow and supporting script
avinashsingh77 af16098
add workflow and supporting script
avinashsingh77 c899050
add readme for scripts
avinashsingh77 ce4c90c
add readme for scripts
avinashsingh77 0fa1a2c
improve func performance
avinashsingh77 df4cedf
improve func performance
avinashsingh77 509ad7d
Add support for modelFile generate via model providers model_url (#329)
avinashsingh77 62edaef
Add workflow for bilding top models
avinashsingh77 8ac9452
Add workflow for bilding top models
avinashsingh77 d791c65
Merge pull request #1 from avinashsingh77/workflow_for_top_models
avinashsingh77 03bd0f9
Merge pull request #1 from avinashsingh77/workflow_for_top_models
avinashsingh77 92d6815
Chore: Pin GitHub Actions to commit SHAs with version comments (#360)
bupd da80a9d
cleanup models after push
avinashsingh77 0795360
cleanup models after push
avinashsingh77 f001c44
Merge branch 'main' of github.com:avinashsingh77/modctl
avinashsingh77 c64bee7
Merge branch 'main' of github.com:avinashsingh77/modctl
avinashsingh77 4896ddf
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] 954a64e
build(deps): Bump actions/cache from 4 to 5 (#353)
dependabot[bot] 89198b1
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] 2fbe255
build(deps): Bump golang.org/x/sys from 0.38.0 to 0.39.0 (#354)
dependabot[bot] 72bec3d
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] 2e31c6b
build(deps): Bump d7y.io/api/v2 from 2.1.89 to 2.1.94 (#355)
dependabot[bot] 13cfa04
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] 96e80a4
build(deps): Bump github/codeql-action from 4.31.7 to 4.31.8 (#358)
dependabot[bot] f74b8a7
Add workflow for bilding top models
avinashsingh77 3fa954d
Add workflow for bilding top models
avinashsingh77 611ee4f
cleanup models after push
avinashsingh77 2eec53c
cleanup models after push
avinashsingh77 9c95bfc
feat(attach,upload): add destination-dir flag for custom file paths (…
chlins d1b3576
build(deps): Bump actions/setup-go from 6.0.0 to 6.1.0 (#369)
dependabot[bot] 2f04881
build(deps): Bump actions/checkout from 6.0.0 to 6.0.1 (#367)
dependabot[bot] fac74bd
build(deps): Bump d7y.io/api/v2 from 2.1.94 to 2.2.1 (#366)
dependabot[bot] d0fbe57
build(deps): Bump github.com/vbauerster/mpb/v8 from 8.11.2 to 8.11.3 …
dependabot[bot] cf5e4b6
build(deps): Bump github/codeql-action from 4.31.8 to 4.31.9 (#364)
dependabot[bot] 4b16ee1
add workflow and supporting script
avinashsingh77 f6e8833
add workflow and supporting script
avinashsingh77 5c63df5
add readme for scripts
avinashsingh77 2d38d7e
add readme for scripts
avinashsingh77 cc7c864
improve func performance
avinashsingh77 c7b9b6e
improve func performance
avinashsingh77 cee6eac
Merge branch 'workflow_for_top_models' of github.com:avinashsingh77/m…
avinashsingh77 b9321bb
Merge branch 'workflow_for_top_models' of github.com:avinashsingh77/m…
avinashsingh77 c2a7eca
move scripts under contrib
avinashsingh77 45be889
move scripts under contrib
avinashsingh77 1989b58
remove modctl and modelfile
avinashsingh77 7b59e3a
remove modctl and modelfile
avinashsingh77 ef37971
Merge branch 'main' into workflow_for_top_models
avinashsingh77 779ea1c
resolving conflicts
avinashsingh77 8f8fa7b
Merge branch 'modelpack:main' into workflow_for_top_models
avinashsingh77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
avinashsingh77 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.