Training Workflow #56
This file contains 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
name: Training Workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
script_content: | |
description: 'Content of train.py' | |
required: true | |
type: string | |
jobs: | |
train: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install uv | |
uses: astral-sh/setup-uv@v1 | |
- name: Cache UV packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/uv | |
.venv | |
key: ${{ runner.os }}-uv-numpy-torch-v2 | |
restore-keys: | | |
${{ runner.os }}-uv-numpy-torch- | |
- name: Create virtual environment and install dependencies | |
run: | | |
uv venv | |
source .venv/bin/activate | |
uv pip install numpy torch | |
- name: Create and run training script | |
run: | | |
echo "${{ inputs.script_content }}" > train.py | |
source .venv/bin/activate | |
python train.py > training.log 2>&1 | |
- name: Upload logs | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: training-logs | |
path: training.log | |
retention-days: 1 | |
if-no-files-found: warn | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: train | |
if: always() | |
steps: | |
- uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: training-logs |