Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
"vectordb_bench.results" = ["*.json"]
"vectordb_bench.fig.homepage" = ["*.png"]

[tool.setuptools.packages.find]
where = ["."]
Expand Down
13 changes: 4 additions & 9 deletions vectordb_bench/backend/clients/milvus/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,14 @@ class MilvusRefineTypedDict(TypedDict):
]


class MilvusHNSWPQTypedDict(
CommonTypedDict,
MilvusTypedDict,
MilvusHNSWTypedDict,
MilvusRefineTypedDict
):
class MilvusHNSWPQTypedDict(CommonTypedDict, MilvusTypedDict, MilvusHNSWTypedDict, MilvusRefineTypedDict):
nbits: Annotated[
int,
click.option(
"--nbits",
type=int,
required=True,
)
),
]


Expand Down Expand Up @@ -194,7 +189,7 @@ class MilvusHNSWPRQTypedDict(
type=int,
help="The number of residual subquantizers.",
required=True,
)
),
]


Expand All @@ -220,7 +215,7 @@ def MilvusHNSWPRQ(**parameters: Unpack[MilvusHNSWPRQTypedDict]):
refine=parameters["refine"],
refine_type=parameters["refine_type"],
refine_k=parameters["refine_k"],
nrq=parameters["nrq"]
nrq=parameters["nrq"],
),
**parameters,
)
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
32 changes: 30 additions & 2 deletions vectordb_bench/frontend/components/welcome/welcomePrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from PIL import Image
from io import BytesIO
import os
from pathlib import Path
from importlib import resources

from vectordb_bench.frontend.components.welcome.pagestyle import pagestyle

Expand All @@ -11,12 +13,38 @@ def get_image_as_base64(image_path):
if image_path.startswith("http"):
return image_path

# Try to load from package resources first (for pip installed package)
if image_path.startswith("fig/homepage/"):
try:
# Convert fig/homepage/xxx.png to vectordb_bench.fig.homepage
package_parts = ["vectordb_bench"] + image_path.split("/")[:-1]
package_name = ".".join(package_parts)
file_name = os.path.basename(image_path)

# Get the resource content using importlib.resources
files = resources.files(package_name)
img_data = (files / file_name).read_bytes()

img = Image.open(BytesIO(img_data))
buffered = BytesIO()
img.save(buffered, format="PNG")
return f"data:image/png;base64,{base64.b64encode(buffered.getvalue()).decode()}"
except Exception:
# If package resource fails, try the original path
pass

# Fallback to file system path (for development)
path = os.path.expanduser(image_path)
if not os.path.isabs(path):
# Try relative to the vectordb_bench package directory
package_dir = Path(__file__).parent.parent.parent
path = package_dir / path

img = Image.open(path)
buffered = BytesIO()
img.save(buffered, format="PNG")
return f"data:image/png;base64,{base64.b64encode(buffered.getvalue()).decode()}"
except Exception as e:
except Exception:
return None


Expand Down Expand Up @@ -110,7 +138,7 @@ def welcomePrams(st):
for option in options:
option["image"] = get_image_as_base64(option["image"])

for i, option in enumerate(options[:6]):
for option in options[:6]:
html_content += f"""
<a href="/{option['link']}" target="_self" style="text-decoration: none;">
<div class="section-card">
Expand Down