mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-27 07:25:16 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfe05aa05b |
No files matched your search
@@ -23,6 +23,7 @@ dependencies = [
|
||||
"channels~=4.2",
|
||||
"channels-redis~=4.2",
|
||||
"concurrent-log-handler~=0.9.25",
|
||||
"cryptography>=50",
|
||||
"dateparser~=1.4",
|
||||
# WARNING: django does not use semver.
|
||||
# Only patch versions are guaranteed to not introduce breaking changes.
|
||||
@@ -46,6 +47,7 @@ dependencies = [
|
||||
"flower>=2.0.1,<2.3",
|
||||
"gotenberg-client[httpx]~=1.0",
|
||||
"httpx-oauth~=0.17",
|
||||
"humanize>=4.15",
|
||||
"ijson>=3.5.1",
|
||||
"imap-tools>=1.14,<1.16",
|
||||
"jinja2~=3.1.6",
|
||||
@@ -56,10 +58,13 @@ dependencies = [
|
||||
"llama-index-embeddings-openai-like>=0.2.2",
|
||||
"llama-index-llms-ollama>=0.9.1",
|
||||
"llama-index-llms-openai-like>=0.7.1",
|
||||
"lxml>=6.1",
|
||||
"ocrmypdf[heic]>=17.12,<17.13",
|
||||
"ollama>=0.6.1",
|
||||
"openai>=2.48",
|
||||
"pathvalidate~=3.3.1",
|
||||
"pdf2image~=1.17.0",
|
||||
"pikepdf>=10.13",
|
||||
"python-dateutil~=2.9.0",
|
||||
"python-dotenv~=1.2.1",
|
||||
"python-gnupg~=0.5.4",
|
||||
|
||||
@@ -1256,36 +1256,3 @@ class TestIndexPageSize:
|
||||
|
||||
assert page_size_of(legacy_page_size_db) == DB_PAGE_SIZE
|
||||
assert DocumentChunksTable.count(store.client) == 2
|
||||
|
||||
|
||||
def test_open_connection_closes_connection_when_setup_fails(
|
||||
tmp_path: Path,
|
||||
mocker: MockerFixture,
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN a table setup step that fails after the connection was opened
|
||||
WHEN the store is created
|
||||
THEN the setup error propagates
|
||||
AND the connection that was opened is closed, not leaked
|
||||
"""
|
||||
opened: list[sqlite3.Connection] = []
|
||||
real_connect = sqlite3.connect
|
||||
|
||||
def recording_connect(*args, **kwargs) -> sqlite3.Connection:
|
||||
conn = real_connect(*args, **kwargs)
|
||||
opened.append(conn)
|
||||
return conn
|
||||
|
||||
mocker.patch("paperless_ai.vector_store.sqlite3.connect", recording_connect)
|
||||
mocker.patch.object(
|
||||
DocumentMetaTable,
|
||||
"create",
|
||||
side_effect=RuntimeError("setup failed"),
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError, match="setup failed"):
|
||||
PaperlessSqliteVecVectorStore(uri=str(tmp_path))
|
||||
|
||||
assert len(opened) == 1
|
||||
with pytest.raises(sqlite3.ProgrammingError):
|
||||
opened[0].execute("SELECT 1")
|
||||
@@ -4,7 +4,6 @@ import sqlite3
|
||||
import struct
|
||||
from collections.abc import Iterator
|
||||
from collections.abc import Sequence
|
||||
from contextlib import ExitStack
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from types import TracebackType
|
||||
@@ -213,38 +212,33 @@ class PaperlessSqliteVecVectorStore(BasePydanticVectorStore):
|
||||
|
||||
@staticmethod
|
||||
def _open_connection(db_path: str) -> sqlite3.Connection:
|
||||
with ExitStack() as stack:
|
||||
conn = sqlite3.connect(
|
||||
db_path,
|
||||
timeout=30,
|
||||
isolation_level=None, # autocommit; explicit transactions below
|
||||
)
|
||||
# Closes the connection (and its WAL/SHM handles) if any setup step
|
||||
# below raises. pop_all() disarms it once setup has succeeded.
|
||||
stack.callback(conn.close)
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.enable_load_extension(True) # noqa: FBT003
|
||||
sqlite_vec.load(conn)
|
||||
conn.enable_load_extension(False) # noqa: FBT003
|
||||
conn.execute(f"PRAGMA page_size={DB_PAGE_SIZE}")
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
conn.execute("PRAGMA synchronous=NORMAL")
|
||||
IndexMetaTable.create(conn)
|
||||
# vec0 metadata columns only get an efficient lookup path inside a
|
||||
# KNN (MATCH) query; a plain `WHERE document_id = ?` is a full table
|
||||
# scan regardless of index size. This plain, indexed table is how
|
||||
# delete()/upsert_document() find a document's chunk ids without
|
||||
# that scan.
|
||||
DocumentChunksTable.create(conn)
|
||||
# modified used to be a vec0 metadata column, but vec0 only inlines
|
||||
# TEXT metadata up to 12 bytes -- an ISO timestamp is always longer,
|
||||
# so every read recompiled and stepped a fresh SQL statement per row.
|
||||
# It was never filtered on inside a KNN query either, so it never
|
||||
# needed to be a vec0 column at all. One row per document here (not
|
||||
# per chunk, like document_chunks), since every chunk of a document
|
||||
# shares the same modified value -- see get_modified_times().
|
||||
DocumentMetaTable.create(conn)
|
||||
stack.pop_all()
|
||||
conn = sqlite3.connect(
|
||||
db_path,
|
||||
timeout=30,
|
||||
isolation_level=None, # autocommit; explicit transactions below
|
||||
)
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.enable_load_extension(True) # noqa: FBT003
|
||||
sqlite_vec.load(conn)
|
||||
conn.enable_load_extension(False) # noqa: FBT003
|
||||
conn.execute(f"PRAGMA page_size={DB_PAGE_SIZE}")
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
conn.execute("PRAGMA synchronous=NORMAL")
|
||||
IndexMetaTable.create(conn)
|
||||
# vec0 metadata columns only get an efficient lookup path inside a
|
||||
# KNN (MATCH) query; a plain `WHERE document_id = ?` is a full table
|
||||
# scan regardless of index size. This plain, indexed table is how
|
||||
# delete()/upsert_document() find a document's chunk ids without
|
||||
# that scan.
|
||||
DocumentChunksTable.create(conn)
|
||||
# modified used to be a vec0 metadata column, but vec0 only inlines
|
||||
# TEXT metadata up to 12 bytes -- an ISO timestamp is always longer,
|
||||
# so every read recompiled and stepped a fresh SQL statement per row.
|
||||
# It was never filtered on inside a KNN query either, so it never
|
||||
# needed to be a vec0 column at all. One row per document here (not
|
||||
# per chunk, like document_chunks), since every chunk of a document
|
||||
# shares the same modified value -- see get_modified_times().
|
||||
DocumentMetaTable.create(conn)
|
||||
return conn
|
||||
|
||||
@property
|
||||
|
||||
@@ -2516,6 +2516,7 @@ dependencies = [
|
||||
{ name = "channels" },
|
||||
{ name = "channels-redis" },
|
||||
{ name = "concurrent-log-handler" },
|
||||
{ name = "cryptography" },
|
||||
{ name = "dateparser" },
|
||||
{ name = "django" },
|
||||
{ name = "django-allauth", extra = ["mfa", "socialaccount"] },
|
||||
@@ -2537,6 +2538,7 @@ dependencies = [
|
||||
{ name = "flower" },
|
||||
{ name = "gotenberg-client", extra = ["httpx"] },
|
||||
{ name = "httpx-oauth" },
|
||||
{ name = "humanize" },
|
||||
{ name = "ijson" },
|
||||
{ name = "imap-tools" },
|
||||
{ name = "jinja2" },
|
||||
@@ -2547,10 +2549,13 @@ dependencies = [
|
||||
{ name = "llama-index-embeddings-openai-like" },
|
||||
{ name = "llama-index-llms-ollama" },
|
||||
{ name = "llama-index-llms-openai-like" },
|
||||
{ name = "lxml" },
|
||||
{ name = "ocrmypdf", extra = ["heic"] },
|
||||
{ name = "ollama" },
|
||||
{ name = "openai" },
|
||||
{ name = "pathvalidate" },
|
||||
{ name = "pdf2image" },
|
||||
{ name = "pikepdf" },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "python-gnupg" },
|
||||
@@ -2668,6 +2673,7 @@ requires-dist = [
|
||||
{ name = "channels", specifier = "~=4.2" },
|
||||
{ name = "channels-redis", specifier = "~=4.2" },
|
||||
{ name = "concurrent-log-handler", specifier = "~=0.9.25" },
|
||||
{ name = "cryptography", specifier = ">=50.0.0" },
|
||||
{ name = "dateparser", specifier = "~=1.4" },
|
||||
{ name = "django", specifier = "~=5.2.18" },
|
||||
{ name = "django-allauth", extras = ["mfa", "socialaccount"], specifier = "~=65.21.1" },
|
||||
@@ -2690,6 +2696,7 @@ requires-dist = [
|
||||
{ name = "gotenberg-client", extras = ["httpx"], specifier = "~=1.0" },
|
||||
{ name = "granian", extras = ["uvloop"], marker = "extra == 'webserver'", specifier = ">=2.7,<2.9" },
|
||||
{ name = "httpx-oauth", specifier = "~=0.17" },
|
||||
{ name = "humanize", specifier = ">=4.15.0" },
|
||||
{ name = "ijson", specifier = ">=3.5.1" },
|
||||
{ name = "imap-tools", specifier = ">=1.14,<1.16" },
|
||||
{ name = "jinja2", specifier = "~=3.1.6" },
|
||||
@@ -2700,11 +2707,14 @@ requires-dist = [
|
||||
{ name = "llama-index-embeddings-openai-like", specifier = ">=0.2.2" },
|
||||
{ name = "llama-index-llms-ollama", specifier = ">=0.9.1" },
|
||||
{ name = "llama-index-llms-openai-like", specifier = ">=0.7.1" },
|
||||
{ name = "lxml", specifier = ">=6.1.0" },
|
||||
{ name = "mysqlclient", marker = "extra == 'mariadb'", specifier = ">=2.2.7,<2.4" },
|
||||
{ name = "ocrmypdf", extras = ["heic"], specifier = ">=17.12,<17.13" },
|
||||
{ name = "ollama", specifier = ">=0.6.1" },
|
||||
{ name = "openai", specifier = ">=2.48" },
|
||||
{ name = "pathvalidate", specifier = "~=3.3.1" },
|
||||
{ name = "pdf2image", specifier = "~=1.17.0" },
|
||||
{ name = "pikepdf", specifier = ">=10.13" },
|
||||
{ name = "psycopg", extras = ["c", "pool"], marker = "extra == 'postgres'", specifier = "==3.3.8" },
|
||||
{ name = "psycopg-c", marker = "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp312-cp312-manylinux_2_38_aarch64.whl" },
|
||||
{ name = "psycopg-c", marker = "python_full_version == '3.14.*' and platform_machine == 'aarch64' and sys_platform == 'linux' and extra == 'postgres'", url = "https://github.com/paperless-ngx/builder/releases/download/psycopg-trixie-3.3.8/psycopg_c-3.3.8-cp314-cp314-manylinux_2_38_aarch64.whl" },
|
||||
|
||||
Reference in new issue
Block a user