diracx-db 0.0.1a25__py3-none-any.whl → 0.0.1a27__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.
@@ -5,7 +5,7 @@ from typing import Any
5
5
  from sqlalchemy import Executable, delete, insert, literal, select, update
6
6
  from sqlalchemy.exc import IntegrityError, NoResultFound
7
7
 
8
- from diracx.core.exceptions import SandboxNotFoundError
8
+ from diracx.core.exceptions import SandboxAlreadyAssignedError, SandboxNotFoundError
9
9
  from diracx.core.models import SandboxInfo, SandboxType, UserInfo
10
10
  from diracx.db.sql.utils import BaseSQLDB, utcnow
11
11
 
@@ -135,10 +135,18 @@ class SandboxMetadataDB(BaseSQLDB):
135
135
  stmt = insert(SBEntityMapping).from_select(
136
136
  ["SBId", "EntityId", "Type"], select_sb_id
137
137
  )
138
- await self.conn.execute(stmt)
138
+ try:
139
+ await self.conn.execute(stmt)
140
+ except IntegrityError as e:
141
+ raise SandboxAlreadyAssignedError(pfn, se_name) from e
139
142
 
140
143
  stmt = update(SandBoxes).where(SandBoxes.SEPFN == pfn).values(Assigned=True)
141
144
  result = await self.conn.execute(stmt)
145
+ if result.rowcount == 0:
146
+ # If the update didn't affect any row, the sandbox doesn't exist
147
+ # It means the previous insert didn't have any effect
148
+ raise SandboxNotFoundError(pfn, se_name)
149
+
142
150
  assert result.rowcount == 1
143
151
 
144
152
  async def unassign_sandboxes_to_jobs(self, jobs_ids: list[int]) -> None:
@@ -232,7 +232,7 @@ def find_time_resolution(value):
232
232
  if isinstance(value, datetime):
233
233
  return None, value
234
234
  if match := re.fullmatch(
235
- r"\d{4}(-\d{2}(-\d{2}(([ T])\d{2}(:\d{2}(:\d{2}(\.\d{6}Z?)?)?)?)?)?)?", value
235
+ r"\d{4}(-\d{2}(-\d{2}(([ T])\d{2}(:\d{2}(:\d{2}(\.\d{1,6}Z?)?)?)?)?)?)?", value
236
236
  ):
237
237
  if match.group(6):
238
238
  precision, pattern = "SECOND", r"\1-\2-\3 \4:\5:\6"
@@ -249,7 +249,7 @@ def find_time_resolution(value):
249
249
  return (
250
250
  precision,
251
251
  re.sub(
252
- r"^(\d{4})-?(\d{2})?-?(\d{2})?[ T]?(\d{2})?:?(\d{2})?:?(\d{2})?\.?(\d{6})?Z?$",
252
+ r"^(\d{4})-?(\d{2})?-?(\d{2})?[ T]?(\d{2})?:?(\d{2})?:?(\d{2})?\.?(\d{1,6})?Z?$",
253
253
  pattern,
254
254
  value,
255
255
  ),
@@ -47,7 +47,8 @@ class date_trunc(expression.FunctionElement): # noqa: N801
47
47
  """
48
48
 
49
49
  type = DateTime()
50
- inherit_cache = True
50
+ # Cache does not work as intended with time resolution values, so we disable it
51
+ inherit_cache = False
51
52
 
52
53
  def __init__(self, *args, time_resolution, **kwargs) -> None:
53
54
  super().__init__(*args, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: diracx-db
3
- Version: 0.0.1a25
3
+ Version: 0.0.1a27
4
4
  Summary: TODO
5
5
  License: GPL-3.0-only
6
6
  Classifier: Intended Audience :: Science/Research
@@ -22,18 +22,18 @@ diracx/db/sql/pilot_agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
22
22
  diracx/db/sql/pilot_agents/db.py,sha256=7-cuCbh_KhM0jlybsHMWV-W66bHsPHIVBpbuqwjncj0,1232
23
23
  diracx/db/sql/pilot_agents/schema.py,sha256=KeWnFSpYOTrT3-_rOCFjbjNnPNXKnUZiJVsu4vv5U2U,2149
24
24
  diracx/db/sql/sandbox_metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- diracx/db/sql/sandbox_metadata/db.py,sha256=wpGPUA1KLrt9B9qJaQGZExnyeREp44jdbW3XkRX_kP0,6410
25
+ diracx/db/sql/sandbox_metadata/db.py,sha256=7dmWhrg2hD_XDgD2uA9Iao4ZvVvuoEHVGseDwhDuJFc,6817
26
26
  diracx/db/sql/sandbox_metadata/schema.py,sha256=mI-YpH6NneOQ6QiqwIwyJ4afwfoamybSlQpvaISFfPY,1431
27
27
  diracx/db/sql/task_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  diracx/db/sql/task_queue/db.py,sha256=xY8yPpCIwTC5epcyFGxAP8K9sOVybYsgoH2_QH3NHb8,9105
29
29
  diracx/db/sql/task_queue/schema.py,sha256=5efAgvNYRkLlaJ2NzRInRfmVa3tyIzQu2l0oRPy4Kzw,3258
30
30
  diracx/db/sql/utils/__init__.py,sha256=b4lLIYRFVX8PW15ekklzs5OeulA6lNEOfBOJqgIOtYY,529
31
- diracx/db/sql/utils/base.py,sha256=hAFeUKWQIOJq9w_WholaLDdDxBd-E8UVLKq99uX7aYw,12361
32
- diracx/db/sql/utils/functions.py,sha256=PFA570qkCZQdABxsz2_LBEfYUv8dln3suNHx17PHGS0,2879
31
+ diracx/db/sql/utils/base.py,sha256=JPT4EdZJ4VQ57kOIbtxD549wbCwVBC-dZ1XLmE9U_4s,12365
32
+ diracx/db/sql/utils/functions.py,sha256=2gNckXXpMBcFVIC4Liu-QUmZpBhfrMDUsEi2BIO2tV0,2964
33
33
  diracx/db/sql/utils/job.py,sha256=U_y8DZdMGU5NbQF3udA4Yg43HaKhF8YhYa-PhzYmIyI,19592
34
34
  diracx/db/sql/utils/types.py,sha256=yU-tXsu6hFGPsr9ba1n3ZjGPnHQI_06lbpkTeDCWJtg,1287
35
- diracx_db-0.0.1a25.dist-info/METADATA,sha256=nS8p6yWANvSRExxHMNva7-w75wsU6P-g4TFVCpWg0Gk,688
36
- diracx_db-0.0.1a25.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
37
- diracx_db-0.0.1a25.dist-info/entry_points.txt,sha256=YLI4f6640bri8Ud6Jt9WNq79pSTVQAkfUasb9f75fR8,315
38
- diracx_db-0.0.1a25.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
39
- diracx_db-0.0.1a25.dist-info/RECORD,,
35
+ diracx_db-0.0.1a27.dist-info/METADATA,sha256=6I2J10z8F9OB_vuvT5eMhZ1_cQB6WnNFUyLTwvrdBko,688
36
+ diracx_db-0.0.1a27.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
37
+ diracx_db-0.0.1a27.dist-info/entry_points.txt,sha256=YLI4f6640bri8Ud6Jt9WNq79pSTVQAkfUasb9f75fR8,315
38
+ diracx_db-0.0.1a27.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
39
+ diracx_db-0.0.1a27.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5