Skip to content

Commit 4c98a16

Browse files
CI Tests and SPI Docs (#65)
* Fix watchOS compilation error * Add spi docc builds * Run tests on PRs into main * Require at least macos 13 * Add very verbose output for tests * Update readme badges
1 parent 24605a8 commit 4c98a16

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.github/workflows/unit-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: macos-13
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build
16+
run: swift build --vv --build-tests
17+
- name: Run tests
18+
run: swift test --vv --skip-build

.spi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [Transformers]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# `swift-transformers`
2+
[![Unit Tests](https://github.com/huggingface/swift-transformers/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/huggingface/swift-transformers/actions/workflows/unit-tests.yml)
3+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fhuggingface%2Fswift-transformers%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/huggingface/swift-transformers)
4+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fhuggingface%2Fswift-transformers%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/huggingface/swift-transformers)
25

36
This is a collection of utilities to help adopt language models in Swift apps. It tries to follow the Python `transformers` API and abstractions whenever possible, but it also aims to provide an idiomatic Swift interface and does not assume prior familiarity with [`transformers`](https://github.com/huggingface/transformers) or [`tokenizers`](https://github.com/huggingface/tokenizers).
47

Sources/TransformersCLI/main.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ struct TransformersCLI: ParsableCommand {
5353
}
5454
semaphore.wait()
5555
}
56-
56+
5757
func compile(at url: URL) throws -> URL {
58+
#if os(watchOS)
59+
fatalError("Model compilation is not supported on watchOS")
60+
#else
5861
if url.pathExtension == "mlmodelc" { return url }
5962
print("Compiling model \(url)")
6063
return try MLModel.compileModel(at: url)
64+
#endif
6165
}
62-
66+
6367
func run() throws {
6468
let url = URL(filePath: modelPath)
6569
let compiledURL = try compile(at: url)

0 commit comments

Comments
 (0)