forked from Cloud-CV/evalai-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add commands to view & create challenge host & participant teams(Clou…
…d-CV#74) * Tests for host teams * Fix conflicts * Fix conflicts * Add team url validators * update validators
- Loading branch information
1 parent
b859532
commit c7270dc
Showing
7 changed files
with
253 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,62 @@ | ||
import click | ||
import sys | ||
import validators | ||
|
||
from click import echo, style | ||
|
||
from evalai.utils.teams import ( | ||
create_participant_team, | ||
display_participant_teams, | ||
create_team, | ||
display_teams, | ||
) | ||
|
||
|
||
@click.group(invoke_without_command=True) | ||
@click.pass_context | ||
def teams(ctx): | ||
@click.option('--host', '-h', is_flag=True, | ||
help="View your host teams.") | ||
@click.option('--participant', '-p', is_flag=True, | ||
help="View your host teams.") | ||
def teams(ctx, host, participant): | ||
""" | ||
List all the participant/host teams of a user. | ||
""" | ||
""" | ||
List all the participant teams of a user. | ||
Invoked by running `evalai teams` | ||
""" | ||
if ctx.invoked_subcommand is None: | ||
display_participant_teams() | ||
if host == participant: | ||
echo("Sorry, wrong flag. Please pass either one of the flags " | ||
"{} or {}.".format(style("--participant", bold=True, fg="yellow"), | ||
style("--host", bold=True, fg="yellow"))) | ||
sys.exit(1) | ||
|
||
display_teams(host) | ||
|
||
|
||
@teams.command() | ||
def create(): | ||
@click.argument('TEAM', type=str) | ||
def create(team): | ||
""" | ||
Create a participant or host team. | ||
""" | ||
""" | ||
Create a participant team. | ||
Invoked by running `evalai teams create` | ||
""" | ||
team_name = click.prompt("Enter team name: ", type=str) | ||
if click.confirm("Please confirm the team name - %s" % (team_name), abort=True): | ||
create_participant_team(team_name) | ||
is_host = False | ||
if team not in ("host", "participant"): | ||
echo("Sorry, wrong argument. Please choose either " | ||
"{} or {}.".format(style("participant", bold=True, fg="yellow"), | ||
style("host", bold=True, fg="yellow"))) | ||
sys.exit(1) | ||
|
||
team_name = click.prompt("Enter team name", type=str) | ||
if click.confirm("Please confirm the team name - {}".format(team_name), abort=True): | ||
team_url = "" | ||
if click.confirm("Do you want to enter the Team URL".format(team_name)): | ||
team_url = click.prompt('Team URL', type=str) | ||
while not (validators.url(team_url) or validators.domain(team_url)): | ||
echo("Sorry, please enter a valid link.") | ||
team_url = click.prompt('Team URL', type=str) | ||
|
||
is_host = (team == "host") | ||
create_team(team_name, team_url, is_host) |
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
Empty file.
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
Oops, something went wrong.