2
2
import json
3
3
4
4
from click import style
5
+ from click .utils import echo
5
6
6
7
from evalai .utils .auth import get_host_url
7
- from evalai .utils .common import Date , notify_user , upload_file_using_presigned_url
8
+ from evalai .utils .common import (
9
+ Date ,
10
+ notify_user ,
11
+ upload_file_using_presigned_url ,
12
+ )
8
13
from evalai .utils .challenges import (
9
14
display_all_challenge_list ,
10
15
display_future_challenge_list ,
17
22
display_challenge_phase_split_list ,
18
23
display_leaderboard ,
19
24
)
20
- from evalai .utils .submissions import display_my_submission_details
25
+ from evalai .utils .submissions import (
26
+ display_my_submission_details ,
27
+ get_submission_meta_attributes ,
28
+ )
21
29
from evalai .utils .teams import participate_in_a_challenge
22
30
from evalai .utils .submissions import make_submission
23
31
from evalai .utils .urls import URLS
@@ -205,11 +213,19 @@ def participate(ctx, team):
205
213
"""
206
214
Invoked by running `evalai challenge CHALLENGE participate TEAM`
207
215
"""
208
- terms_and_conditions_page_url = "{}{}" .format (get_host_url (), URLS .terms_and_conditions_page .value )
209
- terms_and_conditions_page_url = terms_and_conditions_page_url .format (ctx .challenge_id )
210
- message = "Please refer challenge terms and conditions here: {}" \
211
- "\n \n By agreeing to participate in the challenge, you are agreeing to terms and conditions." \
212
- "\n \n Do you accept challenge terms and conditions?" .format (terms_and_conditions_page_url )
216
+ terms_and_conditions_page_url = "{}{}" .format (
217
+ get_host_url (), URLS .terms_and_conditions_page .value
218
+ )
219
+ terms_and_conditions_page_url = terms_and_conditions_page_url .format (
220
+ ctx .challenge_id
221
+ )
222
+ message = (
223
+ "Please refer challenge terms and conditions here: {}"
224
+ "\n \n By agreeing to participate in the challenge, you are agreeing to terms and conditions."
225
+ "\n \n Do you accept challenge terms and conditions?" .format (
226
+ terms_and_conditions_page_url
227
+ )
228
+ )
213
229
if click .confirm (message ):
214
230
participate_in_a_challenge (ctx .challenge_id , team )
215
231
else :
@@ -224,7 +240,10 @@ def participate(ctx, team):
224
240
@click .option ("--public" , is_flag = True )
225
241
@click .option ("--private" , is_flag = True )
226
242
@click .option (
227
- "--file" , type = click .File ("rb" ), required = True , help = "File path to the submission or annotation file"
243
+ "--file" ,
244
+ type = click .File ("rb" ),
245
+ required = True ,
246
+ help = "File path to the submission or annotation file" ,
228
247
)
229
248
def submit (ctx , file , annotation , large , public , private ):
230
249
"""
@@ -264,18 +283,138 @@ def submit(ctx, file, annotation, large, public, private):
264
283
style ("Method Name" , fg = "yellow" ), type = str , default = ""
265
284
)
266
285
submission_metadata ["method_description" ] = click .prompt (
267
- style ("Method Description" , fg = "yellow" ), type = str , default = ""
286
+ style ("Method Description" , fg = "yellow" ),
287
+ type = str ,
288
+ default = "" ,
268
289
)
269
290
submission_metadata ["project_url" ] = click .prompt (
270
291
style ("Project URL" , fg = "yellow" ), type = str , default = ""
271
292
)
272
293
submission_metadata ["publication_url" ] = click .prompt (
273
294
style ("Publication URL" , fg = "yellow" ), type = str , default = ""
274
295
)
296
+ submission_meta_attributes = get_submission_meta_attributes (
297
+ ctx .challenge_id , ctx .phase_id
298
+ )
299
+ submission_attribute_metadata = []
300
+ if (
301
+ submission_meta_attributes
302
+ and len (submission_meta_attributes ) > 0
303
+ ):
304
+ if click .confirm (
305
+ "Do you want to include the Submission Metadata?"
306
+ ):
307
+ for attribute in submission_meta_attributes :
308
+ attribute_type = attribute ["type" ]
309
+ attribute_name = attribute ["name" ]
310
+ attribute_description = attribute ["description" ]
311
+ attribute_required = attribute .get ("required" )
312
+ if attribute_required :
313
+ attribute_name = attribute_name + '*'
314
+ value = None
315
+ message = "{} ({})" .format (
316
+ attribute_name , attribute_description
317
+ )
318
+ if attribute_type == "text" :
319
+ while True :
320
+ value = click .prompt (
321
+ style (message , fg = "yellow" ),
322
+ type = str ,
323
+ default = "" ,
324
+ )
325
+ if not attribute_required or value != "" :
326
+ break
327
+ echo (
328
+ "Error: {} is a required field" .format (
329
+ attribute ["name" ]
330
+ )
331
+ )
332
+ if attribute_type == "boolean" :
333
+ while True :
334
+ value = click .prompt (
335
+ style (message , fg = "yellow" ), type = bool , default = ""
336
+ )
337
+ if not attribute_required or value != "" :
338
+ break
339
+ echo (
340
+ "Error: {} is a required field" .format (
341
+ attribute ["name" ]
342
+ )
343
+ )
344
+ if attribute_type == "radio" :
345
+ while True :
346
+ value = click .prompt (
347
+ style (
348
+ "{}:\n Choices:{}" .format (
349
+ message , attribute ["options" ]
350
+ ),
351
+ fg = "yellow" ,
352
+ ),
353
+ type = click .Choice (attribute ["options" ]),
354
+ default = ""
355
+ )
356
+ if not attribute_required or value != "" :
357
+ break
358
+ echo (
359
+ "Error: {} is a required field" .format (
360
+ attribute ["name" ]
361
+ )
362
+ )
363
+ if attribute_type == "checkbox" :
364
+ option_chosen = True
365
+ while option_chosen :
366
+ value = []
367
+ choices = click .prompt (
368
+ style (
369
+ "{}:\n Choices(separated by comma):{}" .format (
370
+ message , attribute ["options" ]
371
+ ),
372
+ fg = "yellow" ,
373
+ ),
374
+ type = str ,
375
+ show_default = False ,
376
+ default = ""
377
+ )
378
+ if choices != "" :
379
+ choices = [
380
+ choice .strip (" " )
381
+ for choice in choices .split ("," )
382
+ ]
383
+ else :
384
+ choices = []
385
+ option_chosen = False
386
+ if attribute_required and len (choices ) == 0 :
387
+ echo (
388
+ "Error: {} is a required field. Please select atleast one option" .format (
389
+ attribute ["name" ]
390
+ )
391
+ )
392
+ option_chosen = True
393
+ for choice in choices :
394
+ if choice in attribute ["options" ]:
395
+ value .append (choice )
396
+ option_chosen = False
397
+ else :
398
+ echo (
399
+ "Error: Choose correct value(s) from the given options only"
400
+ )
401
+ option_chosen = True
402
+ break
403
+ submission_attribute_metadata .append (
404
+ {attribute_name : value }
405
+ )
275
406
if large :
276
- upload_file_using_presigned_url (ctx .phase_id , file , "submission" , submission_metadata )
407
+ upload_file_using_presigned_url (
408
+ ctx .phase_id , file , "submission" , submission_metadata
409
+ )
277
410
else :
278
- make_submission (ctx .challenge_id , ctx .phase_id , file , submission_metadata )
411
+ make_submission (
412
+ ctx .challenge_id ,
413
+ ctx .phase_id ,
414
+ file ,
415
+ submission_metadata ,
416
+ submission_attribute_metadata ,
417
+ )
279
418
280
419
281
420
challenge .add_command (phase )
0 commit comments