-
Notifications
You must be signed in to change notification settings - Fork 6
305 lines (263 loc) · 10.4 KB
/
Copy pathci.yml
File metadata and controls
305 lines (263 loc) · 10.4 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Python CI
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
actions: read
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
python-ci-capi:
runs-on: ubuntu-latest
steps:
- name: Checkout ladybug
uses: actions/checkout@v4
with:
repository: LadybugDB/ladybug
fetch-depth: 1
path: ladybug
- name: Update submodules
working-directory: ladybug
run: git submodule update --init --recursive dataset
- name: Checkout ladybug-python into ladybug/tools/python_api
uses: actions/checkout@v4
with:
fetch-depth: 1
path: ladybug/tools/python_api
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: python-${{ runner.os }}-${{ runner.arch }}-${{ github.ref }}
max-size: 2G
create-symlink: true
restore-keys: |
python-${{ runner.os }}-${{ runner.arch }}-refs/heads/main
python-${{ runner.os }}-${{ runner.arch }}-
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
working-directory: ladybug/tools/python_api
run: |
uv venv .venv
uv pip install -e .[dev]
- name: Resolve compatible lbug artifact run
working-directory: ladybug
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
SHA="$(git rev-parse HEAD)"
API_URL="https://api.github.com/repos/LadybugDB/ladybug/actions/workflows/build-and-deploy.yml/runs"
AUTH_HEADER="Authorization: Bearer $GITHUB_TOKEN"
ACCEPT_HEADER="Accept: application/vnd.github+json"
VERSION_HEADER="X-GitHub-Api-Version: 2022-11-28"
RUN_ID="$(
curl -fsSL \
-H "$AUTH_HEADER" \
-H "$ACCEPT_HEADER" \
-H "$VERSION_HEADER" \
"$API_URL?head_sha=$SHA&status=success&per_page=1" \
| python -c 'import json,sys; data=json.load(sys.stdin); runs=data.get("workflow_runs") or []; print(runs[0]["id"] if runs else "")'
)"
if [ -z "$RUN_ID" ]; then
RUN_ID="$(
curl -fsSL \
-H "$AUTH_HEADER" \
-H "$ACCEPT_HEADER" \
-H "$VERSION_HEADER" \
"$API_URL?branch=main&status=success&per_page=1" \
| python -c 'import json,sys; data=json.load(sys.stdin); runs=data.get("workflow_runs") or []; print(runs[0]["id"] if runs else "")'
)"
fi
if [ -z "$RUN_ID" ]; then
echo "Could not find a successful LadybugDB/ladybug build-and-deploy run." >&2
exit 1
fi
echo "Using Ladybug build-and-deploy RUN_ID=$RUN_ID for SHA=$SHA"
echo "LBUG_BUILD_RUN_ID=$RUN_ID" >> "$GITHUB_ENV"
- name: Download shared lbug library
working-directory: ladybug/tools/python_api
env:
GH_TOKEN: ${{ github.token }}
run: |
gh --version
LBUG_PRECOMPILED_RUN_ID="$LBUG_BUILD_RUN_ID" LBUG_LIB_KIND=shared bash scripts/download_lbug.sh .cache/lbug-capi.env
cat .cache/lbug-capi.env >> "$GITHUB_ENV"
- name: Check formatting (black)
working-directory: ladybug/tools/python_api
run: |
uv pip install black
.venv/bin/black --check src_py test
- name: Run ruff check
working-directory: ladybug/tools/python_api
run: |
.venv/bin/ruff check src_py test
- name: Debug dataset resolution
working-directory: ladybug/tools/python_api
run: |
pwd
ls -la
echo "--- path helper candidates ---"
find . .. ../.. \( -name 'lbug_test_paths.py' -o -name 'test_helper.py' \) -print
echo "--- dataset candidates ---"
find . .. ../.. -maxdepth 3 -type d -name dataset -print
echo "--- python debug ---"
.venv/bin/python - <<'PY'
import importlib.util
import pathlib
import sys
print("cwd =", pathlib.Path.cwd())
sys.path.insert(0, str(pathlib.Path("test").resolve()))
print("sys.path[:6] =", sys.path[:6])
print("find_spec(lbug_test_paths) =", importlib.util.find_spec("lbug_test_paths"))
try:
import lbug_test_paths
print("lbug_test_paths.__file__ =", getattr(lbug_test_paths, "__file__", None))
print("LBUG_ROOT =", getattr(lbug_test_paths, "LBUG_ROOT", None))
print("LBUG_ROOT_PATH =", getattr(lbug_test_paths, "LBUG_ROOT_PATH", None))
print("DATASET_ROOT =", getattr(lbug_test_paths, "DATASET_ROOT", None))
except Exception as exc:
print("import lbug_test_paths failed:", repr(exc))
for rel in (
pathlib.Path("dataset"),
pathlib.Path("../dataset"),
pathlib.Path("../../dataset"),
pathlib.Path("test/test_helper.py"),
pathlib.Path("test_helper.py"),
pathlib.Path("lbug_test_paths.py"),
pathlib.Path("../dataset/tinysnb/schema.cypher"),
pathlib.Path("../../dataset/tinysnb/schema.cypher"),
):
print(f"{rel} exists={rel.exists()} resolved={rel.resolve()}")
PY
- name: Run pytest (C API backend, non-torch)
working-directory: ladybug/tools/python_api
env:
LBUG_PYTHON_BACKEND: capi
run: |
.venv/bin/python -m pytest -vv ./test --ignore=./test/test_torch_geometric.py
- name: Run pytest (C API backend, torch-geometric)
working-directory: ladybug/tools/python_api
env:
LBUG_PYTHON_BACKEND: capi
run: |
.venv/bin/python -c 'import sys; import torch; import pytest; raise SystemExit(pytest.main(["-vv", "./test/test_torch_geometric.py"]))'
python-ci-pybind:
runs-on: ubuntu-latest
steps:
- name: Checkout ladybug
uses: actions/checkout@v4
with:
repository: LadybugDB/ladybug
fetch-depth: 1
path: ladybug
- name: Update submodules
working-directory: ladybug
run: git submodule update --init --recursive dataset
- name: Checkout ladybug-python into ladybug/tools/python_api
uses: actions/checkout@v4
with:
fetch-depth: 1
path: ladybug/tools/python_api
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: python-${{ runner.os }}-${{ runner.arch }}-${{ github.ref }}
max-size: 2G
create-symlink: true
restore-keys: |
python-${{ runner.os }}-${{ runner.arch }}-refs/heads/main
python-${{ runner.os }}-${{ runner.arch }}-
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
working-directory: ladybug/tools/python_api
run: |
uv venv .venv
uv pip install -e .[dev]
- name: Check formatting (black)
working-directory: ladybug/tools/python_api
run: |
uv pip install black
.venv/bin/black --check src_py test
- name: Run ruff check
working-directory: ladybug/tools/python_api
run: |
.venv/bin/ruff check src_py test
- name: Build native module
working-directory: ladybug
env:
GEN: Ninja
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
make python
cp tools/python_api/src_py/*.py tools/python_api/build/ladybug/
- name: Debug dataset resolution
working-directory: ladybug/tools/python_api
run: |
pwd
ls -la
echo "--- path helper candidates ---"
find . .. ../.. \( -name 'lbug_test_paths.py' -o -name 'test_helper.py' \) -print
echo "--- dataset candidates ---"
find . .. ../.. -maxdepth 3 -type d -name dataset -print
echo "--- python debug ---"
.venv/bin/python - <<'PY'
import importlib.util
import pathlib
import sys
print("cwd =", pathlib.Path.cwd())
sys.path.insert(0, str(pathlib.Path("test").resolve()))
print("sys.path[:6] =", sys.path[:6])
print("find_spec(lbug_test_paths) =", importlib.util.find_spec("lbug_test_paths"))
try:
import lbug_test_paths
print("lbug_test_paths.__file__ =", getattr(lbug_test_paths, "__file__", None))
print("LBUG_ROOT =", getattr(lbug_test_paths, "LBUG_ROOT", None))
print("LBUG_ROOT_PATH =", getattr(lbug_test_paths, "LBUG_ROOT_PATH", None))
print("DATASET_ROOT =", getattr(lbug_test_paths, "DATASET_ROOT", None))
except Exception as exc:
print("import lbug_test_paths failed:", repr(exc))
for rel in (
pathlib.Path("dataset"),
pathlib.Path("../dataset"),
pathlib.Path("../../dataset"),
pathlib.Path("test/test_helper.py"),
pathlib.Path("test_helper.py"),
pathlib.Path("lbug_test_paths.py"),
pathlib.Path("../dataset/tinysnb/schema.cypher"),
pathlib.Path("../../dataset/tinysnb/schema.cypher"),
):
print(f"{rel} exists={rel.exists()} resolved={rel.resolve()}")
PY
- name: Run pytest (pybind backend, non-torch)
working-directory: ladybug/tools/python_api
env:
LBUG_PYTHON_BACKEND: pybind
run: |
export PYTHONPATH=./build
.venv/bin/python -m pytest -vv ./test --ignore=./test/test_torch_geometric.py
- name: Run pytest (pybind backend, torch-geometric)
working-directory: ladybug/tools/python_api
env:
LBUG_PYTHON_BACKEND: pybind
run: |
export PYTHONPATH=./build
.venv/bin/python -c 'import sys; import torch; import pytest; raise SystemExit(pytest.main(["-vv", "./test/test_torch_geometric.py"]))'