Skip to content

Commit

Permalink
Add minor fixes & Fix python2 compatibility issues(Cloud-CV#95)
Browse files Browse the repository at this point in the history
* Make submission metadata optional

* Fix server error in leaderboards

* Fix utf-8 error

* Fix python 2 compatibility issue
  • Loading branch information
guyandtheworld authored and RishabhJain2018 committed Aug 22, 2018
1 parent 9c53205 commit 41e23e1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
11 changes: 6 additions & 5 deletions evalai/challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ def submit(ctx, file):
"""
submission_metadata = {}
if click.confirm('Do you want to include the Submission Details?'):
submission_metadata = {}
submission_metadata["method_name"] = click.prompt(style('Method Name', fg="yellow"), type=str)
submission_metadata["method_description"] = click.prompt(style('Method Description', fg="yellow"), type=str)
submission_metadata["project_url"] = click.prompt(style('Project URL', fg="yellow"), type=str)
submission_metadata["publication_url"] = click.prompt(style('Publication URL', fg="yellow"), type=str)
submission_metadata["method_name"] = click.prompt(style('Method Name', fg="yellow"), type=str, default="")
submission_metadata["method_description"] = click.prompt(style('Method Description', fg="yellow"),
type=str, default="")
submission_metadata["project_url"] = click.prompt(style('Project URL', fg="yellow"), type=str, default="")
submission_metadata["publication_url"] = click.prompt(style('Publication URL', fg="yellow"),
type=str, default="")
make_submission(ctx.challenge_id, ctx.phase_id, file, submission_metadata)


Expand Down
4 changes: 3 additions & 1 deletion evalai/utils/challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def pretty_print_leaderboard_data(attributes, results):
"""
leaderboard_table = BeautifulTable(max_width=150)
attributes = ["Rank", "Participant Team"] + attributes + ["Last Submitted"]
attributes = list(map(lambda item: str(item), attributes))
leaderboard_table.column_headers = attributes

for rank, result in enumerate(results, start=1):
Expand All @@ -465,9 +466,10 @@ def display_leaderboard(challenge_id, phase_split_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("Error: {}".format(response.json()["error"]), fg="red", bold=True))
else:
echo(err)
sys.exit(1)
except requests.exceptions.RequestException as err:
echo(style("\nCould not establish a connection to EvalAI."
" Please check the Host URL.\n", bold=True, fg="red"))
Expand Down
2 changes: 1 addition & 1 deletion evalai/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def clean_data(data):
"""
data = BeautifulSoup(data, "lxml").text.strip()
data = ' '.join(data.split())
return data
data.encode("utf-8")
3 changes: 2 additions & 1 deletion evalai/utils/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def make_submission(challenge_id, phase_id, file, submission_metadata={}):
input_file = {'input_file': file}
data = {
'status': 'submitting',
**submission_metadata,
}
data = dict(data, **submission_metadata)

try:
response = requests.post(
url,
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python
import io

from setuptools import setup, find_packages


PROJECT = 'evalai'


with open('README.md', encoding='utf-8') as f:
with io.open('README.md', encoding='utf-8') as f:
long_description = f.read()

setup(
Expand Down
1 change: 1 addition & 0 deletions tests/test_challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def test_display_leaderboard(self):

table = BeautifulTable(max_width=150)
attributes = ["Rank", "Participant Team"] + attributes + ["Last Submitted"]
attributes = list(map(lambda item: str(item), attributes))
table.column_headers = attributes

for rank, result in enumerate(self.leaderboard, start=1):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_make_submission_when_file_is_valid_without_metadata(self):
@responses.activate
def test_make_submission_when_file_is_valid_with_metadata(self):
expected = "Do you want to include the Submission Details? [y/N]: Y"
expected = "{}\n{}".format(expected, ("Method Name: Test\nMethod Description: "
"Test\nProject URL: Test\nPublication URL: Test\n"))
expected = "{}\n{}".format(expected, ("Method Name []: Test\nMethod Description []: "
"Test\nProject URL []: Test\nPublication URL []: Test\n"))
expected = "{}\n{}".format(expected, ("Your file {} with the ID {} is successfully submitted.\n\n"
"You can use `evalai submission {}` to view this "
"submission's status.").format("test_file.txt", "9", "9"))
Expand Down

0 comments on commit 41e23e1

Please sign in to comment.