From 9fbf95c8b68a34f6c7aa3c9bfbd3e8959ea11850 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Sun, 12 Jan 2020 14:48:10 +0100 Subject: [PATCH 01/20] Added command to display contents of stdderr file --- evalai/submissions.py | 13 +++++++++++++ evalai/utils/submissions.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/evalai/submissions.py b/evalai/submissions.py index ac8bccf62..b0b3a8da1 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -19,6 +19,7 @@ from evalai.utils.submissions import ( display_submission_details, display_submission_result, + display_submission_stderr_file, convert_bytes_to, ) from evalai.utils.urls import URLS @@ -63,6 +64,18 @@ def result(ctx): display_submission_result(ctx.submission_id) +@submission.command() +@click.pass_obj +def stderr(ctx): + """ + Display the submission error + """ + """ + Invoked by `evalai submission SUBMISSION_ID stderr`. + """ + display_submission_stderr_file(ctx.submission_id) + + @click.command() @click.argument("IMAGE", nargs=1) @click.option( diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 8e7aae044..9178199c5 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -292,3 +292,17 @@ def convert_bytes_to(byte, to, bsize=1024): unit = int(unit / bsize) return unit + + +def display_submission_stderr_file(submission_id): + try: + response = submission_details_request(submission_id).json() + echo(requests.get(response['stderr_file']).text) + except requests.exceptions.MissingSchema: + echo( + style( + "\nThe Submission is yet to be evaluated.\n", + bold=True, + fg="yellow", + ) + ) From ba452765ca13f4f46370d2e6d64641ad2e4213bc Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Sun, 12 Jan 2020 15:26:29 +0100 Subject: [PATCH 02/20] Added Tests for displaying contents of stderr_file --- tests/data/submission_response.py | 26 +++++++++++++++++++++++++ tests/test_submissions.py | 32 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/data/submission_response.py b/tests/data/submission_response.py index e9ee30474..37192a664 100644 --- a/tests/data/submission_response.py +++ b/tests/data/submission_response.py @@ -158,3 +158,29 @@ submission_result_file = """ [{"Total": 60, "Metric1": 61, "Metric2": 62, "Metric3": 63}] """ + + +submission_stderr_result = """ + { + "id": 48728, + "participant_team": 3519, + "participant_team_name": "test", + "execution_time": 0.085137, + "challenge_phase": 251, + "created_by": 5672, + "status": "failed", + "input_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/a93d2f2b-ac19-409d-a97d-7240ea336a0c.txt", + "stdout_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/0b2c4396-e078-4b95-b041-83801a430874.txt", + "stderr_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/39f3b087-8f86-4757-9c93-bf0b26c1a3c2.txt", + "submitted_at": "2019-12-11T05:37:24.259890Z", + "method_name": "null", + "method_description": "null", + "project_url": "null", + "publication_url": "null", + "is_public": false, + "is_flagged": false, + "submission_result_file": null, + "when_made_public": null, + "is_baseline": false + }""" + \ No newline at end of file diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 02f65fc76..bc6bc5632 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -290,3 +290,35 @@ def test_make_submission_for_docker_based_challenge( ], ) assert result.exit_code == 0 + + +class TestDisplayStderrFile(BaseTestClass): + def setup(self): + self.submission_stderr_result = json.loads(submission_response.submission_stderr_result), + self.expected_stderr_text = "Testing display contents of stderr file" + + url = "{}{}" + responses.add( + responses.GET, + url.format(API_HOST_URL, URLS.get_submission.value).format( + "48728" + ), + json=self.submission_stderr_result, + status=200, + ) + + responses.add( + responses.GET, + self.submission_stderr_result["stderr_file"], + body=self.expected_stderr_text, + status=200, + ) + + @responses.activate + def test_display_stderr_file_success(self): + expected = self.expected_stderr_text + result = runner.invoke( + submission, + ["48728", "stderr"] + ) + assert result.output.strip() == expected From 39b32abea83a378c56f85fc4eb4c7be9e34ee729 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Sun, 12 Jan 2020 15:30:48 +0100 Subject: [PATCH 03/20] Fixed Errors --- tests/data/submission_response.py | 3 +-- tests/test_submissions.py | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/data/submission_response.py b/tests/data/submission_response.py index 37192a664..e4ee89a41 100644 --- a/tests/data/submission_response.py +++ b/tests/data/submission_response.py @@ -160,7 +160,7 @@ """ -submission_stderr_result = """ +submission_result_with_stderr_file = """ { "id": 48728, "participant_team": 3519, @@ -183,4 +183,3 @@ "when_made_public": null, "is_baseline": false }""" - \ No newline at end of file diff --git a/tests/test_submissions.py b/tests/test_submissions.py index bc6bc5632..c5fa27d0a 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -294,7 +294,7 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): - self.submission_stderr_result = json.loads(submission_response.submission_stderr_result), + self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) self.expected_stderr_text = "Testing display contents of stderr file" url = "{}{}" @@ -317,8 +317,9 @@ def setup(self): @responses.activate def test_display_stderr_file_success(self): expected = self.expected_stderr_text + runner = CliRunner() result = runner.invoke( - submission, - ["48728", "stderr"] - ) + submission, + ["48728", "stderr"] + ) assert result.output.strip() == expected From a8f50cc152d7805f3ab7ec35e06b3d1a43910271 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:21:22 +0100 Subject: [PATCH 04/20] Changed test case --- evalai/utils/submissions.py | 7 +++---- tests/test_submissions.py | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 9178199c5..c5edfcb9a 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -295,10 +295,9 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): - try: - response = submission_details_request(submission_id).json() - echo(requests.get(response['stderr_file']).text) - except requests.exceptions.MissingSchema: + response = submission_details_request(submission_id).json() + echo(requests.get(response['stderr_file']).text) + if response['status'] == "failed": echo( style( "\nThe Submission is yet to be evaluated.\n", diff --git a/tests/test_submissions.py b/tests/test_submissions.py index c5fa27d0a..a046a3d5d 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -317,6 +317,9 @@ def setup(self): @responses.activate def test_display_stderr_file_success(self): expected = self.expected_stderr_text + expected = expected.format( + "\nThe Submission is yet to be evaluated." + ) runner = CliRunner() result = runner.invoke( submission, From 709675e16476263577dfb6a3c487723f1a3e6741 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:27:15 +0100 Subject: [PATCH 05/20] Changed test case --- evalai/utils/submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index c5edfcb9a..a3096b6a3 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -297,7 +297,7 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() echo(requests.get(response['stderr_file']).text) - if response['status'] == "failed": + if response['status'].text == "failed": echo( style( "\nThe Submission is yet to be evaluated.\n", From 11ef835e17c8be468684759f6b763b9289353056 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:28:19 +0100 Subject: [PATCH 06/20] Changed test case --- evalai/utils/submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index a3096b6a3..c5edfcb9a 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -297,7 +297,7 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() echo(requests.get(response['stderr_file']).text) - if response['status'].text == "failed": + if response['status'] == "failed": echo( style( "\nThe Submission is yet to be evaluated.\n", From e4c16482cfe20d0c938cf335ae2b079ee67571ad Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:34:14 +0100 Subject: [PATCH 07/20] Changed test case --- evalai/utils/submissions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index c5edfcb9a..842139398 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -297,6 +297,7 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() echo(requests.get(response['stderr_file']).text) + echo(response['status']) if response['status'] == "failed": echo( style( From 2621121b8d6ccf5d917486809e8924c5d404488b Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:37:07 +0100 Subject: [PATCH 08/20] Changed test case --- evalai/utils/submissions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 842139398..c5edfcb9a 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -297,7 +297,6 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() echo(requests.get(response['stderr_file']).text) - echo(response['status']) if response['status'] == "failed": echo( style( From d396bd69e2b34a66333632976d93a656c1d384da Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:38:06 +0100 Subject: [PATCH 09/20] Changed test case --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index a046a3d5d..161130885 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -325,4 +325,4 @@ def test_display_stderr_file_success(self): submission, ["48728", "stderr"] ) - assert result.output.strip() == expected + assert result.output == expected From c84ad76280be6276c09c0bd75cb2c2f0b84d4a69 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:41:36 +0100 Subject: [PATCH 10/20] Changed test case --- evalai/utils/submissions.py | 2 +- tests/test_submissions.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index c5edfcb9a..9bd3813f4 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -296,7 +296,6 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() - echo(requests.get(response['stderr_file']).text) if response['status'] == "failed": echo( style( @@ -305,3 +304,4 @@ def display_submission_stderr_file(submission_id): fg="yellow", ) ) + echo(requests.get(response['stderr_file']).text) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 161130885..df6d008f5 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -295,7 +295,7 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) - self.expected_stderr_text = "Testing display contents of stderr file" + self.expected_stderr_text = "\nThe Submission is yet to be evaluated.\n" url = "{}{}" responses.add( @@ -318,11 +318,11 @@ def setup(self): def test_display_stderr_file_success(self): expected = self.expected_stderr_text expected = expected.format( - "\nThe Submission is yet to be evaluated." + "Testing display contents of stderr file" ) runner = CliRunner() result = runner.invoke( submission, ["48728", "stderr"] ) - assert result.output == expected + assert result.output.strip() == expected From 936c7fcd83d49067bbcc408dc3bd28e854e7bcec Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:54:47 +0100 Subject: [PATCH 11/20] Changed test case --- evalai/utils/submissions.py | 3 ++- tests/test_submissions.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 9bd3813f4..b4d1d7d58 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -296,6 +296,7 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() + echo(requests.get(response['stderr_file']).text) if response['status'] == "failed": echo( style( @@ -304,4 +305,4 @@ def display_submission_stderr_file(submission_id): fg="yellow", ) ) - echo(requests.get(response['stderr_file']).text) + sys.exit(0) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index df6d008f5..9196bfbc7 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -295,7 +295,7 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) - self.expected_stderr_text = "\nThe Submission is yet to be evaluated.\n" + self.expected_stderr_text = "Testing display contents of stderr file" url = "{}{}" responses.add( @@ -318,7 +318,7 @@ def setup(self): def test_display_stderr_file_success(self): expected = self.expected_stderr_text expected = expected.format( - "Testing display contents of stderr file" + "\nThe Submission is yet to be evaluated." ) runner = CliRunner() result = runner.invoke( @@ -326,3 +326,4 @@ def test_display_stderr_file_success(self): ["48728", "stderr"] ) assert result.output.strip() == expected + assert result.exit_code == 0 From f64b0001790f7adac010c15f5974545671c88885 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:58:30 +0100 Subject: [PATCH 12/20] Changed test case --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 9196bfbc7..af89de83a 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -295,7 +295,7 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) - self.expected_stderr_text = "Testing display contents of stderr file" + self.expected_stderr_text = "Testing display contents of stderr file{}" url = "{}{}" responses.add( From 079548346b159883957a654433785f51b7bde4ce Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:05:03 +0100 Subject: [PATCH 13/20] fixed errors --- tests/test_submissions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index af89de83a..4953eb15d 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -316,9 +316,10 @@ def setup(self): @responses.activate def test_display_stderr_file_success(self): - expected = self.expected_stderr_text + expected = "{}\n{}" expected = expected.format( - "\nThe Submission is yet to be evaluated." + self.expected_stderr_text, + "The Submission is yet to be evaluated." ) runner = CliRunner() result = runner.invoke( From 768e947ff4871be7f35750e32580ff1f8977d365 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:06:45 +0100 Subject: [PATCH 14/20] fixed errors --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 4953eb15d..8fa1b11ef 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -295,7 +295,7 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) - self.expected_stderr_text = "Testing display contents of stderr file{}" + self.expected_stderr_text = "Testing display contents of stderr file" url = "{}{}" responses.add( From 6bab44cc5f84dac95710001a00567aa2ca094072 Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:11:13 +0100 Subject: [PATCH 15/20] Changed test case --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 8fa1b11ef..3dbd8ebcf 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -316,7 +316,7 @@ def setup(self): @responses.activate def test_display_stderr_file_success(self): - expected = "{}\n{}" + expected = "{}{}" expected = expected.format( self.expected_stderr_text, "The Submission is yet to be evaluated." From 75295761e1c11d561ec81d8e57f66148ca6fd5de Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:12:46 +0100 Subject: [PATCH 16/20] Changed test case --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 3dbd8ebcf..00943dad6 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -316,7 +316,7 @@ def setup(self): @responses.activate def test_display_stderr_file_success(self): - expected = "{}{}" + expected = "{}\n\n{}" expected = expected.format( self.expected_stderr_text, "The Submission is yet to be evaluated." From 283393072a7d339815d6a482578bce842ad2aade Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:26:58 +0100 Subject: [PATCH 17/20] Added more robust test case --- evalai/utils/submissions.py | 11 ++++++++++- tests/data/submission_response.py | 27 ++++++++++++++++++++++++++- tests/test_submissions.py | 31 ++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index b4d1d7d58..f6caf9878 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -297,7 +297,7 @@ def convert_bytes_to(byte, to, bsize=1024): def display_submission_stderr_file(submission_id): response = submission_details_request(submission_id).json() echo(requests.get(response['stderr_file']).text) - if response['status'] == "failed": + if response['status'] == "submitted": echo( style( "\nThe Submission is yet to be evaluated.\n", @@ -305,4 +305,13 @@ def display_submission_stderr_file(submission_id): fg="yellow", ) ) + + if response['status'] == "failed": + echo( + style( + "\nThe Submission failed.\n", + bold=True, + fg="red", + ) + ) sys.exit(0) diff --git a/tests/data/submission_response.py b/tests/data/submission_response.py index e4ee89a41..6ece119af 100644 --- a/tests/data/submission_response.py +++ b/tests/data/submission_response.py @@ -160,7 +160,7 @@ """ -submission_result_with_stderr_file = """ +submission_result_with_stderr_file_with_status_of_submitted = """ { "id": 48728, "participant_team": 3519, @@ -168,6 +168,31 @@ "execution_time": 0.085137, "challenge_phase": 251, "created_by": 5672, + "status": "submitted", + "input_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/a93d2f2b-ac19-409d-a97d-7240ea336a0c.txt", + "stdout_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/0b2c4396-e078-4b95-b041-83801a430874.txt", + "stderr_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/39f3b087-8f86-4757-9c93-bf0b26c1a3c2.txt", + "submitted_at": "2019-12-11T05:37:24.259890Z", + "method_name": "null", + "method_description": "null", + "project_url": "null", + "publication_url": "null", + "is_public": false, + "is_flagged": false, + "submission_result_file": null, + "when_made_public": null, + "is_baseline": false + }""" + + +submission_result_with_stderr_file_with_status_of_failed = """ + { + "id": 48928, + "participant_team": 3519, + "participant_team_name": "test", + "execution_time": 0.085137, + "challenge_phase": 251, + "created_by": 5672, "status": "failed", "input_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/a93d2f2b-ac19-409d-a97d-7240ea336a0c.txt", "stdout_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/0b2c4396-e078-4b95-b041-83801a430874.txt", diff --git a/tests/test_submissions.py b/tests/test_submissions.py index 00943dad6..d2bfa90ff 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -294,7 +294,8 @@ def test_make_submission_for_docker_based_challenge( class TestDisplayStderrFile(BaseTestClass): def setup(self): - self.submission_stderr_result = json.loads(submission_response.submission_result_with_stderr_file) + self.submission_stderr_result_submitted = json.loads(submission_response.submission_result_with_stderr_file_with_status_of_submitted) + self.submission_stderr_result_failed = json.loads(submission_response.submission_result_with_stderr_file_with_status_of_failed) self.expected_stderr_text = "Testing display contents of stderr file" url = "{}{}" @@ -303,7 +304,16 @@ def setup(self): url.format(API_HOST_URL, URLS.get_submission.value).format( "48728" ), - json=self.submission_stderr_result, + json=self.submission_stderr_result_submitted, + status=200, + ) + + responses.add( + responses.GET, + url.format(API_HOST_URL, URLS.get_submission.value).format( + "48928" + ), + json=self.submission_stderr_result_failed, status=200, ) @@ -315,7 +325,7 @@ def setup(self): ) @responses.activate - def test_display_stderr_file_success(self): + def test_display_stderr_file_success_with_status_of_submitted(self): expected = "{}\n\n{}" expected = expected.format( self.expected_stderr_text, @@ -328,3 +338,18 @@ def test_display_stderr_file_success(self): ) assert result.output.strip() == expected assert result.exit_code == 0 + + @responses.activate + def test_display_stderr_file_success_with_status_of_failed(self): + expected = "{}\n\n{}" + expected = expected.format( + self.expected_stderr_text, + "The Submission failed." + ) + runner = CliRunner() + result = runner.invoke( + submission, + ["48928", "stderr"] + ) + assert result.output.strip() == expected + assert result.exit_code == 0 From 1d768ccc76e94659fb68954fec9f51ca659185ce Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:42:22 +0100 Subject: [PATCH 18/20] fixed errors --- tests/test_submissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submissions.py b/tests/test_submissions.py index d2bfa90ff..d51120383 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -319,7 +319,7 @@ def setup(self): responses.add( responses.GET, - self.submission_stderr_result["stderr_file"], + self.submission_stderr_result_submitted["stderr_file"], body=self.expected_stderr_text, status=200, ) From ab4abcbb433d4073bd16247ca6244d2cfbb71b0e Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Tue, 14 Jan 2020 07:51:49 +0100 Subject: [PATCH 19/20] Added more robust test case --- evalai/utils/submissions.py | 9 +++++++++ tests/data/submission_response.py | 25 +++++++++++++++++++++++++ tests/test_submissions.py | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index f6caf9878..281131cd1 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -314,4 +314,13 @@ def display_submission_stderr_file(submission_id): fg="red", ) ) + + if response['status'] == "running": + echo( + style( + "\nThe Submission is still running.\n", + bold=True, + fg="red", + ) + ) sys.exit(0) diff --git a/tests/data/submission_response.py b/tests/data/submission_response.py index 6ece119af..33a1facdb 100644 --- a/tests/data/submission_response.py +++ b/tests/data/submission_response.py @@ -208,3 +208,28 @@ "when_made_public": null, "is_baseline": false }""" + + +submission_result_with_stderr_file_with_status_of_running = """ + { + "id": 49928, + "participant_team": 3519, + "participant_team_name": "test", + "execution_time": 0.085137, + "challenge_phase": 251, + "created_by": 5672, + "status": "running", + "input_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/a93d2f2b-ac19-409d-a97d-7240ea336a0c.txt", + "stdout_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/0b2c4396-e078-4b95-b041-83801a430874.txt", + "stderr_file": "https://evalai.s3.amazonaws.com/media/submission_files/submission_48728/39f3b087-8f86-4757-9c93-bf0b26c1a3c2.txt", + "submitted_at": "2019-12-11T05:37:24.259890Z", + "method_name": "null", + "method_description": "null", + "project_url": "null", + "publication_url": "null", + "is_public": false, + "is_flagged": false, + "submission_result_file": null, + "when_made_public": null, + "is_baseline": false + }""" diff --git a/tests/test_submissions.py b/tests/test_submissions.py index d51120383..851386910 100644 --- a/tests/test_submissions.py +++ b/tests/test_submissions.py @@ -296,6 +296,7 @@ class TestDisplayStderrFile(BaseTestClass): def setup(self): self.submission_stderr_result_submitted = json.loads(submission_response.submission_result_with_stderr_file_with_status_of_submitted) self.submission_stderr_result_failed = json.loads(submission_response.submission_result_with_stderr_file_with_status_of_failed) + self.submission_stderr_result_running = json.loads(submission_response.submission_result_with_stderr_file_with_status_of_running) self.expected_stderr_text = "Testing display contents of stderr file" url = "{}{}" @@ -317,6 +318,15 @@ def setup(self): status=200, ) + responses.add( + responses.GET, + url.format(API_HOST_URL, URLS.get_submission.value).format( + "49928" + ), + json=self.submission_stderr_result_running, + status=200, + ) + responses.add( responses.GET, self.submission_stderr_result_submitted["stderr_file"], @@ -353,3 +363,18 @@ def test_display_stderr_file_success_with_status_of_failed(self): ) assert result.output.strip() == expected assert result.exit_code == 0 + + @responses.activate + def test_display_stderr_file_success_with_status_of_running(self): + expected = "{}\n\n{}" + expected = expected.format( + self.expected_stderr_text, + "The Submission is still running." + ) + runner = CliRunner() + result = runner.invoke( + submission, + ["49928", "stderr"] + ) + assert result.output.strip() == expected + assert result.exit_code == 0 From 84825c84db30a6d094f0f2e1c432e7bbd9d949de Mon Sep 17 00:00:00 2001 From: jayy <35180217+nsjcorps@users.noreply.github.com> Date: Tue, 14 Jan 2020 07:55:35 +0100 Subject: [PATCH 20/20] Added more robust test case --- evalai/utils/submissions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 281131cd1..6c5b03a5d 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -306,7 +306,7 @@ def display_submission_stderr_file(submission_id): ) ) - if response['status'] == "failed": + elif response['status'] == "failed": echo( style( "\nThe Submission failed.\n", @@ -315,7 +315,7 @@ def display_submission_stderr_file(submission_id): ) ) - if response['status'] == "running": + elif response['status'] == "running": echo( style( "\nThe Submission is still running.\n",