File tree Expand file tree Collapse file tree 5 files changed +55
-24
lines changed
Expand file tree Collapse file tree 5 files changed +55
-24
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " Python 3.10" ,
33 "image" : " mcr.microsoft.com/devcontainers/python:3.10" ,
4- "runArgs" : [
5- " --runtime" ,
6- " nvidia" ,
7- " --gpus" ,
8- " all" ,
9- // optional but make sure CUDA workloads are available
10- " --env" ,
11- " NVIDIA_VISIBLE_DEVICES=all" ,
12- // optional but make sure CUDA workloads are available
13- " --env" ,
14- " NVIDIA_DRIVER_CAPABILITIES=compute,utility"
15- ],
164 "customizations" : {
175 "vscode" : {
186 "extensions" : [
2614 " hbenl.vscode-test-explorer"
2715 ]
2816 }
29- },
30- "hostRequirements" : {
31- "gpu" : " optional"
32- },
33- "remoteEnv" : {
34- // optional but make sure CUDA workloads are available
35- "NVIDIA_VISIBLE_DEVICES" : " all" ,
36- "NVIDIA_DRIVER_CAPABILITIES" : " compute,utility"
3717 }
3818}
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " Python 3.11" ,
3+ "image" : " mcr.microsoft.com/devcontainers/python:3.11" ,
4+ "runArgs" : [
5+ " --runtime" ,
6+ " nvidia" ,
7+ " --gpus" ,
8+ " all" ,
9+ // optional but make sure CUDA workloads are available
10+ " --env" ,
11+ " NVIDIA_VISIBLE_DEVICES=all" ,
12+ // optional but make sure CUDA workloads are available
13+ " --env" ,
14+ " NVIDIA_DRIVER_CAPABILITIES=compute,utility"
15+ ],
16+ "customizations" : {
17+ "vscode" : {
18+ "extensions" : [
19+ " ms-python.black-formatter" ,
20+ " ms-python.flake8" ,
21+ " ms-python.isort" ,
22+ " ms-python.vscode-pylance" ,
23+ " ms-python.python" ,
24+ " ms-python.debugpy" ,
25+ " ms-python.vscode-python-envs" ,
26+ " hbenl.vscode-test-explorer"
27+ ]
28+ }
29+ },
30+ "hostRequirements" : {
31+ "gpu" : " optional"
32+ },
33+ "remoteEnv" : {
34+ // optional but make sure CUDA workloads are available
35+ "NVIDIA_VISIBLE_DEVICES" : " all" ,
36+ "NVIDIA_DRIVER_CAPABILITIES" : " compute,utility"
37+ }
38+ }
Original file line number Diff line number Diff line change 4949
5050 - name : Test
5151 # Using default directory for models
52+ # COVERAGE_CORE=pytrace: Workaround for Python 3.11 segfault with SQLite extensions + C tracer
53+ # See: https://github.com/nedbat/coveragepy/issues/1665
54+ env :
55+ COVERAGE_CORE : ${{ matrix.python-version == '3.11' && 'pytrace' || '' }}
5256 run : |
5357 pytest --cov --cov-branch --cov-report=xml -v -m "not slow" ./tests
5458
Original file line number Diff line number Diff line change @@ -42,8 +42,9 @@ def get_preview(
4242 return self .chunk_content [:max_chars ]
4343
4444 # Sort by start_offset to maintain document order
45- top_sentences .sort (
46- key = lambda s : s .start_offset if s .start_offset is not None else - 1
45+ top_sentences = sorted (
46+ top_sentences ,
47+ key = lambda s : s .start_offset if s .start_offset is not None else - 1 ,
4748 )
4849
4950 preview_parts = []
Original file line number Diff line number Diff line change 11import sqlite3
22import tempfile
3+ from collections .abc import Generator
34
45import pytest
56
@@ -26,7 +27,7 @@ def db_conn():
2627
2728
2829@pytest .fixture
29- def engine (db_conn ) -> Engine :
30+ def engine (db_conn ) -> Generator [ Engine , None , None ] :
3031 conn , settings = db_conn
3132
3233 engine = Engine (
@@ -39,4 +40,11 @@ def engine(db_conn) -> Engine:
3940 engine .quantize ()
4041 engine .create_new_context ()
4142
42- return engine
43+ yield engine
44+
45+ # Cleanup resources to prevent segfaults in Python 3.11
46+ # Must explicitly free resources before garbage collection
47+ try :
48+ engine .close ()
49+ except Exception :
50+ pass
You can’t perform that action at this time.
0 commit comments