-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added results export in JSON format for TaskReview app
- Loading branch information
Showing
21 changed files
with
430 additions
and
84 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
30 changes: 30 additions & 0 deletions
30
mephisto/client/review_app/server/api/views/task_export_results_json_view.py
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,30 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import os | ||
|
||
from flask import send_file | ||
from flask.views import MethodView | ||
from werkzeug.exceptions import NotFound | ||
|
||
from .task_export_results_view import get_result_file_path | ||
from .task_export_results_view import get_results_dir | ||
|
||
|
||
class TaskExportResultsJsonView(MethodView): | ||
def get(self, task_id: str = None) -> dict: | ||
"""Get result data file in JSON format""" | ||
results_dir = get_results_dir() | ||
results_file_path = get_result_file_path(results_dir, task_id) | ||
|
||
if not os.path.exists(results_file_path): | ||
raise NotFound("File not found") | ||
|
||
return send_file( | ||
results_file_path, | ||
as_attachment=True, | ||
attachment_filename=f"task-{task_id}-results.json", | ||
) |
Oops, something went wrong.