nucliadb 6.3.4.post3796__py3-none-any.whl → 6.3.4.post3799__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.
@@ -502,11 +502,12 @@ class KnowledgeBox:
502
502
  shard_manager = get_shard_manager()
503
503
  await shard_manager.create_vectorset(self.kbid, config)
504
504
 
505
- async def delete_vectorset(self, vectorset_id: str):
506
- vectorset_count = await datamanagers.vectorsets.count(self.txn, kbid=self.kbid)
507
- if vectorset_count == 1:
508
- raise VectorSetConflict("Deletion of your last vectorset is not allowed")
505
+ async def vectorset_marked_for_deletion(self, vectorset_id: str) -> bool:
506
+ key = KB_VECTORSET_TO_DELETE.format(kbid=self.kbid, vectorset=vectorset_id)
507
+ value = await self.txn.get(key)
508
+ return value is not None
509
509
 
510
+ async def delete_vectorset(self, vectorset_id: str):
510
511
  deleted = await datamanagers.vectorsets.delete(
511
512
  self.txn, kbid=self.kbid, vectorset_id=vectorset_id
512
513
  )
@@ -514,6 +515,10 @@ class KnowledgeBox:
514
515
  # already deleted
515
516
  return
516
517
 
518
+ vectorset_count = await datamanagers.vectorsets.count(self.txn, kbid=self.kbid)
519
+ if vectorset_count == 0:
520
+ raise VectorSetConflict("Deletion of your last vectorset is not allowed")
521
+
517
522
  # mark vectorset for async deletion
518
523
  deletion_mark_key = KB_VECTORSET_TO_DELETE.format(kbid=self.kbid, vectorset=vectorset_id)
519
524
  payload = VectorSetPurge(storage_key_kind=deleted.storage_key_kind)
@@ -58,16 +58,23 @@ async def add_vectorset(request: Request, kbid: str, vectorset_id: str) -> Creat
58
58
  detail=err.content,
59
59
  )
60
60
 
61
- except VectorSetConflict:
61
+ except VectorSetConflict as err:
62
62
  raise HTTPException(
63
63
  status_code=409,
64
- detail="A vectorset with this embedding model already exists in your KB",
64
+ detail=str(err),
65
65
  )
66
66
 
67
67
  return CreatedVectorSet(id=vectorset_id)
68
68
 
69
69
 
70
70
  async def _add_vectorset(kbid: str, vectorset_id: str) -> None:
71
+ storage = await get_storage()
72
+
73
+ async with datamanagers.with_ro_transaction() as txn:
74
+ kbobj = KnowledgeBox(txn, storage, kbid)
75
+ if await kbobj.vectorset_marked_for_deletion(vectorset_id):
76
+ raise VectorSetConflict("Vectorset is already being deleted. Please try again later.")
77
+
71
78
  # First off, add the vectorset to the learning configuration if it's not already there
72
79
  lconfig = await learning_proxy.get_configuration(kbid)
73
80
  assert lconfig is not None
@@ -79,7 +86,6 @@ async def _add_vectorset(kbid: str, vectorset_id: str) -> None:
79
86
  assert lconfig is not None
80
87
 
81
88
  # Then, add the vectorset to the index if it's not already there
82
- storage = await get_storage()
83
89
  vectorset_config = get_vectorset_config(lconfig, vectorset_id)
84
90
  async with datamanagers.with_rw_transaction() as txn:
85
91
  kbobj = KnowledgeBox(txn, storage, kbid)
@@ -275,7 +275,7 @@ class GCloudFileStorageManager(FileStorageManager):
275
275
  data = {"text": text}
276
276
  if resp.status not in (200, 204, 404):
277
277
  if resp.status == 404:
