Skip to content

Commit

Permalink
refactor: sort OSCAR services by date
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Nov 19, 2024
1 parent d2805eb commit a0732e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ai4papi/routers/v1/inference/oscar.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ def get_services_list(

services.append(s)

return services
# Sort services by creation time, recent to old
dates = [s['environment']['Variables']['PAPI_CREATED'] for s in services]
idxs = sorted(range(len(dates)), key=dates.__getitem__) # argsort
sorted_services = [services[i] for i in idxs[::-1]]

return sorted_services


@router.get("/services/{service_name}")
Expand Down

0 comments on commit a0732e8

Please sign in to comment.