flwr-nightly 1.12.0.dev20241008__py3-none-any.whl → 1.12.0.dev20241009__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.
Potentially problematic release.
This version of flwr-nightly might be problematic. Click here for more details.
- flwr/server/superlink/state/in_memory_state.py +25 -0
- flwr/server/superlink/state/sqlite_state.py +41 -1
- {flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/METADATA +1 -1
- {flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/RECORD +7 -7
- {flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/entry_points.txt +0 -0
|
@@ -116,6 +116,7 @@ class InMemoryState(State): # pylint: disable=R0902,R0904
|
|
|
116
116
|
# Return TaskIns
|
|
117
117
|
return task_ins_list
|
|
118
118
|
|
|
119
|
+
# pylint: disable=R0911
|
|
119
120
|
def store_task_res(self, task_res: TaskRes) -> Optional[UUID]:
|
|
120
121
|
"""Store one TaskRes."""
|
|
121
122
|
# Validate task
|
|
@@ -129,6 +130,17 @@ class InMemoryState(State): # pylint: disable=R0902,R0904
|
|
|
129
130
|
task_ins_id = task_res.task.ancestry[0]
|
|
130
131
|
task_ins = self.task_ins_store.get(UUID(task_ins_id))
|
|
131
132
|
|
|
133
|
+
# Ensure that the consumer_id of taskIns matches the producer_id of taskRes.
|
|
134
|
+
if (
|
|
135
|
+
task_ins
|
|
136
|
+
and task_res
|
|
137
|
+
and not (
|
|
138
|
+
task_ins.task.consumer.anonymous or task_res.task.producer.anonymous
|
|
139
|
+
)
|
|
140
|
+
and task_ins.task.consumer.node_id != task_res.task.producer.node_id
|
|
141
|
+
):
|
|
142
|
+
return None
|
|
143
|
+
|
|
132
144
|
if task_ins is None:
|
|
133
145
|
log(ERROR, "TaskIns with task_id %s does not exist.", task_ins_id)
|
|
134
146
|
return None
|
|
@@ -189,6 +201,19 @@ class InMemoryState(State): # pylint: disable=R0902,R0904
|
|
|
189
201
|
replied_task_ids: set[UUID] = set()
|
|
190
202
|
for _, task_res in self.task_res_store.items():
|
|
191
203
|
reply_to = UUID(task_res.task.ancestry[0])
|
|
204
|
+
|
|
205
|
+
# Check if corresponding TaskIns exists and is not expired
|
|
206
|
+
task_ins = self.task_ins_store.get(reply_to)
|
|
207
|
+
if task_ins is None:
|
|
208
|
+
log(WARNING, "TaskIns with task_id %s does not exist.", reply_to)
|
|
209
|
+
task_ids.remove(reply_to)
|
|
210
|
+
continue
|
|
211
|
+
|
|
212
|
+
if task_ins.task.created_at + task_ins.task.ttl <= time.time():
|
|
213
|
+
log(WARNING, "TaskIns with task_id %s is expired.", reply_to)
|
|
214
|
+
task_ids.remove(reply_to)
|
|
215
|
+
continue
|
|
216
|
+
|
|
192
217
|
if reply_to in task_ids and task_res.task.delivered_at == "":
|
|
193
218
|
task_res_list.append(task_res)
|
|
194
219
|
replied_task_ids.add(reply_to)
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# ==============================================================================
|
|
15
15
|
"""SQLite based implemenation of server state."""
|
|
16
16
|
|
|
17
|
+
# pylint: disable=too-many-lines
|
|
17
18
|
|
|
18
19
|
import json
|
|
19
20
|
import re
|
|
@@ -389,6 +390,16 @@ class SqliteState(State): # pylint: disable=R0904
|
|
|
389
390
|
)
|
|
390
391
|
return None
|
|
391
392
|
|
|
393
|
+
# Ensure that the consumer_id of taskIns matches the producer_id of taskRes.
|
|
394
|
+
if (
|
|
395
|
+
task_ins
|
|
396
|
+
and task_res
|
|
397
|
+
and not (task_ins["consumer_anonymous"] or task_res.task.producer.anonymous)
|
|
398
|
+
and convert_sint64_to_uint64(task_ins["consumer_node_id"])
|
|
399
|
+
!= task_res.task.producer.node_id
|
|
400
|
+
):
|
|
401
|
+
return None
|
|
402
|
+
|
|
392
403
|
# Fail if the TaskRes TTL exceeds the
|
|
393
404
|
# expiration time of the TaskIns it replies to.
|
|
394
405
|
# Condition: TaskIns.created_at + TaskIns.ttl ≥
|
|
@@ -432,7 +443,7 @@ class SqliteState(State): # pylint: disable=R0904
|
|
|
432
443
|
|
|
433
444
|
return task_id
|
|
434
445
|
|
|
435
|
-
# pylint: disable-next=R0914
|
|
446
|
+
# pylint: disable-next=R0912,R0915,R0914
|
|
436
447
|
def get_task_res(self, task_ids: set[UUID], limit: Optional[int]) -> list[TaskRes]:
|
|
437
448
|
"""Get TaskRes for task_ids.
|
|
438
449
|
|
|
@@ -451,6 +462,35 @@ class SqliteState(State): # pylint: disable=R0904
|
|
|
451
462
|
if limit is not None and limit < 1:
|
|
452
463
|
raise AssertionError("`limit` must be >= 1")
|
|
453
464
|
|
|
465
|
+
# Check if corresponding TaskIns exists and is not expired
|
|
466
|
+
task_ids_placeholders = ",".join([f":id_{i}" for i in range(len(task_ids))])
|
|
467
|
+
query = f"""
|
|
468
|
+
SELECT *
|
|
469
|
+
FROM task_ins
|
|
470
|
+
WHERE task_id IN ({task_ids_placeholders})
|
|
471
|
+
AND (created_at + ttl) > CAST(strftime('%s', 'now') AS REAL)
|
|
472
|
+
"""
|
|
473
|
+
query += ";"
|
|
474
|
+
|
|
475
|
+
task_ins_data = {}
|
|
476
|
+
for index, task_id in enumerate(task_ids):
|
|
477
|
+
task_ins_data[f"id_{index}"] = str(task_id)
|
|
478
|
+
|
|
479
|
+
task_ins_rows = self.query(query, task_ins_data)
|
|
480
|
+
|
|
481
|
+
if not task_ins_rows:
|
|
482
|
+
return []
|
|
483
|
+
|
|
484
|
+
for row in task_ins_rows:
|
|
485
|
+
# Convert values from sint64 to uint64
|
|
486
|
+
convert_sint64_values_in_dict_to_uint64(
|
|
487
|
+
row, ["run_id", "producer_node_id", "consumer_node_id"]
|
|
488
|
+
)
|
|
489
|
+
task_ins = dict_to_task_ins(row)
|
|
490
|
+
if task_ins.task.created_at + task_ins.task.ttl <= time.time():
|
|
491
|
+
log(WARNING, "TaskIns with task_id %s is expired.", task_ins.task_id)
|
|
492
|
+
task_ids.remove(UUID(task_ins.task_id))
|
|
493
|
+
|
|
454
494
|
# Retrieve all anonymous Tasks
|
|
455
495
|
if len(task_ids) == 0:
|
|
456
496
|
return []
|
{flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/RECORD
RENAMED
|
@@ -272,8 +272,8 @@ flwr/server/superlink/fleet/vce/backend/backend.py,sha256=LBAQxnbfPAphVOVIvYMj0Q
|
|
|
272
272
|
flwr/server/superlink/fleet/vce/backend/raybackend.py,sha256=7kB3re3mR53b7E6L6DPSioTSKD3YGtS3uJsPD7Hn2Fw,7155
|
|
273
273
|
flwr/server/superlink/fleet/vce/vce_api.py,sha256=cGPsjS_4SJHm8jszGjsHh8ZNk9nqWoIQwW_62yKKR1Y,12647
|
|
274
274
|
flwr/server/superlink/state/__init__.py,sha256=Gj2OTFLXvA-mAjBvwuKDM3rDrVaQPcIoybSa2uskMTE,1003
|
|
275
|
-
flwr/server/superlink/state/in_memory_state.py,sha256=
|
|
276
|
-
flwr/server/superlink/state/sqlite_state.py,sha256=
|
|
275
|
+
flwr/server/superlink/state/in_memory_state.py,sha256=P00PeiBjNqxrWVUpMfoNFEbK9XwTULlaOzSgpaMBzkA,15960
|
|
276
|
+
flwr/server/superlink/state/sqlite_state.py,sha256=WlPVEfiPHcumnTXrnYhxxrxiAfC5xEKACV99w_9Q-js,35806
|
|
277
277
|
flwr/server/superlink/state/state.py,sha256=KpM894R8RE1N0b-s_Nlii6i0TDxj0DRkKa3Vf24Gt70,8127
|
|
278
278
|
flwr/server/superlink/state/state_factory.py,sha256=Fo8pBQ1WWrVJK5TOEPZ_zgJE69_mfTGjTO6czh6571o,2021
|
|
279
279
|
flwr/server/superlink/state/utils.py,sha256=OsF3OOoU4bU4PgLWkypX6EDoFs0L8RP_mHEBG-tVqGA,5227
|
|
@@ -301,8 +301,8 @@ flwr/superexec/exec_grpc.py,sha256=ZPq7EP55Vwj0kRcLVuTCokFqfIgBk-7YmDykZoMKi-c,1
|
|
|
301
301
|
flwr/superexec/exec_servicer.py,sha256=TRpwPVl7eI0Y_xlCY6DmVpAo0yFU1gLwzyIeqFw9pyk,4746
|
|
302
302
|
flwr/superexec/executor.py,sha256=-5J-ZLs-uArro3T2pCq0YQRC65cs18M888nufzdYE4E,2375
|
|
303
303
|
flwr/superexec/simulation.py,sha256=J6pw-RqCSiUed8I_3MasZH4tl57ZmDebPAHNnbb0-vE,7420
|
|
304
|
-
flwr_nightly-1.12.0.
|
|
305
|
-
flwr_nightly-1.12.0.
|
|
306
|
-
flwr_nightly-1.12.0.
|
|
307
|
-
flwr_nightly-1.12.0.
|
|
308
|
-
flwr_nightly-1.12.0.
|
|
304
|
+
flwr_nightly-1.12.0.dev20241009.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
305
|
+
flwr_nightly-1.12.0.dev20241009.dist-info/METADATA,sha256=coU4H2vio6xXLZKrcCpJMOecM6p-az9LZ8WFBggz0bE,15618
|
|
306
|
+
flwr_nightly-1.12.0.dev20241009.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
307
|
+
flwr_nightly-1.12.0.dev20241009.dist-info/entry_points.txt,sha256=WUCbqhLEOzjx_lyATIM0-f0e8kOVaQjzwOvyOxHrMhs,434
|
|
308
|
+
flwr_nightly-1.12.0.dev20241009.dist-info/RECORD,,
|
{flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/LICENSE
RENAMED
|
File without changes
|
{flwr_nightly-1.12.0.dev20241008.dist-info → flwr_nightly-1.12.0.dev20241009.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|