Skip to content

Commit

Permalink
fix: remove pagination on <task_id>/perf (#690)
Browse files Browse the repository at this point in the history
## Related issues

- Substra/substra#372
- Substra/substra-frontend#222

## Description

Remove pagination in performance endpoints, as we always need all of
them.

Note: alternative implementation would be to iterate on all pages in
`<task_id>/perf/` in all case, in the frontend and in the SDK.

Fixes FL-1092

## How has this been tested?

<!-- Please describe the tests that you ran to verify your changes.  -->

## Checklist

- [ ] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

---------

Signed-off-by: Guilhem Barthes <[email protected]>
  • Loading branch information
guilhem-barthes authored Jul 17, 2023
1 parent 396af78 commit e295624
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Remove pagination on `get_performances` to remove limitation on 1000 first points ([#690](https://github.com/Substra/substra-backend/pull/690))

## [0.39.0](https://github.com/Substra/substra-backend/releases/tag/0.39.0) 2023-06-27

### Added
Expand Down
6 changes: 0 additions & 6 deletions backend/api/tests/views/test_views_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ def test_performance_list_empty(self):
self.assertEqual(
response.json(),
{
"count": 0,
"next": None,
"previous": None,
"compute_plan_statistics": {
"compute_tasks_distinct_ranks": [1, 2, 3],
"compute_tasks_distinct_rounds": [1],
Expand All @@ -134,9 +131,6 @@ def test_performance_list(self):
self.assertEqual(
response.json(),
{
"count": len(self.expected_results),
"next": None,
"previous": None,
"compute_plan_statistics": self.expected_stats,
"results": self.expected_results,
},
Expand Down
10 changes: 4 additions & 6 deletions backend/api/views/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rest_framework import mixins
from rest_framework.decorators import action
from rest_framework.filters import OrderingFilter
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

import orchestrator.computeplan_pb2 as computeplan_pb2
Expand All @@ -32,6 +33,7 @@

class CPPerformanceViewSet(mixins.ListModelMixin, GenericViewSet):
serializer_class = CPPerformanceSerializer
pagination_class = None
filter_backends = [OrderingFilter]
ordering_fields = [
"compute_task_output__task__rank",
Expand Down Expand Up @@ -79,12 +81,8 @@ def get_queryset(self):
def list(self, request, compute_plan_pk):
queryset = self.filter_queryset(self.get_queryset())
cp_stats = self._get_cp_ranks_and_rounds(compute_plan_pk).first()

page = self.paginate_queryset(queryset)
serializer = self.get_serializer(page, many=True)
response = self.get_paginated_response(serializer.data)
response.data["compute_plan_statistics"] = cp_stats
return response
serializer = self.get_serializer(queryset, many=True)
return Response({"results": serializer.data, "compute_plan_statistics": cp_stats})


class PerformanceFilter(FilterSet):
Expand Down

0 comments on commit e295624

Please sign in to comment.