nucliadb 6.5.0.post4415__py3-none-any.whl → 6.5.0.post4426__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ # Copyright (C) 2021 Bosutech XXI S.L.
2
+ #
3
+ # nucliadb is offered under the AGPL v3.0 and as commercial software.
4
+ # For commercial licensing, contact us at info@nuclia.com.
5
+ #
6
+ # AGPL:
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as
9
+ # published by the Free Software Foundation, either version 3 of the
10
+ # License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ """Migration #36
22
+
23
+ Backfill catalog slug field
24
+
25
+ """
26
+
27
+ import logging
28
+ from typing import cast
29
+
30
+ from nucliadb.common.maindb.pg import PGDriver, PGTransaction
31
+ from nucliadb.migrator.context import ExecutionContext
32
+
33
+ logger = logging.getLogger(__name__)
34
+
35
+
36
+ async def migrate(context: ExecutionContext) -> None:
37
+ driver = cast(PGDriver, context.kv_driver)
38
+
39
+ BATCH_SIZE = 10_000
40
+ async with driver.transaction() as txn:
41
+ txn = cast(PGTransaction, txn)
42
+ start_key = ""
43
+ while True:
44
+ async with txn.connection.cursor() as cur:
45
+ logger.info(f"Filling {BATCH_SIZE} catalog slugs from {start_key}")
46
+ # Get a batch of slugs from the resource table
47
+ await cur.execute(
48
+ """
49
+ CREATE TEMPORARY TABLE tmp_0036_backfill_catalog ON COMMIT DROP AS
50
+ SELECT
51
+ key,
52
+ SPLIT_PART(key, '/', 3)::UUID AS kbid,
53
+ SPLIT_PART(key, '/', 5) AS slug,
54
+ ENCODE(value, 'escape')::UUID AS rid
55
+ FROM resources
56
+ WHERE key ~ '^/kbs/[^/]+/s/.*'
57
+ AND key > %s
58
+ ORDER BY key
59
+ LIMIT %s
60
+ """,
61
+ (start_key, BATCH_SIZE),
62
+ )
63
+
64
+ # Set the key for next iteration
65
+ await cur.execute("SELECT MAX(key) FROM tmp_0036_backfill_catalog")
66
+ start_key = (await cur.fetchone())[0] # type: ignore
67
+ if start_key is None:
68
+ break
69
+
70
+ # Update the catalog with the slugs
71
+ await cur.execute(
72
+ """
73
+ UPDATE catalog c SET slug = tmp.slug
74
+ FROM tmp_0036_backfill_catalog tmp
75
+ WHERE c.kbid = tmp.kbid AND c.rid = tmp.rid
76
+ """
77
+ )
78
+ await txn.commit()
79
+
80
+
81
+ async def migrate_kb(context: ExecutionContext, kbid: str) -> None: ...
@@ -0,0 +1,31 @@
1
+ # Copyright (C) 2021 Bosutech XXI S.L.
2
+ #
3
+ # nucliadb is offered under the AGPL v3.0 and as commercial software.
4
+ # For commercial licensing, contact us at info@nuclia.com.
5
+ #
6
+ # AGPL:
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as
9
+ # published by the Free Software Foundation, either version 3 of the
10
+ # License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ from nucliadb.common.maindb.pg import PGTransaction
22
+
23
+
24
+ async def migrate(txn: PGTransaction) -> None:
25
+ async with txn.connection.cursor() as cur:
26
+ await cur.execute(
27
+ """
28
+ ALTER TABLE catalog ADD COLUMN slug TEXT;
29
+ CREATE INDEX ON catalog(slug);
30
+ """
31
+ )
@@ -57,14 +57,15 @@ async def pgcatalog_update(txn: Transaction, kbid: str, resource: Resource, inde
57
57
  await cur.execute(
58
58
  """
59
59
  INSERT INTO catalog
60
- (kbid, rid, title, created_at, modified_at, labels)
60
+ (kbid, rid, title, created_at, modified_at, labels, slug)
61
61
  VALUES
62
- (%(kbid)s, %(rid)s, %(title)s, %(created_at)s, %(modified_at)s, %(labels)s)
62
+ (%(kbid)s, %(rid)s, %(title)s, %(created_at)s, %(modified_at)s, %(labels)s, %(slug)s)
63
63
  ON CONFLICT (kbid, rid) DO UPDATE SET
64
64
  title = excluded.title,
65
65
  created_at = excluded.created_at,
66
66
  modified_at = excluded.modified_at,
