Training Workflow #31
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: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
# Cache pip packages | |
- name: Cache pip packages | |
uses: actions/cache@v3 | |
id: pip-cache | |
with: | |
path: | | |
~/.cache/pip | |
key: ${{ runner.os }}-pip-v1 | |
restore-keys: | | |
${{ runner.os }}-pip- | |
# Cache PyTorch specific directories | |
- name: Cache PyTorch | |
uses: actions/cache@v3 | |
id: pytorch-cache | |
with: | |
path: | | |
~/.cache/torch | |
~/.cache/torch_extensions | |
~/.local/lib/python*/site-packages/torch | |
~/.local/lib/python*/site-packages/torch_* | |
key: ${{ runner.os }}-pytorch-v1 | |
restore-keys: | | |
${{ runner.os }}-pytorch- | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install torch numpy | |
# Print versions for debugging | |
python -c "import torch; print(f'PyTorch version: {torch.__version__}')" | |
python -c "import numpy; print(f'NumPy version: {numpy.__version__}')" | |
- name: Create and run training script | |
run: | | |
echo "${{ inputs.script_content }}" > train.py | |
echo "Content of train.py:" | |
cat train.py | |
python train.py > training.log 2>&1 | |
- name: Upload logs | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: training-logs | |
path: training.log |