def submit(ctx, file): """ Make submission to a challenge. """ """ Invoked by running `evalai challenge CHALLENGE phase PHASE submit FILE` """ submission_metadata = {} if click.confirm("Do you want to include the Submission Details?"): submission_metadata["method_name"] = click.prompt(style("Method Name", fg="green"), type=str, default="") submission_metadata["method_description"] = click.prompt(style( "Method Description", fg="green"), type=str, default="") submission_metadata["project_url"] = click.prompt(style("Project URL", fg="green"), type=str, default="") submission_metadata["publication_url"] = click.prompt(style( "Publication URL", fg="green"), type=str, default="") make_submission(ctx.challenge_id, ctx.phase_id, file, submission_metadata)
def submit(ctx, file, annotation, large, public, private): """ For uploading submission files to evalai: - Invoked by running 'evalai challenge CHALLENGE phase PHASE submit --file FILE' - For large files, add a '--large' option at the end of the command For uploading test annotation files to evalai: - Invoked by running "evalai challenge CHALLENGE phase PHASE submit --file FILE --annotation" Arguments: ctx (class click.Context) -- The context object which holds state of the invocation file (str) -- the path of the file to be uploaded annotations (boolean) -- flag to denote if file is a test annotation file large (boolean) -- flag to denote if submission file is large (if large, presigned urls are used for uploads) public (boolean) -- flag to denote if submission is public private (boolean) -- flag to denote if submission is private Returns: None """ if public and private: message = "\nError: Submission can't be public and private.\nPlease select either --public or --private" notify_user(message, color="red") else: if annotation: upload_file_using_presigned_url(ctx.phase_id, file, "annotation") else: submission_metadata = {} if public: submission_metadata["is_public"] = json.dumps(True) elif private: submission_metadata["is_public"] = json.dumps(False) else: submission_metadata["is_public"] = None if click.confirm("Do you want to include the Submission Details?"): 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="" ) if large: upload_file_using_presigned_url(ctx.phase_id, file, "submission", submission_metadata) else: make_submission(ctx.challenge_id, ctx.phase_id, file, submission_metadata)
def submit(ctx, file, annotation, large): """ For uploading submission files to evalai: - Invoked by running 'evalai challenge CHALLENGE phase PHASE submit --file FILE' - For large files, add a '--large' option at the end of the command For uploading test annotation files to evalai: - Invoked by running "evalai challenge CHALLENGE phase PHASE submit --file FILE --annotation" Arguments: ctx (class click.Context) -- The context object which holds state of the invocation file (str) -- the path of the file to be uploaded annotations (boolean) -- flag to denote if file is a test annotation file large (boolean) -- flag to denote if submission file is large (if large, presigned urls are used for uploads) Returns: None """ if annotation: upload_file_using_presigned_url(ctx.phase_id, file, "annotation") else: submission_metadata = {} if click.confirm("Do you want to include the Submission Details?"): 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="" ) if large: upload_file_using_presigned_url(ctx.phase_id, file, "submission", submission_metadata) else: make_submission(ctx.challenge_id, ctx.phase_id, file, submission_metadata)
def submit(ctx, file, annotation, large, public, private): """ For uploading submission files to evalai: - Invoked by running 'evalai challenge CHALLENGE phase PHASE submit --file FILE' - For large files, add a '--large' option at the end of the command For uploading test annotation files to evalai: - Invoked by running "evalai challenge CHALLENGE phase PHASE submit --file FILE --annotation" Arguments: ctx (class click.Context) -- The context object which holds state of the invocation file (str) -- the path of the file to be uploaded annotations (boolean) -- flag to denote if file is a test annotation file large (boolean) -- flag to denote if submission file is large (if large, presigned urls are used for uploads) public (boolean) -- flag to denote if submission is public private (boolean) -- flag to denote if submission is private Returns: None """ if public and private: message = "\nError: Submission can't be public and private.\nPlease select either --public or --private" notify_user(message, color="red") else: if annotation: upload_file_using_presigned_url(ctx.phase_id, file, "annotation") else: submission_metadata = {} if public: submission_metadata["is_public"] = json.dumps(True) elif private: submission_metadata["is_public"] = json.dumps(False) else: submission_metadata["is_public"] = None if click.confirm("Do you want to include the Submission Details?"): 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="") submission_meta_attributes = get_submission_meta_attributes( ctx.challenge_id, ctx.phase_id) submission_attribute_metadata = [] if (submission_meta_attributes and len(submission_meta_attributes) > 0): if click.confirm( "Do you want to include the Submission Metadata?"): for attribute in submission_meta_attributes: attribute_type = attribute["type"] attribute_name = attribute["name"] attribute_description = attribute["description"] attribute_required = attribute.get("required") if attribute_required: attribute_name = attribute_name + '*' value = None message = "{} ({})".format(attribute_name, attribute_description) if attribute_type == "text": while True: value = click.prompt( style(message, fg="yellow"), type=str, default="", ) if not attribute_required or value != "": break echo("Error: {} is a required field".format( attribute["name"])) if attribute_type == "boolean": while True: value = click.prompt(style(message, fg="yellow"), type=bool, default="") if not attribute_required or value != "": break echo("Error: {} is a required field".format( attribute["name"])) if attribute_type == "radio": while True: value = click.prompt(style( "{}:\nChoices:{}".format( message, attribute["options"]), fg="yellow", ), type=click.Choice( attribute["options"]), default="") if not attribute_required or value != "": break echo("Error: {} is a required field".format( attribute["name"])) if attribute_type == "checkbox": option_chosen = True while option_chosen: value = [] choices = click.prompt(style( "{}:\nChoices(separated by comma):{}". format(message, attribute["options"]), fg="yellow", ), type=str, show_default=False, default="") if choices != "": choices = [ choice.strip(" ") for choice in choices.split(",") ] else: choices = [] option_chosen = False if attribute_required and len(choices) == 0: echo( "Error: {} is a required field. Please select atleast one option" .format(attribute["name"])) option_chosen = True for choice in choices: if choice in attribute["options"]: value.append(choice) option_chosen = False else: echo( "Error: Choose correct value(s) from the given options only" ) option_chosen = True break submission_attribute_metadata.append( {attribute_name: value}) if large: upload_file_using_presigned_url(ctx.phase_id, file, "submission", submission_metadata) else: make_submission( ctx.challenge_id, ctx.phase_id, file, submission_metadata, submission_attribute_metadata, )