Skip to content

Commit 56aa1bc

Browse files
authored
fix: use semantic version comparison instead of string comparison (#34)
Version checks in the /healthz endpoint used string comparison (e.g. lancedb_version >= "0.5") which is lexicographic, not numeric. This produces incorrect results for certain version numbers: "0.9" >= "0.16" evaluates to True as a string comparison, but 0.9 is less than 0.16 semantically. Replaced with packaging.version.parse() which handles semver correctly. packaging is available as a transitive dependency of pip/setuptools. Fixes #20
1 parent d83e2ec commit 56aa1bc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

backend/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import lancedb
1010
import pyarrow as pa
11+
from packaging.version import parse as parse_version
1112
from fastapi import FastAPI, HTTPException, Query
1213
from fastapi.middleware.cors import CORSMiddleware
1314
from fastapi.responses import JSONResponse
@@ -126,8 +127,8 @@ async def health_check():
126127
# Determine compatibility features based on Lance version
127128
compat = {
128129
"vector_preview": True,
129-
"schema_evolution": lancedb_version >= "0.5",
130-
"lance_v2_format": lancedb_version >= "0.16"
130+
"schema_evolution": parse_version(lancedb_version) >= parse_version("0.5"),
131+
"lance_v2_format": parse_version(lancedb_version) >= parse_version("0.16")
131132
}
132133

133134
# Generate build tag

0 commit comments

Comments
 (0)