python3Packages.llm: 0.30 -> 0.31.1

This commit is contained in:
Lein Matsumaru
2026-07-11 08:28:12 +00:00
parent 1b5f703ee5
commit bc0681ea1e
2 changed files with 75 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
fetchpatch2,
pytestCheckHook,
replaceVars,
setuptools,
@@ -167,7 +168,7 @@ let
llm = buildPythonPackage rec {
pname = "llm";
version = "0.30";
version = "0.31.1";
pyproject = true;
build-system = [ setuptools ];
@@ -176,11 +177,17 @@ let
owner = "simonw";
repo = "llm";
tag = version;
hash = "sha256-+8fwx7sS1vFSTqb+p2uDLqWW/UIx8WoW3kYJihznRRg=";
hash = "sha256-XxQ6IQyuO1rxQtiyb4VGrM7uGoffuNN5BhyI4YDxnZg=";
};
patches = [
./001-disable-install-uninstall-commands.patch
# Remove when https://github.com/simonw/llm/pull/1525 gets merged.
./do-not-commit-inside-content_hash-embeddings.patch
(fetchpatch2 {
url = "https://github.com/simonw/llm/commit/67adad2c10be5c1898e3e1a664adb573f5d032cf.patch";
hash = "sha256-7+sBQvef94ZTUrqNKVzHzjFADNj1KNzA2tbGs5btwNA=";
})
]
# See https://github.com/NixOS/nixpkgs/issues/476258 and https://github.com/simonw/llm/pull/1334
# TODO: Remove when sqlite 3.52.x is released.

View File

@@ -0,0 +1,66 @@
From db03b44068e71f5266b720eb68ecae50e3e14303 Mon Sep 17 00:00:00 2001
From: Ewerton Silva <ewertoncom297@gmail.com>
Date: Sat, 11 Jul 2026 23:50:58 -0300
Subject: [PATCH] fix: do not commit inside the content_hash embeddings
migration
---
llm/embeddings_migrations.py | 21 ++++++++++-----------
tests/test_migrate.py | 12 ++++++++++++
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/llm/embeddings_migrations.py b/llm/embeddings_migrations.py
index 96444bd65..595a692d9 100644
--- a/llm/embeddings_migrations.py
+++ b/llm/embeddings_migrations.py
@@ -62,17 +62,16 @@ def random_md5():
db.conn.create_function("temp_md5", 1, md5)
db.conn.create_function("temp_random_md5", 0, random_md5)
- with db.conn:
- db.execute("""
- update embeddings
- set content_hash = temp_md5(content)
- where content is not null
- """)
- db.execute("""
- update embeddings
- set content_hash = temp_random_md5()
- where content is null
- """)
+ db.execute("""
+ update embeddings
+ set content_hash = temp_md5(content)
+ where content is not null
+ """)
+ db.execute("""
+ update embeddings
+ set content_hash = temp_random_md5()
+ where content is null
+ """)
db["embeddings"].create_index(["content_hash"])
diff --git a/tests/test_migrate.py b/tests/test_migrate.py
index 705021100..e74b1554b 100644
--- a/tests/test_migrate.py
+++ b/tests/test_migrate.py
@@ -117,6 +117,18 @@ def test_migrations_for_embeddings():
assert db["embeddings"].foreign_keys[0].other_table == "collections"
+@pytest.mark.skipif(
+ not hasattr(sqlite_utils.Database, "atomic"),
+ reason="sqlite-utils 4 and higher run each migration inside a transaction",
+)
+def test_embeddings_migrations_do_not_commit():
+ # https://github.com/simonw/llm/issues/1523
+ db = sqlite_utils.Database(memory=True)
+ for migration in embeddings_migrations.pending(db):
+ with db.atomic():
+ migration.fn(db)
+
+
def test_backfill_content_hash():
db = sqlite_utils.Database(memory=True)
# Run migrations up to but not including m004_store_content_hash