diracx-db 0.0.1a22__py3-none-any.whl → 0.0.1a23__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,10 +105,9 @@ class JobLoggingDB(BaseSQLDB):
105
105
 
106
106
  seqnum = {jid: seqnum for jid, seqnum in (await self.conn.execute(seqnum_stmt))}
107
107
  # IF a seqnum is not found, then assume it does not exist and the first sequence number is 1.
108
-
109
108
  # https://docs.sqlalchemy.org/en/20/orm/queryguide/dml.html#orm-bulk-insert-statements
110
109
  await self.conn.execute(
111
- insert(LoggingInfo),
110
+ LoggingInfo.__table__.insert(),
112
111
  [
113
112
  {
114
113
  "JobID": record.job_id,
@@ -118,38 +117,43 @@ class JobLoggingDB(BaseSQLDB):
118
117
  "ApplicationStatus": record.application_status[:255],
119
118
  "StatusTime": record.date,
120
119
  "StatusTimeOrder": get_epoc(record.date),
121
- "Source": record.source[:32],
120
+ "StatusSource": record.source[:32],
122
121
  }
123
122
  for record in records
124
123
  ],
125
124
  )
126
125
 
127
- async def get_records(self, job_id: int) -> list[JobStatusReturn]:
126
+ async def get_records(self, job_ids: list[int]) -> dict[int, JobStatusReturn]:
128
127
  """Returns a Status,MinorStatus,ApplicationStatus,StatusTime,Source tuple
129
128
  for each record found for job specified by its jobID in historical order.
130
129
  """
130
+ # We could potentially use a group_by here, but we need to post-process the
131
+ # results later.
131
132
  stmt = (
132
133
  select(
134
+ LoggingInfo.JobID,
133
135
  LoggingInfo.Status,
134
136
  LoggingInfo.MinorStatus,
135
137
  LoggingInfo.ApplicationStatus,
136
138
  LoggingInfo.StatusTime,
137
139
  LoggingInfo.Source,
138
140
  )
139
- .where(LoggingInfo.JobID == int(job_id))
141
+ .where(LoggingInfo.JobID.in_(job_ids))
140
142
  .order_by(LoggingInfo.StatusTimeOrder, LoggingInfo.StatusTime)
141
143
  )
142
144
  rows = await self.conn.execute(stmt)
143
145
 
144
- values = []
146
+ values = defaultdict(list)
145
147
  for (
148
+ job_id,
146
149
  status,
147
150
  minor_status,
148
151
  application_status,
149
152
  status_time,
150
153
  status_source,
151
154
  ) in rows:
