Repository navigation
93 lines (79 loc) · 3.06 KB
/
Copy pathpython-package.yml
File metadata and controls
93 lines (79 loc) · 3.06 KB
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
name: Validate Install
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10.11", 3.11, 3.12, 3.13, 3.14]
fail-fast: false
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('chainforge/requirements.txt', 'chainforge/constraints.txt', 'setup.py') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install package
run: |
pip install -e .
- name: Install with RAG extras
run: |
pip install -e .[rag]
- name: Install pytest
run: |
pip install pytest
# The RAG tests download sentence-transformers / model2vec models from the
# HuggingFace Hub. Cache them so that every matrix entry doesn't re-fetch
# a few hundred MB on each run.
- name: Cache HuggingFace models
uses: actions/cache@v4
with:
path: ~/.cache/huggingface
key: ${{ runner.os }}-hf-${{ hashFiles('tests/*.py') }}
restore-keys: |
${{ runner.os }}-hf-
# TODO: Check that the server runs
# NOTE: faiss-cpu is deliberately NOT installed here. It bundles its own
# OpenMP runtime, and a second libomp in the same interpreter as torch's
# segfaults (verified on macOS: merely having faiss-cpu installed, without
# importing it, turns the embedding tests into SIGSEGV). The FaissVectorStore
# tests therefore run in the separate step below.
- name: Run tests
env:
HF_HUB_DISABLE_TELEMETRY: "1"
# Tests needing a provider API key skip themselves when it is unset,
# so this job stays green (and free) without secrets.
run: pytest -v -m "not needs_faiss"
# A second, isolated invocation for the optional FAISS backend. ChainForge
# no longer offers a faiss extra -- the pip wheels collide with any other
# OpenMP library, so we do not install it for anyone -- but the
# faiss_vector_store retrieval method still works when a user installs it
# themselves, and this keeps that path from rotting. faiss-cpu is named
# directly here for the same reason.
#
# Installing it only now means it cannot destabilise the run above, and
# excluding `slow` keeps this process from loading a real ML model, which
# is the combination that crashes.
- name: Install faiss and run the FAISS backend tests
env:
HF_HUB_DISABLE_TELEMETRY: "1"
run: |
pip install faiss-cpu
pytest -v -m "needs_faiss and not slow"