Skip to content

Commit

Permalink
Remove jobs from status API
Browse files Browse the repository at this point in the history
  • Loading branch information
catileptic committed Mar 18, 2024
1 parent 569729f commit cf2ccf1
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions servicelayer/taskqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,18 @@ def cancel(self):

def get_status(self):
"""Status of a given dataset."""
status = {"finished": 0, "running": 0, "pending": 0, "jobs": []}
finished = self.conn.get(self.finished_key)
running = self.conn.scard(self.running_key)
pending = self.conn.scard(self.pending_key)
status["finished"] = max(0, unpack_int(finished))
status["running"] = max(0, unpack_int(running))
status["pending"] = max(0, unpack_int(pending))
status = {"finished": 0, "running": 0, "pending": 0, "stages": []}

start, end, last_update = self.conn.mget(
(self.start_key, self.end_key, self.last_update_key)
)
status["start_time"] = start
status["end_time"] = end
status["last_update"] = last_update

jobs_info = {
"finished": max(0, unpack_int(finished)),
"running": max(0, unpack_int(running)),
"pending": max(0, unpack_int(pending)),
"stages": [],
}

for stage in self.conn.smembers(self.active_stages_key):
stage_key = self.get_stage_key(stage)
jobs_info["stages"].append(
status["stages"].append(
{
"job_id": "",
"stage": stage,
Expand All @@ -146,7 +134,16 @@ def get_status(self):
}
)

status["jobs"].append(jobs_info)
status["finished"] = max(
0, sum([stage["finished"] for stage in status["stages"]])
)
status["running"] = max(
0, sum([stage["running"] for stage in status["stages"]])
)
status["pending"] = max(
0, sum([stage["pending"] for stage in status["stages"]])
)

return status

@classmethod
Expand Down

0 comments on commit cf2ccf1

Please sign in to comment.