From 89424ba53bc47ef7095d75615c675d6381acd521 Mon Sep 17 00:00:00 2001 From: Takitsuse Nagisa Date: Sat, 11 Jan 2020 17:29:09 +0900 Subject: [PATCH 1/4] Take in display_submission_result to result --- evalai/submissions.py | 14 ++++++++++++-- evalai/utils/submissions.py | 17 ----------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/evalai/submissions.py b/evalai/submissions.py index ac8bccf62..8b5b14270 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -18,8 +18,8 @@ from evalai.utils.requests import make_request from evalai.utils.submissions import ( display_submission_details, - display_submission_result, convert_bytes_to, + submission_details_request ) from evalai.utils.urls import URLS from evalai.utils.config import ( @@ -60,7 +60,17 @@ def result(ctx): """ Invoked by `evalai submission SUBMISSION_ID result`. """ - display_submission_result(ctx.submission_id) + try: + response = submission_details_request(ctx.submission_id).json() + echo(requests.get(response['submission_result_file']).text) + except requests.exceptions.MissingSchema: + echo( + style( + "\nThe Submission is yet to be evaluated.\n", + bold=True, + fg="red", + ) + ) @click.command() diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 19d9fc3e4..1e9e82b74 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -264,23 +264,6 @@ def display_submission_details(submission_id): pretty_print_submission_details(response) -def display_submission_result(submission_id): - """ - Function to display result of a particular submission - """ - try: - response = submission_details_request(submission_id).json() - echo(requests.get(response['submission_result_file']).text) - except requests.exceptions.MissingSchema: - echo( - style( - "\nThe Submission is yet to be evaluated.\n", - bold=True, - fg="red", - ) - ) - - def convert_bytes_to(byte, to, bsize=1024): """ Convert bytes to KB, MB, GB etc. From fb4c9086b8b5ea60dc47f801424b8a4e7621b08a Mon Sep 17 00:00:00 2001 From: Takitsuse Nagisa Date: Sun, 12 Jan 2020 22:15:51 +0900 Subject: [PATCH 2/4] Define common function --- evalai/submissions.py | 15 +++------------ evalai/utils/submissions.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/evalai/submissions.py b/evalai/submissions.py index 8b5b14270..16b22e485 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -18,6 +18,7 @@ from evalai.utils.requests import make_request from evalai.utils.submissions import ( display_submission_details, + display_submission_with, convert_bytes_to, submission_details_request ) @@ -60,18 +61,8 @@ def result(ctx): """ Invoked by `evalai submission SUBMISSION_ID result`. """ - try: - response = submission_details_request(ctx.submission_id).json() - echo(requests.get(response['submission_result_file']).text) - except requests.exceptions.MissingSchema: - echo( - style( - "\nThe Submission is yet to be evaluated.\n", - bold=True, - fg="red", - ) - ) - + error_message = "\nThe Submission is yet to be evaluated.\n" + display_submission_with(ctx.submission_id, "submission_result_file", error_message) @click.command() @click.argument("IMAGE", nargs=1) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 1e9e82b74..ed4f96d51 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -264,6 +264,23 @@ def display_submission_details(submission_id): pretty_print_submission_details(response) +def display_submission_with(submission_id, file_name, error_message): + """ + Function to display information of a particular submission + """ + try: + response = submission_details_request(submission_id).json() + echo(requests.get(response[file_name]).text) + except requests.exceptions.MissingSchema: + echo( + style( + error_message, + bold=True, + fg="red", + ) + ) + + def convert_bytes_to(byte, to, bsize=1024): """ Convert bytes to KB, MB, GB etc. From 25c056b8e10ce05a35b96763c937af5c1e452648 Mon Sep 17 00:00:00 2001 From: Takitsuse Nagisa Date: Sun, 12 Jan 2020 22:21:32 +0900 Subject: [PATCH 3/4] Fix error --- evalai/submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evalai/submissions.py b/evalai/submissions.py index 16b22e485..d45684e40 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -20,7 +20,6 @@ display_submission_details, display_submission_with, convert_bytes_to, - submission_details_request ) from evalai.utils.urls import URLS from evalai.utils.config import ( @@ -64,6 +63,7 @@ def result(ctx): error_message = "\nThe Submission is yet to be evaluated.\n" display_submission_with(ctx.submission_id, "submission_result_file", error_message) + @click.command() @click.argument("IMAGE", nargs=1) @click.option( From 7315a2ac7258d94dc08779e33df9e6860697085a Mon Sep 17 00:00:00 2001 From: Takitsuse Nagisa Date: Sun, 12 Jan 2020 22:28:43 +0900 Subject: [PATCH 4/4] Rename display_submission_with to display_submission_file_data --- evalai/submissions.py | 4 ++-- evalai/utils/submissions.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/evalai/submissions.py b/evalai/submissions.py index d45684e40..bd0e75997 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -18,7 +18,7 @@ from evalai.utils.requests import make_request from evalai.utils.submissions import ( display_submission_details, - display_submission_with, + display_submission_file_data, convert_bytes_to, ) from evalai.utils.urls import URLS @@ -61,7 +61,7 @@ def result(ctx): Invoked by `evalai submission SUBMISSION_ID result`. """ error_message = "\nThe Submission is yet to be evaluated.\n" - display_submission_with(ctx.submission_id, "submission_result_file", error_message) + display_submission_file_data(ctx.submission_id, "submission_result_file", error_message) @click.command() diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index ed4f96d51..9bf70d914 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -264,7 +264,7 @@ def display_submission_details(submission_id): pretty_print_submission_details(response) -def display_submission_with(submission_id, file_name, error_message): +def display_submission_file_data(submission_id, file_name, error_message): """ Function to display information of a particular submission """