-
Notifications
You must be signed in to change notification settings - Fork 201
134 lines (118 loc) · 3.92 KB
/
python.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Python
on:
pull_request:
jobs:
build_and_test:
name: Check everything builds & tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
# Lowest and highest, no version specified so that
# new releases get automatically tested against
version: [{torch: torch==1.10, python: "3.8"}, {torch: torch, python: "3.12"}]
# TODO this would include macos ARM target.
# however jax has an illegal instruction issue
# that exists only in CI (probably difference in instruction support).
# include:
# - os: macos-latest
# version:
# torch: torch
# python: "3.11"
defaults:
run:
working-directory: ./bindings/python
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Cargo install audit
run: cargo install cargo-audit
- uses: Swatinem/rust-cache@v2
with:
workspaces: "bindings/python"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version.python }}
architecture: "x64"
- name: Lint with RustFmt
run: cargo fmt -- --check
- name: Lint with Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run Audit
run: cargo audit -D warnings
- name: Install
run: |
pip install -U pip
pip install .[numpy,tensorflow]
pip install ${{ matrix.version.torch }}
- name: Install (jax, flax)
if: matrix.os != 'windows-latest'
run: |
pip install .[jax]
shell: bash
- name: Install (mlx)
if: matrix.os == 'macos-latest'
run: |
pip install .[mlx]
shell: bash
- name: Check style
run: |
pip install .[quality]
black --check --line-length 119 --target-version py35 py_src/safetensors tests
- name: Run tests
run: |
cargo test
pip install .[testing]
pytest -sv tests/
test_s390x_big_endian:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
name: Test bigendian - S390X
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set short sha
id: vars
run: echo "GITHUB_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/huggingface/safetensors/s390x
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Test big endian
uses: docker/build-push-action@v4
with:
platforms: linux/s390x
file: Dockerfile.s390x.test
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/huggingface/safetensors/s390x:cache,mode=max
cache-to: type=registry,ref=ghcr.io/huggingface/safetensors/s390x:cache,mode=max