Skip to content

Commit

Permalink
fix sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
panh99 committed Sep 23, 2024
1 parent 68b3154 commit e219662
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/py/flwr/server/superlink/state/sqlite_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,14 @@ def get_run(self, run_id: int) -> Optional[Run]:

def get_run_status(self, run_ids: set[int]) -> dict[int, RunStatus]:
"""Retrieve the statuses for the specified runs."""
# Convert the uint64 value to sint64 for SQLite
sint64_run_ids = tuple(convert_uint64_to_sint64(run_id) for run_id in run_ids)
query = f"SELECT * FROM run WHERE run_id IN ({','.join(['?'] * len(run_ids))});"
rows = self.query(query, tuple(run_ids))
rows = self.query(query, sint64_run_ids)

return {
row["run_id"]: RunStatus(
# Restore uint64 run IDs
convert_sint64_to_uint64(row["run_id"]): RunStatus(
status=row["status"],
sub_status=row["sub_status"],
details=row["details"],
Expand All @@ -805,8 +808,10 @@ def get_run_status(self, run_ids: set[int]) -> dict[int, RunStatus]:

def update_run_status(self, run_id: int, new_status: RunStatus) -> bool:
"""Update the status of the run with the specified `run_id`."""
# Convert the uint64 value to sint64 for SQLite
sint64_run_id = convert_uint64_to_sint64(run_id)
query = "SELECT * FROM run WHERE run_id = ?;"
rows = self.query(query, (run_id,))
rows = self.query(query, (sint64_run_id,))

# Check if the run_id exists
if not rows:
Expand Down Expand Up @@ -841,7 +846,7 @@ def update_run_status(self, run_id: int, new_status: RunStatus) -> bool:
new_status.status,
new_status.sub_status,
new_status.details,
run_id,
sint64_run_id,
)
self.query(query, data)
return True
Expand Down

0 comments on commit e219662

Please sign in to comment.