nucliadb 6.3.0.post3402__py3-none-any.whl → 6.3.0.post3417__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.
- migrations/pg/0004_catalog_facets.py +51 -0
- nucliadb/export_import/datamanager.py +2 -2
- nucliadb/export_import/utils.py +3 -1
- nucliadb/search/search/pgcatalog.py +2 -2
- {nucliadb-6.3.0.post3402.dist-info → nucliadb-6.3.0.post3417.dist-info}/METADATA +6 -6
- {nucliadb-6.3.0.post3402.dist-info → nucliadb-6.3.0.post3417.dist-info}/RECORD +9 -8
- {nucliadb-6.3.0.post3402.dist-info → nucliadb-6.3.0.post3417.dist-info}/WHEEL +1 -1
- {nucliadb-6.3.0.post3402.dist-info → nucliadb-6.3.0.post3417.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.3.0.post3402.dist-info → nucliadb-6.3.0.post3417.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
|
|
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
|
+
CREATE OR REPLACE FUNCTION extract_facets(facets TEXT[])
|
28
|
+
RETURNS TEXT[] AS $$
|
29
|
+
SELECT array_agg(prefix) FROM (
|
30
|
+
SELECT DISTINCT p.prefix
|
31
|
+
FROM unnest(facets) AS facet,
|
32
|
+
LATERAL (
|
33
|
+
SELECT string_agg(part, '/') OVER(ROWS UNBOUNDED PRECEDING) AS prefix
|
34
|
+
FROM regexp_split_to_table(facet, '/') AS part
|
35
|
+
) AS p
|
36
|
+
) AS s
|
37
|
+
WHERE prefix != '';
|
38
|
+
$$ LANGUAGE SQL IMMUTABLE;
|
39
|
+
""")
|
40
|
+
|
41
|
+
# Concurrent index must be created outside of a transaction but psycopg automatically
|
42
|
+
# creates transactions. We temporarily disable this for this single statement.
|
43
|
+
await txn.connection.commit()
|
44
|
+
try:
|
45
|
+
await txn.connection.set_autocommit(True)
|
46
|
+
await txn.connection.execute(
|
47
|
+
"CREATE INDEX CONCURRENTLY ON catalog USING gin (kbid, extract_facets(labels));"
|
48
|
+
)
|
49
|
+
await txn.connection.execute("ANALYZE catalog")
|
50
|
+
finally:
|
51
|
+
await txn.connection.set_autocommit(False)
|
@@ -30,7 +30,7 @@ from nucliadb_telemetry import errors
|
|
30
30
|
from nucliadb_utils.storages.storage import Storage, StorageField
|
31
31
|
|
32
32
|
MAINDB_EXPORT_KEY = "/kbs/{kbid}/exports/{id}"
|
33
|
-
|
33
|
+
MAINDB_IMPORT_KEY = "/kbs/{kbid}/imports/{id}"
|
34
34
|
STORAGE_EXPORT_KEY = "exports/{export_id}"
|
35
35
|
STORAGE_IMPORT_KEY = "imports/{import_id}"
|
36
36
|
|
@@ -49,7 +49,7 @@ class ExportImportDataManager:
|
|
49
49
|
def _get_maindb_metadata_key(self, type: str, kbid: str, id: str) -> str:
|
50
50
|
if type not in ("export", "import"):
|
51
51
|
raise ValueError(f"Invalid type: {type}")
|
52
|
-
key = MAINDB_EXPORT_KEY if type == "export" else
|
52
|
+
key = MAINDB_EXPORT_KEY if type == "export" else MAINDB_IMPORT_KEY
|
53
53
|
return key.format(kbid=kbid, id=id)
|
54
54
|
|
55
55
|
async def get_metadata(self, type: str, kbid: str, id: str) -> Metadata:
|
nucliadb/export_import/utils.py
CHANGED
@@ -134,6 +134,7 @@ async def import_binary(
|
|
134
134
|
bucket_name = context.blob_storage.get_bucket_name(kbid)
|
135
135
|
new_cf.bucket_name = bucket_name
|
136
136
|
|
137
|
+
# Replace the source kbid with the destination kbid
|
137
138
|
src_kb = cf.uri.split("/")[1]
|
138
139
|
new_cf.uri = new_cf.uri.replace(src_kb, kbid, 1)
|
139
140
|
|
@@ -235,7 +236,8 @@ def _clone_collect_cf(binaries: list[resources_pb2.CloudFile], origin: resources
|
|
235
236
|
async def download_binary(
|
236
237
|
context: ApplicationContext, cf: resources_pb2.CloudFile
|
237
238
|
) -> AsyncGenerator[bytes, None]:
|
238
|
-
|
239
|
+
bucket_name = context.blob_storage.get_bucket_name_from_cf(cf)
|
240
|
+
async for data in context.blob_storage.download(bucket_name, cf.uri):
|
239
241
|
yield data
|
240
242
|
|
241
243
|
|
@@ -61,7 +61,7 @@ def _convert_filter(filter, filter_params):
|
|
61
61
|
if op == "literal":
|
62
62
|
param_name = f"param{len(filter_params)}"
|
63
63
|
filter_params[param_name] = [operands]
|
64
|
-
return f"labels @> %({param_name})s"
|
64
|
+
return f"extract_facets(labels) @> %({param_name})s"
|
65
65
|
elif op in ("and", "or"):
|
66
66
|
array_op = "@>" if op == "and" else "&&"
|
67
67
|
sql = []
|
@@ -69,7 +69,7 @@ def _convert_filter(filter, filter_params):
|
|
69
69
|
if literals:
|
70
70
|
param_name = f"param{len(filter_params)}"
|
71
71
|
filter_params[param_name] = literals
|
72
|
-
sql.append(f"labels {array_op} %({param_name})s")
|
72
|
+
sql.append(f"extract_facets(labels) {array_op} %({param_name})s")
|
73
73
|
for nonlit in nonliterals:
|
74
74
|
sql.append(_convert_filter(nonlit, filter_params))
|
75
75
|
return "(" + f" {op.upper()} ".join(sql) + ")"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.3.0.
|
3
|
+
Version: 6.3.0.post3417
|
4
4
|
Summary: NucliaDB
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
6
6
|
License: AGPL
|
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
21
21
|
Requires-Python: <4,>=3.9
|
22
22
|
Description-Content-Type: text/markdown
|
23
|
-
Requires-Dist: nucliadb-telemetry[all]>=6.3.0.
|
24
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.0.
|
25
|
-
Requires-Dist: nucliadb-protos>=6.3.0.
|
26
|
-
Requires-Dist: nucliadb-models>=6.3.0.
|
27
|
-
Requires-Dist: nidx-protos>=6.3.0.
|
23
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.3.0.post3417
|
24
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.0.post3417
|
25
|
+
Requires-Dist: nucliadb-protos>=6.3.0.post3417
|
26
|
+
Requires-Dist: nucliadb-models>=6.3.0.post3417
|
27
|
+
Requires-Dist: nidx-protos>=6.3.0.post3417
|
28
28
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
29
29
|
Requires-Dist: nuclia-models>=0.24.2
|
30
30
|
Requires-Dist: uvicorn
|
@@ -31,6 +31,7 @@ migrations/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
|
31
31
|
migrations/pg/0001_bootstrap.py,sha256=Fsqkeof50m7fKiJN05kmNEMwiKDlOrAgcAS5sLLkutA,1256
|
32
32
|
migrations/pg/0002_catalog.py,sha256=Rsleecu351Ty19kYZgOpqX5G3MEAY8nMxCJrAeuS2Mw,1690
|
33
33
|
migrations/pg/0003_catalog_kbid_index.py,sha256=uKq_vtnuf73GVf0mtl2rhzdk_czAoEU1UdiVKVZpA0M,1044
|
34
|
+
migrations/pg/0004_catalog_facets.py,sha256=FJFASHjfEHG3sNve9BP2HnnLO4xr7dnR6Qpctnmt4LE,2180
|
34
35
|
migrations/pg/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
35
36
|
nucliadb/__init__.py,sha256=_abCmDJ_0ku483Os4UAjPX7Nywm39cQgAV_DiyjsKeQ,891
|
36
37
|
nucliadb/health.py,sha256=UIxxA4oms4HIsCRZM_SZsdkIZIlgzmOxw-qSHLlWuak,3465
|
@@ -94,13 +95,13 @@ nucliadb/common/models_utils/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJ
|
|
94
95
|
nucliadb/common/models_utils/from_proto.py,sha256=d-q6-JWvjVVxtI57itQVKRIY8Hzv-tBhDt-tr4aIKNM,15979
|
95
96
|
nucliadb/common/models_utils/to_proto.py,sha256=97JvOR_3odu50YvzLa2CERfEN3w_QPmAVcCJwJB5m5A,2438
|
96
97
|
nucliadb/export_import/__init__.py,sha256=y-Is0Bxa8TMV6UiOW0deC_D3U465P65CQ5RjBjIWnow,932
|
97
|
-
nucliadb/export_import/datamanager.py,sha256=
|
98
|
+
nucliadb/export_import/datamanager.py,sha256=ZL96M6WuyrFLcGdoM6Cb6hQwrGFRtSeRlsKuvDjV3sY,6722
|
98
99
|
nucliadb/export_import/exceptions.py,sha256=Dw8WqfG4r6MPJc5TPfbjMvCgXXWTcTOecGHRVU1h3kM,1949
|
99
100
|
nucliadb/export_import/exporter.py,sha256=kgbW-B7FNW7mlc9rBVEfwkkFTqD58TWSTDe9zkmEnBc,7098
|
100
101
|
nucliadb/export_import/importer.py,sha256=v5cq9Nn8c2zrY_K_00mydR52f8mdFxR7tLdtNLQ0qvk,4229
|
101
102
|
nucliadb/export_import/models.py,sha256=dbjScNkiMRv4X3Ktudy1JRliD25bfoDTy3JmEZgQSCc,2121
|
102
103
|
nucliadb/export_import/tasks.py,sha256=fpCBeFYPReyLIdk38LDM9Tpnw_VczeMrobT4n1RAIp4,2507
|
103
|
-
nucliadb/export_import/utils.py,sha256=
|
104
|
+
nucliadb/export_import/utils.py,sha256=t7xLA3f5W3zGq3HNXe3noOQnY7gRO8TAoe8S8BG3_so,19733
|
104
105
|
nucliadb/ingest/__init__.py,sha256=fsw3C38VP50km3R-nHL775LNGPpJ4JxqXJ2Ib1f5SqE,1011
|
105
106
|
nucliadb/ingest/app.py,sha256=n5PlZyrf-bJsrc6jMRSO4DTjGyZLb4q6EA6Y4x6TYfQ,7028
|
106
107
|
nucliadb/ingest/cache.py,sha256=w7jMMzamOmQ7gwXna6Dqm6isRNBVv6l5BTBlTxaYWjE,1005
|
@@ -222,7 +223,7 @@ nucliadb/search/search/ingestion_agents.py,sha256=NeJr4EEX-bvFFMGvXOOwLv8uU7NuQ-
|
|
222
223
|
nucliadb/search/search/merge.py,sha256=i_PTBFRqC5iTTziOMEltxLIlmokIou5hjjgR4BnoLBE,22635
|
223
224
|
nucliadb/search/search/metrics.py,sha256=81X-tahGW4n2CLvUzCPdNxNClmZqUWZjcVOGCUHoiUM,2872
|
224
225
|
nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
|
225
|
-
nucliadb/search/search/pgcatalog.py,sha256=
|
226
|
+
nucliadb/search/search/pgcatalog.py,sha256=hNZJtbke0kFz9ygz70gMMJz9NxhRPznefCad83yQPd4,8887
|
226
227
|
nucliadb/search/search/predict_proxy.py,sha256=IFI3v_ODz2_UU1XZnyaD391fE7-2C0npSmj_HmDvzS4,3123
|
227
228
|
nucliadb/search/search/query.py,sha256=j7NdAXQXSytWvf_tyqpG-Fz4AhVGI-Y5i7NPm3s7-PI,29980
|
228
229
|
nucliadb/search/search/rank_fusion.py,sha256=tRGo_KlsFsVx1CQEy1iqQ6f0T1Dq1kf0axDXHuuzvvM,6946
|
@@ -338,8 +339,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
338
339
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
339
340
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
340
341
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
341
|
-
nucliadb-6.3.0.
|
342
|
-
nucliadb-6.3.0.
|
343
|
-
nucliadb-6.3.0.
|
344
|
-
nucliadb-6.3.0.
|
345
|
-
nucliadb-6.3.0.
|
342
|
+
nucliadb-6.3.0.post3417.dist-info/METADATA,sha256=Nya_zwsp_AAX_HD3Qf6w7Hwd5UpeppIBUeCi9qqCnro,4291
|
343
|
+
nucliadb-6.3.0.post3417.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
|
344
|
+
nucliadb-6.3.0.post3417.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
345
|
+
nucliadb-6.3.0.post3417.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
346
|
+
nucliadb-6.3.0.post3417.dist-info/RECORD,,
|
File without changes
|
File without changes
|