278
- logger.error(
278
+ logger.debug(
279
279
  f"Attempt to delete not found gcloud: {data}, status: {resp.status}",
280
280
  exc_info=True,
281
281
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.3.4.post3796
3
+ Version: 6.3.4.post3799
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.4.post3796
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3796
25
- Requires-Dist: nucliadb-protos>=6.3.4.post3796
26
- Requires-Dist: nucliadb-models>=6.3.4.post3796
27
- Requires-Dist: nidx-protos>=6.3.4.post3796
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3799
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3799
25
+ Requires-Dist: nucliadb-protos>=6.3.4.post3799
26
+ Requires-Dist: nucliadb-models>=6.3.4.post3799
27
+ Requires-Dist: nidx-protos>=6.3.4.post3799
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
@@ -143,7 +143,7 @@ nucliadb/ingest/orm/brain.py,sha256=A8H1J7Bo95sNzDgYr0_UNoemQhWOFEFz9UlYfs6ug-8,
143
143
  nucliadb/ingest/orm/broker_message.py,sha256=XWaiZgDOz94NPOPT-hqbRr5ZkpVimUw6PjUJNftfoVw,7514
144
144
  nucliadb/ingest/orm/entities.py,sha256=3_n6lKhBy2GsdmNmkh0_mvxP8md20OZsbtTNEmfJ8Hg,14888
145
145
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
146
- nucliadb/ingest/orm/knowledgebox.py,sha256=IGOPvBR1qXqDxE5DeiOdYCLdPgjzOVVpsASJ2zYvWwQ,23651
146
+ nucliadb/ingest/orm/knowledgebox.py,sha256=Bfb4-MIQWlaJrQAUDbgs_iIsXCYjS7s5YiiGl_Jb4jo,23887
147
147
  nucliadb/ingest/orm/metrics.py,sha256=OkwMSPKLZcKba0ZTwtTiIxwBgaLMX5ydhGieKvi2y7E,1096
148
148
  nucliadb/ingest/orm/resource.py,sha256=oFD7APhmG1A72h7DTKumZWQRpIDM0o_FytP1P-CcNq0,45918
149
149
  nucliadb/ingest/orm/utils.py,sha256=vCe_9UxHu26JDFGLwQ0wH-XyzJIpQCTK-Ow9dtZR5Vg,2716
@@ -339,7 +339,7 @@ nucliadb/writer/api/v1/services.py,sha256=3AUjk-SmvqJx76v7y89DZx6oyasojPliGYeniR
339
339
  nucliadb/writer/api/v1/slug.py,sha256=xlVBDBpRi9bNulpBHZwhyftVvulfE0zFm1XZIWl-AKY,2389
340
340
  nucliadb/writer/api/v1/transaction.py,sha256=d2Vbgnkk_-FLGSTt3vfldwiJIUf0XoyD0wP1jQNz_DY,2430
341
341
  nucliadb/writer/api/v1/upload.py,sha256=hLMHXSaqEOE-vjKjhIupgdx8klJc3mVQp_oMwx5N-7o,33800
342
- nucliadb/writer/api/v1/vectorsets.py,sha256=mESaXkkI9f-jWWMW61ZZgv7E5YWXKemyc6vwT0lFXns,6747
342
+ nucliadb/writer/api/v1/vectorsets.py,sha256=F3iMViL5G95_Tns4aO2SOA0DwAzxK2_P8MXxtd_XLRE,6973
343
343
  nucliadb/writer/resource/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
344
344
  nucliadb/writer/resource/audit.py,sha256=FvxMZPzrNHtd31HgpZEvxzwAkbxJTZRhPLqRYYJi3tA,1426
345
345
  nucliadb/writer/resource/basic.py,sha256=_zdAr110C7rtEzOKoBRMzPjAnQ0pAtRfGjB8qCzodvI,11767
@@ -349,13 +349,13 @@ nucliadb/writer/tus/__init__.py,sha256=huWpKnDnjsrKlBBJk30ta5vamlA-4x0TbPs_2Up8h
349
349
  nucliadb/writer/tus/azure.py,sha256=XhWAlWTM0vmXcXtuEPYjjeEhuZjiZXZu8q9WsJ7omFE,4107
350
350
  nucliadb/writer/tus/dm.py,sha256=bVoXqt_dpNvTjpffPYhj1JfqK6gfLoPr0hdkknUCZ9E,5488
351
351
  nucliadb/writer/tus/exceptions.py,sha256=WfZSSjsHfoy63wUFlH3QoHx7FMoCNA1oKJmWpZZDnCo,2156
352
- nucliadb/writer/tus/gcs.py,sha256=yM9GSO0mV7c6ZFqK9LpjiBNu96uf1_rofAj9R0NC7xg,14079
352
+ nucliadb/writer/tus/gcs.py,sha256=OnE-YUnp7eyfWFlnh-vlGoxEPS8cUBSSmSm6iJ1Kva0,14079
353
353
  nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,5193
354
354
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
355
355
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
356
356
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
357
- nucliadb-6.3.4.post3796.dist-info/METADATA,sha256=CAxQ5xeSrVmN4NWzZwAdBUv2q5O5cP1INsDQ14RJYdk,4291
358
- nucliadb-6.3.4.post3796.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
359
- nucliadb-6.3.4.post3796.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
- nucliadb-6.3.4.post3796.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
- nucliadb-6.3.4.post3796.dist-info/RECORD,,
357
+ nucliadb-6.3.4.post3799.dist-info/METADATA,sha256=uH02kQKeWrB090Tk5FIcFC7uOW1veqoU6D9BO4lY0os,4291
358
+ nucliadb-6.3.4.post3799.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
359
+ nucliadb-6.3.4.post3799.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
+ nucliadb-6.3.4.post3799.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
+ nucliadb-6.3.4.post3799.dist-info/RECORD,,