67
- labels = excluded.labels""",
67
+ labels = excluded.labels,
68
+ slug = excluded.slug""",
68
69
  {
69
70
  "kbid": resource.kb.kbid,
70
71
  "rid": resource.uuid,
@@ -72,6 +73,7 @@ async def pgcatalog_update(txn: Transaction, kbid: str, resource: Resource, inde
72
73
  "created_at": created_at,
73
74
  "modified_at": modified_at,
74
75
  "labels": list(index_message.labels),
76
+ "slug": resource.basic.slug,
75
77
  },
76
78
  )
77
79
 
@@ -187,7 +187,7 @@ async def chat_streaming_generator(
187
187
 
188
188
  if is_json:
189
189
  try:
190
- parsed_chunk = GenerativeChunk.model_validate(chunk)
190
+ parsed_chunk = GenerativeChunk.model_validate_json(chunk).chunk
191
191
  if isinstance(parsed_chunk, TextGenerativeResponse):
192
192
  text_answer += parsed_chunk.text
193
193
  elif isinstance(parsed_chunk, JSONGenerativeResponse):
@@ -195,7 +195,7 @@ async def chat_streaming_generator(
195
195
  elif isinstance(parsed_chunk, StatusGenerativeResponse):
196
196
  status_code = parsed_chunk.code
197
197
  except ValidationError:
198
- logger.warning(
198
+ logger.exception(
199
199
  f"Unexpected item in predict answer stream: {chunk.decode()}",
200
200
  extra={"kbid": kbid},
201
201
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.5.0.post4415
3
+ Version: 6.5.0.post4426
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -19,11 +19,11 @@ Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Requires-Python: <4,>=3.9
21
21
  Description-Content-Type: text/markdown
22
- Requires-Dist: nucliadb-telemetry[all]>=6.5.0.post4415
23
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.5.0.post4415
24
- Requires-Dist: nucliadb-protos>=6.5.0.post4415
25
- Requires-Dist: nucliadb-models>=6.5.0.post4415
26
- Requires-Dist: nidx-protos>=6.5.0.post4415
22
+ Requires-Dist: nucliadb-telemetry[all]>=6.5.0.post4426
23
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.5.0.post4426
24
+ Requires-Dist: nucliadb-protos>=6.5.0.post4426
25
+ Requires-Dist: nucliadb-models>=6.5.0.post4426
26
+ Requires-Dist: nidx-protos>=6.5.0.post4426
27
27
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
28
28
  Requires-Dist: nuclia-models>=0.24.2
29
29
  Requires-Dist: uvicorn[standard]
@@ -31,6 +31,7 @@ migrations/0032_remove_old_relations.py,sha256=ZaswhmRRsLgw6DVYVdT7cP-gdBf4X3PL9
31
31
  migrations/0033_rollover_nidx_relation_2.py,sha256=9etpqNLVS3PA14qIdsdhorReZxenDaBl-IJNN2AK_Fg,1340
32
32
  migrations/0034_rollover_nidx_texts_3.py,sha256=t19QtWUgHxmTaBPoR1DooAby2IYmkLTQj8qu1z2XkFc,1452
33
33
  migrations/0035_rollover_nidx_texts_4.py,sha256=W0_AUd01pjMpYMDC3yqF6HzDLgcnnPprL80kfyb1WZI,1187
34
+ migrations/0036_backfill_catalog_slug.py,sha256=mizRM-HfPswKq4iEmqofu4kIT6Gd97ruT3qhb257vZk,2954
34
35
  migrations/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
35
36
  migrations/pg/0001_bootstrap.py,sha256=Fsqkeof50m7fKiJN05kmNEMwiKDlOrAgcAS5sLLkutA,1256
36
37
  migrations/pg/0002_catalog.py,sha256=Rsleecu351Ty19kYZgOpqX5G3MEAY8nMxCJrAeuS2Mw,1690
@@ -38,6 +39,7 @@ migrations/pg/0003_catalog_kbid_index.py,sha256=uKq_vtnuf73GVf0mtl2rhzdk_czAoEU1
38
39
  migrations/pg/0004_catalog_facets.py,sha256=FJFASHjfEHG3sNve9BP2HnnLO4xr7dnR6Qpctnmt4LE,2180
39
40
  migrations/pg/0005_purge_tasks_index.py,sha256=3mtyFgpcK0QQ_NONYay7V9xICijCLNkyTPuoc0PBjRg,1139
40
41
  migrations/pg/0006_catalog_title_indexes.py,sha256=n2OGxwE4oeCwHAYaxBkja4t10BmwTjZ2IoCyOdjEBSc,1710
42
+ migrations/pg/0007_catalog_slug.py,sha256=mArzZCBO-RD5DkWxRIyDKgEzrnAcis1TOGvSNUe7Kgg,1150
41
43
  migrations/pg/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
42
44
  nucliadb/__init__.py,sha256=_abCmDJ_0ku483Os4UAjPX7Nywm39cQgAV_DiyjsKeQ,891
43
45
  nucliadb/health.py,sha256=UIxxA4oms4HIsCRZM_SZsdkIZIlgzmOxw-qSHLlWuak,3465
@@ -162,7 +164,7 @@ nucliadb/ingest/orm/utils.py,sha256=fCQRuyecgqhaY7mcBG93oaXMkzkKb9BFjOcy4-ZiSNw,
162
164
  nucliadb/ingest/orm/processor/__init__.py,sha256=Aqd9wCNTvggkMkCY3WvoI8spdr94Jnqk-0iq9XpLs18,922
163
165
  nucliadb/ingest/orm/processor/auditing.py,sha256=TeYhXGJRyQ7ROytbb2u8R0fIh_FYi3HgTu3S1ribY3U,4623
164
166
  nucliadb/ingest/orm/processor/data_augmentation.py,sha256=v-pj4GbBWSuO8dQyahs5UDr5ghsyfhCZDS0ftKd6ZYc,5179
165
- nucliadb/ingest/orm/processor/pgcatalog.py,sha256=ht9_I5WlPc6sSFTY8PsxHlpjN-EsaBaChwqsLlMXwUk,3100
167
+ nucliadb/ingest/orm/processor/pgcatalog.py,sha256=Zh6s0gj_bwDKPBXSs61jlMKJ6XP-dLnPGbrMGD6RHcM,3195
166
168
  nucliadb/ingest/orm/processor/processor.py,sha256=jaEBwbv--WyoC8zcdxWAyF0dAzVA5crVDJl56Bqv1eI,31444
167
169
  nucliadb/ingest/orm/processor/sequence_manager.py,sha256=uqEphtI1Ir_yk9jRl2gPf7BlzzXWovbARY5MNZSBI_8,1704
168
170
  nucliadb/ingest/service/__init__.py,sha256=LHQFUkdmNBOWqBG0Md9sMMI7g5TQZ-hLAnhw6ZblrJg,2002
@@ -250,7 +252,7 @@ nucliadb/search/search/merge.py,sha256=XiRBsxhYPshPV7lZXD-9E259KZOPIf4I2tKosY0lP
250
252
  nucliadb/search/search/metrics.py,sha256=3I6IN0qDSmqIvUaWJmT3rt-Jyjs6LcvnKI8ZqCiuJPY,3501
251
253
  nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
252
254
  nucliadb/search/search/pgcatalog.py,sha256=QtgArjoM-dW_B1oO0aXqp5au7GlLG8jAct9jevUHatw,10997
253
- nucliadb/search/search/predict_proxy.py,sha256=2451FR2DJLedA4eV8KbMbY4la5WZCgjBUHO_iQVaA8I,8634
255
+ nucliadb/search/search/predict_proxy.py,sha256=cuD_sfM3RLdEoQaanRz0CflO6nKVGGKPzoFA17shb_w,8647
254
256
  nucliadb/search/search/query.py,sha256=0qIQdt548L3jtKOyKo06aGJ73SLBxAW3N38_Hc1M3Uw,11528
255
257
  nucliadb/search/search/rank_fusion.py,sha256=xZtXhbmKb_56gs73u6KkFm2efvTATOSMmpOV2wrAIqE,9613
256
258
  nucliadb/search/search/rerankers.py,sha256=E2J1QdKAojqbhHM3KAyaOXKf6tJyETUxKs4tf_BEyqk,7472
@@ -370,8 +372,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
370
372
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
371
373
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
372
374
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
373
- nucliadb-6.5.0.post4415.dist-info/METADATA,sha256=lSbgbK7GgTJXjm5IIzYAeFt7-W8LdME3CKarZjmQwbg,4152
374
- nucliadb-6.5.0.post4415.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
375
- nucliadb-6.5.0.post4415.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
376
- nucliadb-6.5.0.post4415.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
377
- nucliadb-6.5.0.post4415.dist-info/RECORD,,
375
+ nucliadb-6.5.0.post4426.dist-info/METADATA,sha256=fRo_rQ3D5zAGctuqOfk22MzKACI4nZ8mijFy-JSGaT0,4152
376
+ nucliadb-6.5.0.post4426.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
377
+ nucliadb-6.5.0.post4426.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
378
+ nucliadb-6.5.0.post4426.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
379
+ nucliadb-6.5.0.post4426.dist-info/RECORD,,