152
- values.append(
155
+
156
+ values[job_id].append(
153
157
  [
154
158
  status,
155
159
  minor_status,
@@ -161,16 +165,16 @@ class JobLoggingDB(BaseSQLDB):
161
165
 
162
166
  # If no value has been set for the application status in the first place,
163
167
  # We put this status to unknown
164
- res = []
165
- if values:
166
- if values[0][2] == "idem":
167
- values[0][2] = "Unknown"
168
+ res: dict = defaultdict(list)
169
+ for job_id, history in values.items():
170
+ if history[0][2] == "idem":
171
+ history[0][2] = "Unknown"
168
172
 
169
173
  # We replace "idem" values by the value previously stated
170
- for i in range(1, len(values)):
174
+ for i in range(1, len(history)):
171
175
  for j in range(3):
172
- if values[i][j] == "idem":
173
- values[i][j] = values[i - 1][j]
176
+ if history[i][j] == "idem":
177
+ history[i][j] = history[i - 1][j]
174
178
 
175
179
  # And we replace arrays with tuples
176
180
  for (
@@ -179,8 +183,8 @@ class JobLoggingDB(BaseSQLDB):
179
183
  application_status,
180
184
  status_time,
181
185
  status_source,
182
- ) in values:
183
- res.append(
186
+ ) in history:
187
+ res[job_id].append(
184
188
  JobStatusReturn(
185
189
  Status=status,
186
190
  MinorStatus=minor_status,
@@ -435,6 +435,7 @@ async def set_job_status_bulk(
435
435
  )
436
436
 
437
437
  job_data: dict[str, str] = {}
438
+ new_status: str | None = None
438
439
  if updateTimes[-1] >= lastTime:
439
440
  new_status, new_minor, new_application = (
440
441
  returnValueOrRaise( # TODO: Catch this
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diracx-db
3
- Version: 0.0.1a22
3
+ Version: 0.0.1a23
4
4
  Summary: TODO
5
5
  License: GPL-3.0-only
6
6
  Classifier: Intended Audience :: Science/Research
@@ -16,7 +16,7 @@ diracx/db/sql/job/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
16
16
  diracx/db/sql/job/db.py,sha256=54TjRzWBgD2xhM3ljdel399xq8ro4Z0k3c7zWlXXCUI,11616
17
17
  diracx/db/sql/job/schema.py,sha256=w9Ht9LyVK-fB5T9-hYGsqifzneeG2YP123j1-Mx8Xio,4283
18
18
  diracx/db/sql/job_logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- diracx/db/sql/job_logging/db.py,sha256=AQCjtdDajYmPNpAuLsLr24BILteRYFEs9oSlH5a3wng,7509
19
+ diracx/db/sql/job_logging/db.py,sha256=RrvIptxFIVrRETxFgqXvA6OzWlA6i6M21LlSzIQcILc,7787
20
20
  diracx/db/sql/job_logging/schema.py,sha256=dD2arl-6bffeK8INT6tZ1HWEpJuYTx2iNiVzswVXXF8,812
21
21
  diracx/db/sql/pilot_agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  diracx/db/sql/pilot_agents/db.py,sha256=7-cuCbh_KhM0jlybsHMWV-W66bHsPHIVBpbuqwjncj0,1232
@@ -28,9 +28,9 @@ diracx/db/sql/task_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
28
28
  diracx/db/sql/task_queue/db.py,sha256=e6yauZO0nWaUVqjqQycH8iPO4wXLXaC82eaIq1K_KI8,9102
29
29
  diracx/db/sql/task_queue/schema.py,sha256=fvzQyCw_xWAOWTLW6Qrp1m-WzEKb0tlYmafoLTbCy1I,3222
30
30
  diracx/db/sql/utils/__init__.py,sha256=fANPhXofb3ghvnOeLXmcK33YiViJFG8gI2C-2AMArEs,15647
31
- diracx/db/sql/utils/job.py,sha256=tr_XvQJ5srjgXEJI2A2UBvfKT8JQwvChCTnqe6h8aAU,19380
32
- diracx_db-0.0.1a22.dist-info/METADATA,sha256=FATgckb58rXS0mgz0bye2reCjXcuRUKAY8-nHHU6_hE,688
33
- diracx_db-0.0.1a22.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
34
- diracx_db-0.0.1a22.dist-info/entry_points.txt,sha256=YLI4f6640bri8Ud6Jt9WNq79pSTVQAkfUasb9f75fR8,315
35
- diracx_db-0.0.1a22.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
36
- diracx_db-0.0.1a22.dist-info/RECORD,,
31
+ diracx/db/sql/utils/job.py,sha256=B5l9yVdxf67sNxo3iNmrBrIkY184tx8PjFHPij7tpns,19418
32
+ diracx_db-0.0.1a23.dist-info/METADATA,sha256=l60dT_mkn_EtQVz4HmyxW4z6CXPiJR3M3fpTA_yO9-o,688
33
+ diracx_db-0.0.1a23.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
34
+ diracx_db-0.0.1a23.dist-info/entry_points.txt,sha256=YLI4f6640bri8Ud6Jt9WNq79pSTVQAkfUasb9f75fR8,315
35
+ diracx_db-0.0.1a23.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
36
+ diracx_db-0.0.1a23.dist-info/RECORD,,