Compare commits

...
1 Commits
Author SHA1 Message Date
Nicolò Boschi e48be911a2 fix: include correct __version__ in python packages 2026-01-28 16:16:28 +01:00
6 changed files with 86 additions and 24 deletions
+1 -1
View File
@@ -46,4 +46,4 @@ __all__ = [
"RemoteTEICrossEncoder",
"LLMConfig",
]
__version__ = "0.1.0"
__version__ = "0.4.0"
@@ -137,15 +137,26 @@ class LocalSTCrossEncoder(CrossEncoderModel):
# which can cause issues when accelerate is installed but no GPU is available.
# Note: We do NOT use device_map because CrossEncoder internally calls .to(device)
# after loading, which conflicts with accelerate's device_map handling.
import os
import torch
# Check for GPU (CUDA) or Apple Silicon (MPS)
has_gpu = torch.cuda.is_available() or (hasattr(torch.backends, "mps") and torch.backends.mps.is_available())
# Force CPU mode if HINDSIGHT_FORCE_CPU is set (used in daemon mode to avoid MPS/XPC issues)
force_cpu = os.getenv("HINDSIGHT_FORCE_CPU", "0") == "1"
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
if force_cpu:
device = "cpu"
logger.info("Reranker: forcing CPU mode (HINDSIGHT_FORCE_CPU=1)")
else:
# Check for GPU (CUDA) or Apple Silicon (MPS)
has_gpu = torch.cuda.is_available() or (
hasattr(torch.backends, "mps") and torch.backends.mps.is_available()
)
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
device = "cpu"
self._model = CrossEncoder(
self.model_name,
@@ -211,12 +222,21 @@ class LocalSTCrossEncoder(CrossEncoderModel):
)
# Determine device based on hardware availability
has_gpu = torch.cuda.is_available() or (hasattr(torch.backends, "mps") and torch.backends.mps.is_available())
import os
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
force_cpu = os.getenv("HINDSIGHT_FORCE_CPU", "0") == "1"
if force_cpu:
device = "cpu"
else:
has_gpu = torch.cuda.is_available() or (
hasattr(torch.backends, "mps") and torch.backends.mps.is_available()
)
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
device = "cpu"
self._model = CrossEncoder(
self.model_name,
@@ -132,15 +132,26 @@ class LocalSTEmbeddings(Embeddings):
# Determine device based on hardware availability.
# We always set low_cpu_mem_usage=False to prevent lazy loading (meta tensors)
# which can cause issues when accelerate is installed but no GPU is available.
import os
import torch
# Check for GPU (CUDA) or Apple Silicon (MPS)
has_gpu = torch.cuda.is_available() or (hasattr(torch.backends, "mps") and torch.backends.mps.is_available())
# Force CPU mode if HINDSIGHT_FORCE_CPU is set (used in daemon mode to avoid MPS/XPC issues)
force_cpu = os.getenv("HINDSIGHT_FORCE_CPU", "0") == "1"
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
if force_cpu:
device = "cpu"
logger.info("Embeddings: forcing CPU mode (HINDSIGHT_FORCE_CPU=1)")
else:
# Check for GPU (CUDA) or Apple Silicon (MPS)
has_gpu = torch.cuda.is_available() or (
hasattr(torch.backends, "mps") and torch.backends.mps.is_available()
)
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
device = "cpu"
self._model = SentenceTransformer(
self.model_name,
@@ -199,12 +210,21 @@ class LocalSTEmbeddings(Embeddings):
)
# Determine device based on hardware availability
has_gpu = torch.cuda.is_available() or (hasattr(torch.backends, "mps") and torch.backends.mps.is_available())
import os
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
force_cpu = os.getenv("HINDSIGHT_FORCE_CPU", "0") == "1"
if force_cpu:
device = "cpu"
else:
has_gpu = torch.cuda.is_available() or (
hasattr(torch.backends, "mps") and torch.backends.mps.is_available()
)
if has_gpu:
device = None # Let sentence-transformers auto-detect GPU/MPS
else:
device = "cpu"
self._model = SentenceTransformer(
self.model_name,
+6
View File
@@ -140,6 +140,12 @@ def main():
args.port = DEFAULT_DAEMON_PORT
args.host = "127.0.0.1" # Only bind to localhost for security
# Force CPU mode for daemon to avoid macOS MPS/XPC issues
# MPS (Metal Performance Shaders) has unstable XPC connections in background processes
# that can cause assertion failures and process crashes at the C++ level
# (which Python exception handlers cannot catch)
os.environ["HINDSIGHT_FORCE_CPU"] = "1"
# Check if another daemon is already running
daemon_lock = DaemonLock()
if not daemon_lock.acquire():
+16
View File
@@ -77,6 +77,22 @@ for package in "${PYTHON_PACKAGES[@]}"; do
fi
done
# Update __version__ in Python __init__.py files
PYTHON_INIT_FILES=(
"hindsight-api/hindsight_api/__init__.py"
"hindsight-embed/hindsight_embed/__init__.py"
"hindsight-clients/python/hindsight_client_api/__init__.py"
)
for init_file in "${PYTHON_INIT_FILES[@]}"; do
if [ -f "$init_file" ]; then
print_info "Updating __version__ in $init_file"
sed -i.bak "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" "$init_file"
rm "${init_file}.bak"
else
print_warn "File $init_file not found, skipping"
fi
done
# Update Rust CLI
CARGO_FILE="hindsight-cli/Cargo.toml"
if [ -f "$CARGO_FILE" ]; then
Generated
+5 -5
View File
@@ -1295,7 +1295,7 @@ wheels = [
[[package]]
name = "hindsight-all"
version = "0.3.0"
version = "0.4.0"
source = { editable = "hindsight" }
dependencies = [
{ name = "hindsight-api" },
@@ -1319,7 +1319,7 @@ provides-extras = ["test"]
[[package]]
name = "hindsight-api"
version = "0.3.0"
version = "0.4.0"
source = { editable = "hindsight-api" }
dependencies = [
{ name = "aiohttp" },
@@ -1447,7 +1447,7 @@ dev = [
[[package]]
name = "hindsight-client"
version = "0.3.0"
version = "0.4.0"
source = { editable = "hindsight-clients/python" }
dependencies = [
{ name = "aiohttp" },
@@ -1481,7 +1481,7 @@ provides-extras = ["test"]
[[package]]
name = "hindsight-dev"
version = "0.3.0"
version = "0.4.0"
source = { editable = "hindsight-dev" }
dependencies = [
{ name = "hindsight-api" },
@@ -1527,7 +1527,7 @@ dev = [
[[package]]
name = "hindsight-embed"
version = "0.3.0"
version = "0.4.0"
source = { editable = "hindsight-embed" }
dependencies = [
{ name = "httpx" },