Skip to content

cI: add workflows to test models, and publish new package version #240

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

Draft
wants to merge 2 commits into
base: @nk/monorepo
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 56 additions & 0 deletions .github/scripts/run_hf_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from huggingface_hub import list_repo_files, hf_hub_download, list_models
import subprocess
import os

ORG_NAME = "software-mansion"
DEST_DIR = "downloaded_models"
EXECUTOR_RUNNER_PATH = "./cmake-out/executor_runner"

os.makedirs(DEST_DIR, exist_ok=True)

repos = list_models(author=ORG_NAME)

for repo in repos:
repo_id = repo.id
print(f"\n🔍 Checking repository: {repo_id}")

try:
files = list_repo_files(repo_id)
except Exception as e:
print(f"⚠️ Error listing files in {repo_id}: {e}")
continue

pte_files = [f for f in files if f.endswith(".pte")]
print(f"Found {len(pte_files)} .pte file(s)")

for pte_file in pte_files:
try:
print(f"⬇️ Downloading {pte_file} from {repo_id}")
local_path = hf_hub_download(repo_id=repo_id, filename=pte_file, cache_dir=DEST_DIR)
print(f"✅ Downloaded to: {local_path}")

print(f"🚀 Running executor_runner on {local_path}")
result = subprocess.run(
[EXECUTOR_RUNNER_PATH, "--model_path", local_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)

print("📤 executor_runner output:")
print(result.stdout)

if result.returncode != 0:
print("❌ executor_runner failed:")
print(result.stderr)

except Exception as e:
print(f"❌ Error processing {pte_file}: {e}")

finally:
if os.path.exists(local_path):
try:
os.remove(local_path)
print(f"🧹 Removed {local_path}")
except Exception as cleanup_err:
print(f"⚠️ Failed to remove {local_path}: {cleanup_err}")
58 changes: 58 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish Package & Deploy Docs

on:
workflow_dispatch:

jobs:
publish-package:
if: github.repository == 'software-mansion/react-native-executorch'
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/react-native-executorch
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: yarn install

- name: Build package
run: yarn build

- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-docs:
if: github.repository == 'software-mansion/react-native-executorch'
needs: publish-package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

- name: Install docs dependencies & build docs
working-directory: docs
run: |
yarn
yarn build

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
FOLDER: docs/build
BRANCH: gh-pages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 2 additions & 4 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Publish to GitHub Pages

on:
push:
branches:
- main
workflow_dispatch:

jobs:
publish:
Expand All @@ -26,4 +24,4 @@ jobs:
with:
FOLDER: docs/build
BRANCH: gh-pages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/run-models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Exported Models

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout this repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install prerequisites
run: sudo apt-get update && sudo apt-get install -y python3-venv

- name: Clone executorch Repository
run: |
git clone https://github.com/software-mansion-labs/executorch
git submodule sync
git submodule update --init --recursive

- name: Setup Python Virtual Environment and Build
run: |
cd executorch
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
./install_executorch.sh
cmake --build cmake-out -j9
shell: bash
- name: Run models with executor_runner
run: |
cd executorch
source .venv/bin/activate
python ../download_hf_models.py
shell: bash