diff --git a/.github/scripts/run_hf_models.py b/.github/scripts/run_hf_models.py new file mode 100644 index 00000000..c23b7f34 --- /dev/null +++ b/.github/scripts/run_hf_models.py @@ -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}") \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..f33d1700 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 "action@github.com" + 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 }} \ No newline at end of file diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 2c2dc1f6..aeaa9a4f 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -1,9 +1,7 @@ name: Publish to GitHub Pages on: - push: - branches: - - main + workflow_dispatch: jobs: publish: @@ -26,4 +24,4 @@ jobs: with: FOLDER: docs/build BRANCH: gh-pages - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/run-models.yml b/.github/workflows/run-models.yml new file mode 100644 index 00000000..b20463e9 --- /dev/null +++ b/.github/workflows/run-models.yml @@ -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 \ No newline at end of file