diff --git a/evalai/main.py b/evalai/main.py index 57240df46..4beb12213 100644 --- a/evalai/main.py +++ b/evalai/main.py @@ -15,8 +15,9 @@ def main(ctx): Welcome to the EvalAI CLI. """ if ctx.invoked_subcommand is None: - welcome_text = ("Welcome to the EvalAI CLI. Use evalai" - "--help for viewing all the options") + welcome_text = ("Welcome to the EvalAI CLI. Use evalai --help for viewing all the options\n" + "CHALLENGE and PHASE placeholders used throughout the CLI are" + " for challenge_id\nand phase_id of the challenges and phases.") echo(welcome_text) diff --git a/evalai/utils/challenges.py b/evalai/utils/challenges.py index a8ff050e6..c64817238 100644 --- a/evalai/utils/challenges.py +++ b/evalai/utils/challenges.py @@ -243,7 +243,8 @@ def display_challenge_details(challenge): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nUse `evalai challenges` to fetch the active challenges.\n", fg="red", bold=True)) else: echo(err) sys.exit(1) @@ -285,7 +286,9 @@ def display_challenge_phase_list(challenge_id): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nUse `evalai challenges` to fetch the active challenges.", fg="red", bold=True)) + echo(style("\nUse `evalai challenge CHALLENGE phases` to fetch the active phases.\n", fg="red", bold=True)) else: echo(err) sys.exit(1) @@ -351,7 +354,11 @@ def display_challenge_phase_detail(challenge_id, phase_id, is_json): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}\n" + "\nUse `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai challenge CHALLENGE phases` to fetch the " + "active phases.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) sys.exit(1) @@ -399,9 +406,14 @@ def display_challenge_phase_split_list(challenge_id): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"], fg="red", bold=True))) + echo(style("\nError: {}\n" + "\nUse `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai challenge CHALLENGE phases` to fetch the " + "active phases.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) + sys.exit(1) except requests.exceptions.RequestException as err: echo(err) sys.exit(1) diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 15ddabea9..3ef0611e1 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -37,7 +37,11 @@ def make_submission(challenge_id, phase_id, file, submission_metadata={}): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}\n" + "\nUse `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai challenge CHALLENGE phases` to fetch the " + "active phases.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) sys.exit(1) @@ -100,7 +104,11 @@ def display_my_submission_details(challenge_id, phase_id, start_date, end_date): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}\n" + "\nUse `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai challenge CHALLENGE phases` to fetch the " + "active phases.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) sys.exit(1) @@ -145,7 +153,10 @@ def display_submission_details(submission_id): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}\n" + "\nUse `evalai challenge CHALLENGE phase PHASE submissions` " + "to view your submission.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) sys.exit(1) diff --git a/evalai/utils/teams.py b/evalai/utils/teams.py index 7f89ab9f4..492b56df7 100644 --- a/evalai/utils/teams.py +++ b/evalai/utils/teams.py @@ -137,7 +137,11 @@ def participate_in_a_challenge(challenge_id, participant_team_id): except requests.exceptions.HTTPError as err: if (response.status_code in EVALAI_ERROR_CODES): validate_token(response.json()) - echo(style("Error: {}".format(response.json()["error"]), fg="red", bold=True)) + echo(style("\nError: {}\n" + "\nUse `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai teams` to fetch your participant " + "teams.\n".format(response.json()["error"]), + fg="red", bold=True)) else: echo(err) sys.exit(1) diff --git a/tests/test_requests.py b/tests/test_requests.py index 293d83689..e555a4cb2 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -236,8 +236,10 @@ def setup(self): def test_display_submission_details_for_object_does_not_exist(self): runner = CliRunner() result = runner.invoke(submission, ['9']) - response = result.output.rstrip() - assert response == self.expected + response = result.output.strip() + expected = "{}\n\n{}".format(self.expected, "Use `evalai challenge CHALLENGE " + "phase PHASE submissions` to view your submission.") + assert response == expected @responses.activate def test_make_submission_for_object_does_not_exist(self): @@ -247,8 +249,12 @@ def test_make_submission_for_object_does_not_exist(self): f.write('1 2 3 4 5 6') result = runner.invoke(challenge, ['1', 'phase', '2', 'submit', "--file", "test_file.txt"], input="N") - response = result.output.rstrip() - expected = "Do you want to include the Submission Details? [y/N]: N\n{}".format(self.expected) + response = result.output.strip() + + expected = "Do you want to include the Submission Details? [y/N]: N\n\n{}".format(self.expected) + expected = "{}\n\n{}".format(expected, "Use `evalai challenges` to fetch the active challenges.") + expected = "{}\n\n{}".format(expected, "Use `evalai challenge CHALLENGE phases` " + "to fetch the active phases.") assert response == expected @@ -292,7 +298,9 @@ def test_participate_in_a_challenge_when_object_does_not_exist(self): runner = CliRunner() result = runner.invoke(challenge, ['2', 'participate', '3']) response = result.output.rstrip() - assert response == self.expected + expected = "\n{}\n\n{}".format(self.expected, "Use `evalai challenges` to fetch the active challenges.") + expected = "{}\n\n{}".format(expected, "Use `evalai teams` to fetch your participant teams.") + assert response == expected class TestTeamsWhenTeamNameAlreadyExists(BaseTestClass): @@ -338,14 +346,19 @@ def test_display_challenge_phase_list_for_object_does_not_exist(self): runner = CliRunner() result = runner.invoke(challenge, ['10', 'phases']) response = result.output.rstrip() - assert response == self.expected + expected = "\n{}\n\n{}".format(self.expected, "Use `evalai challenges` to fetch the active challenges.\n" + "\nUse `evalai challenge CHALLENGE phases` to fetch the " + "active phases.") + assert response == expected @responses.activate def test_display_challenge_phase_detail_for_object_does_not_exist(self): runner = CliRunner() result = runner.invoke(challenge, ['10', 'phase', '20']) response = result.output.rstrip() - assert response == self.expected + expected = "\n{}\n\n{}".format(self.expected, "Use `evalai challenges` to fetch the active challenges.") + expected = "{}\n\n{}".format(expected, "Use `evalai challenge CHALLENGE phases` to fetch the active phases.") + assert response == expected class TestGetParticipantOrHostTeamChallengesHTTPErrorRequests(BaseTestClass):