-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (54 loc) · 1.5 KB
/
train_workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Training Workflow
on:
pull_request:
paths:
- '.github/workflows/**'
- 'train.py'
workflow_dispatch:
inputs:
script_content:
description: 'Content of train.py'
required: false
type: string
jobs:
train:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Cache PyTorch
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-torch-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-torch-
- name: Create requirements file
run: |
cat << EOF > requirements.txt
numpy
torch
EOF
- name: Setup Python environment
run: |
uv venv .venv
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv pip install -r requirements.txt
- name: Run training script
run: |
if [ ! -z "${{ inputs.script_content }}" ]; then
echo "${{ inputs.script_content }}" > train.py
fi
cat train.py # Debug: print the content
python train.py > training.log 2>&1
- name: Upload logs
uses: actions/upload-artifact@v3
if: always()
with:
name: training-logs
path: training.log