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
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "svsbench"
version = "0.1.0"
description = "Benchmarking for Scalable Vector Search"
readme = "README.md"
authors = [
{ name = "Mihai Capotă", email = "mihai.capota@intel.com" }
]
dynamic = ["version"]
requires-python = ">=3.12"
dependencies = [
"numpy>=1.10",
Expand All @@ -15,7 +15,7 @@ dependencies = [
]

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[dependency-groups]
Expand All @@ -25,5 +25,8 @@ dev = [
"ruff>=0.9.6",
]

[tool.hatch.version]
source = "vcs"

[tool.ruff]
line-length = 79
6 changes: 6 additions & 0 deletions src/svsbench/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Scalable Vector Search Benchmarking."""

from importlib.metadata import version

if __spec__ is None:
raise RuntimeError("Running __init__.py directly is not supported.")
__version__ = version(__spec__.parent)
1 change: 1 addition & 0 deletions src/svsbench/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def main(argv: list[str] | None = None) -> None:
)
print("Logging to", log_file, sep="\n")
logger.info({"argv": argv if argv else sys.argv})
utils.check_uncommitted_and_log_version(logger, args.uncommitted)
args.out_dir.mkdir(exist_ok=True)
if args.data_matrix_file is not None:
if args.query_matrix_file is None:
Expand Down
1 change: 1 addition & 0 deletions src/svsbench/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def main(argv: str | None = None) -> None:
)
print("Logging to", log_file, sep="\n")
logger.info({"argv": argv if argv else sys.argv})
utils.check_uncommitted_and_log_version(logger, args.uncommitted)
compress(
idx_dir=args.idx_dir,
svs_type=args.svs_type,
Expand Down
1 change: 1 addition & 0 deletions src/svsbench/generate_ground_truth.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def main(argv: str | None = None) -> None:
)
print("Logging to", log_file, sep="\n")
logger.info({"argv": argv if argv else sys.argv})
utils.check_uncommitted_and_log_version(logger, args.uncommitted)
generate_ground_truth(
vecs_path=args.vecs_file,
query_file=args.query_file,
Expand Down
1 change: 1 addition & 0 deletions src/svsbench/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def main(argv: str | None = None) -> None:
)
print("Logging to", log_file, sep="\n")
logger.info({"argv": sys.argv})
utils.check_uncommitted_and_log_version(logger, args.uncommitted)
search(
idx_dir=args.idx_dir,
vecs_path=args.vecs_file,
Expand Down
38 changes: 36 additions & 2 deletions src/svsbench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import os
from datetime import datetime
from pathlib import Path
from typing import Any
from typing import Any, Final
from warnings import warn

import svs

from . import consts
from . import consts, __version__

UNCOMMITTED: Final = "--uncommitted"

class JSONFormatter(logging.Formatter):
"""Formatter that dumps msg and created as JSON."""
Expand Down Expand Up @@ -209,6 +210,11 @@ def add_common_arguments(parser):
choices=consts.SVS_TYPES,
default="float32",
)
parser.add_argument(
UNCOMMITTED,
action="store_true",
help="Run even if there are changes in SVSBench not committed to git",
)


def ground_truth_path(
Expand All @@ -230,3 +236,31 @@ def ground_truth_path(
f"{seed if seed is not None else False}.ivecs",
)
)

def check_uncommitted_and_log_version(
logger: logging.Logger, uncommitted: bool
) -> None:
"""Check if SVSBench is using uncommitted code and log version.

The version has a suffix starting with "d2" when there are
uncommitted code changes, e.g., "0.1.1.dev4+gcf3cee1.d20250501".
Without uncommitted changes, that suffix is missing, e.g.,
"0.1.1.dev4+gcf3cee1".

Args:
logger: Logger to log the version.
uncommitted: If True, do not raise an error when uncommitted
code changes are detected.
Raises:
RuntimeError: If uncommitted code changes are detected and
`uncommitted` is False.
"""
if "." in __version__ and __version__.rsplit(".", 1)[1].startswith("d2"):
if not uncommitted:
raise RuntimeError(
"Uncommitted changes detected. To ignore this error,"
f" add {UNCOMMITTED} to the SVSBench call."
)
else:
logger.warning("uncommitted_code_changes")
logger.info({"version": __version__})
2 changes: 2 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_main_with_train_query(tmp_path, tmp_vecs, query_path):
str(query_path),
"--out_dir",
str(tmp_path),
"--uncommitted",
]
)

Expand Down Expand Up @@ -100,5 +101,6 @@ def test_main_with_matrices(tmp_path, tmp_vecs, query_path):
str(query_matrix_path),
"--out_dir",
str(tmp_path),
"--uncommitted",
]
)
Loading
Loading