Skip to content

Commit

Permalink
prediction: use generators instead of list comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelone committed Oct 8, 2024
1 parent a3b7622 commit 4d9e505
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gantry/routes/prediction/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ async def predict(db: aiosqlite.Connection, spec: dict, strategy: str = None) ->
# mapping of sample: [0] cpu_mean, [1] cpu_max, [2] mem_mean, [3] mem_max
n = len(sample)
predictions = {
"cpu_request": sum([build[0] for build in sample]) / n,
"mem_request": sum([build[2] for build in sample]) / n,
"cpu_limit": sum([build[1] for build in sample]) / n,
"mem_limit": max([build[3] for build in sample]) * MEM_LIMIT_BUMP,
"cpu_request": sum(build[0] for build in sample) / n,
"mem_request": sum(build[2] for build in sample) / n,
"cpu_limit": sum(build[1] for build in sample) / n,
"mem_limit": max(build[3] for build in sample) * MEM_LIMIT_BUMP,
}
# build jobs cannot be less than 1
predictions["build_jobs"] = max(1, round(predictions["cpu_request"]))
Expand Down

0 comments on commit 4d9e505

Please sign in to comment.