mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
chore: fix ruff violations — unused imports, Path, dead code, formatting
This commit is contained in:
parent
4c5d981fff
commit
0fd5227355
2 changed files with 29 additions and 53 deletions
|
|
@ -1,10 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
|
||||
from pathlib import Path
|
||||
|
||||
from paperforge import __version__ as PF_VERSION
|
||||
from paperforge.core.errors import ErrorCode
|
||||
|
|
@ -17,8 +19,6 @@ from paperforge.embedding import (
|
|||
)
|
||||
from paperforge.embedding.builder import (
|
||||
PaperEmbeddingJob,
|
||||
embed_body_units,
|
||||
embed_object_units,
|
||||
encode_paper_job,
|
||||
get_body_units_for_embedding,
|
||||
get_object_units_for_embedding,
|
||||
|
|
@ -26,7 +26,6 @@ from paperforge.embedding.builder import (
|
|||
write_encoded_payload,
|
||||
)
|
||||
from paperforge.embedding.preflight import _preflight_check
|
||||
from paperforge.memory.chunker import chunk_fulltext
|
||||
from paperforge.memory.db import get_connection, get_memory_db_path
|
||||
from paperforge.memory.state_snapshot import write_vector_runtime
|
||||
from paperforge.retrieval.manifest import RETRIEVAL_POLICY_VERSION, compute_body_units_hash, compute_object_units_hash
|
||||
|
|
@ -81,25 +80,6 @@ def _pid_alive(pid: int) -> bool:
|
|||
except Exception:
|
||||
return False
|
||||
|
||||
def _assert_collections_healthy(vault: Path) -> tuple[bool, str]:
|
||||
"""Probe sqlite-vec companion tables: connectivity + metadata accessibility."""
|
||||
from paperforge.memory.db import ensure_vec_extension, get_connection, get_memory_db_path
|
||||
from paperforge.memory.schema import ensure_schema
|
||||
|
||||
db_path = get_memory_db_path(vault)
|
||||
if not db_path.exists():
|
||||
return False, "paperforge.db not found"
|
||||
conn = get_connection(db_path)
|
||||
try:
|
||||
ensure_vec_extension(conn)
|
||||
ensure_schema(conn)
|
||||
for meta_table in ["vec_fulltext_meta", "vec_body_meta", "vec_objects_meta"]:
|
||||
conn.execute(f"SELECT COUNT(*) FROM {meta_table}").fetchone()
|
||||
except Exception as exc:
|
||||
return False, f"{meta_table}: {exc}"
|
||||
finally:
|
||||
conn.close()
|
||||
return True, ""
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -167,10 +147,8 @@ def run(args: argparse.Namespace) -> int:
|
|||
# Force-kill if still alive after timeout
|
||||
if _pid_alive(pid):
|
||||
import signal
|
||||
try:
|
||||
with contextlib.suppress(Exception):
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
except Exception:
|
||||
pass
|
||||
# Settle to idle, preserving progress
|
||||
_current = read_vector_build_state(vault).get("current", state.get("current", 0))
|
||||
mark_vector_build_state(vault, status="idle", current=_current, pid=0, message="")
|
||||
|
|
@ -266,9 +244,7 @@ def run(args: argparse.Namespace) -> int:
|
|||
if build_state.get("status") == "running":
|
||||
stale = False
|
||||
pid = build_state.get("pid", 0)
|
||||
if not pid:
|
||||
stale = True
|
||||
elif not _pid_alive(pid):
|
||||
if not pid or not _pid_alive(pid):
|
||||
stale = True
|
||||
else:
|
||||
started = build_state.get("started_at", "")
|
||||
|
|
@ -496,7 +472,7 @@ def run(args: argparse.Namespace) -> int:
|
|||
fulltext_rel = entry.get("fulltext_path", "")
|
||||
if not fulltext_rel:
|
||||
continue
|
||||
fulltext_path = vault / fulltext_rel
|
||||
vault / fulltext_rel
|
||||
|
||||
ocr_root = vault / "System" / "PaperForge" / "ocr" / key
|
||||
has_files = (ocr_root / "structure" / "blocks.structured.jsonl").exists() and (
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue