-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sub]feat: modify computetask failure report (#727)
## Companion PR - Substra/orchestrator#277 - Substra/substra-frontend#240 ## Description The aim is to allow registering failure reports not only for compute task but for other kind of assets (for now, functions which are not building as part of the execution of a compute task) - Modifies `ComputeTaskFailureReport`: - renamed the model to `AssetFailureReport` - renamed field `compute_task_key` to `asset_key` (as we can now have a function key) - added field `asset_type` to provide - Updates protobuf reflecting the previous changes - refactor `download_file` in `PermissionMixin` to provide mroe flexibility (and decouple from DRF) - create new `FailableTask` (Celery task): - centralize the logic to submit asset failure ## How has this been tested? As this is going to be merged on a branch that is going to be merged to a POC branch, we use MNIST as a baseline of a working model. We will deal with failing tests on the POC before merging on main. ## Checklist - [x] [changelog](../CHANGELOG.md) was updated with notable changes - [ ] documentation was updated --------- Signed-off-by: Guilhem Barthes <guilhem.barthes@owkin.com>
- Loading branch information
1 parent
1a2c9b8
commit 947f49e
Showing
36 changed files
with
639 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from rest_framework import response as drf_response | ||
from rest_framework import status | ||
from rest_framework import viewsets | ||
from rest_framework.decorators import action | ||
|
||
from api.errors import AssetPermissionError | ||
from api.models import ComputeTask | ||
from api.models import Function | ||
from api.views import utils as view_utils | ||
from substrapp.models import asset_failure_report | ||
|
||
|
||
class FailedAssetLogsViewSet(view_utils.PermissionMixin, viewsets.GenericViewSet): | ||
queryset = asset_failure_report.AssetFailureReport.objects.all() | ||
|
||
@action(detail=True, url_path=asset_failure_report.LOGS_FILE_PATH) | ||
def file(self, request, pk=None) -> drf_response.Response: | ||
report = self.get_object() | ||
channel_name = view_utils.get_channel_name(request) | ||
if report.asset_type == asset_failure_report.FailedAssetKind.FAILED_ASSET_FUNCTION: | ||
asset_class = Function | ||
else: | ||
asset_class = ComputeTask | ||
|
||
try: | ||
asset = self.get_asset(request, report.key, channel_name, asset_class) | ||
except AssetPermissionError as e: | ||
return view_utils.ApiResponse({"detail": str(e)}, status=status.HTTP_403_FORBIDDEN) | ||
|
||
response = view_utils.get_file_response( | ||
local_file_class=asset_failure_report.AssetFailureReport, | ||
key=report.key, | ||
content_field="logs", | ||
channel_name=channel_name, | ||
url=report.logs_address, | ||
asset_owner=asset.get_owner(), | ||
) | ||
|
||
response.headers["Content-Type"] = "text/plain; charset=utf-8" | ||
response.headers["Content-Disposition"] = f'attachment; filename="tuple_logs_{pk}.txt"' | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.