Skip to content

Commit e85e5ca

Browse files
RishabhJain2018deshraj
authored andcommitted
Challenges: Remove unnecessary logger exceptions in challenge creation API and worker (Cloud-CV#2155)
1 parent d512a7a commit e85e5ca

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

apps/challenges/views.py

+3-24
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,9 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
573573
with open(join(BASE_LOCATION, unique_folder_name, yaml_file), "r") as stream:
574574
yaml_file_data = yaml.safe_load(stream)
575575
except (yaml.YAMLError, ScannerError) as exc:
576-
message = 'Error in creating challenge. Please check the yaml configuration!'
577576
response_data = {
578-
'error': message
577+
'error': exc
579578
}
580-
logger.exception(exc)
581579
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
582580

583581
# Check for evaluation script path in yaml file.
@@ -593,7 +591,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
593591
response_data = {
594592
'error': message
595593
}
596-
logger.exception(message)
597594
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
598595

599596
# Check for evaluation script file in extracted zip folder.
@@ -607,7 +604,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
607604
response_data = {
608605
'error': message
609606
}
610-
logger.exception(message)
611607
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
612608

613609
# Check for test annotation file path in yaml file.
@@ -619,7 +615,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
619615
response_data = {
620616
'error': message
621617
}
622-
logger.exception(message)
623618
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
624619

625620
for data in challenge_phases_data:
@@ -636,7 +631,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
636631
response_data = {
637632
'error': message
638633
}
639-
logger.exception(message)
640634
return Response(
641635
response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
642636

@@ -647,7 +641,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
647641
response_data = {
648642
'error': message
649643
}
650-
logger.exception(message)
651644
return Response(
652645
response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
653646

@@ -683,7 +676,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
683676
response_data = {
684677
'error': message
685678
}
686-
logger.exception(message)
687679
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
688680

689681
# check for evaluation details file
@@ -707,7 +699,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
707699
response_data = {
708700
'error': message
709701
}
710-
logger.exception(message)
711702
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
712703

713704
# check for terms and conditions file
@@ -729,7 +720,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
729720
response_data = {
730721
'error': message
731722
}
732-
logger.exception(message)
733723
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
734724

735725
# check for submission guidelines file
@@ -752,7 +742,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
752742
response_data = {
753743
'error': message
754744
}
755-
logger.exception(message)
756745
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
757746

758747
# Check for leaderboard schema in YAML file
@@ -776,23 +765,20 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
776765
response_data = {
777766
'error': message
778767
}
779-
logger.exception(message)
780768
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
781769
if 'labels' not in leaderboard_schema[0].get('schema'):
782770
message = ('There is no \'labels\' key in leaderboard '
783771
'schema. Please add it and then try again!')
784772
response_data = {
785773
'error': message
786774
}
787-
logger.exception(message)
788775
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
789776
else:
790777
message = ('There is no key \'leaderboard\' '
791778
'in the YAML file. Please add it and then try again!')
792779
response_data = {
793780
'error': message
794781
}
795-
logger.exception(message)
796782
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
797783

798784
try:
@@ -897,7 +883,6 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
897883
response_data = {
898884
'error': message
899885
}
900-
logger.exception(message)
901886
return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
902887

903888
for data in challenge_phase_splits_data:
@@ -963,14 +948,8 @@ def create_challenge_using_zip_file(request, challenge_host_team_pk):
963948
shutil.rmtree(BASE_LOCATION)
964949
logger.info('Zip folder is removed')
965950
except:
966-
logger.exception('Zip folder for challenge {} is not removed from location'.format(challenge.pk,
967-
BASE_LOCATION))
968-
try:
969-
shutil.rmtree(BASE_LOCATION)
970-
logger.info('Zip folder is removed')
971-
except:
972-
logger.info('Zip folder for challenge {} is not removed from location'.format(challenge.pk,
973-
BASE_LOCATION))
951+
logger.exception('Zip folder for challenge {} is not removed from {} location'.format(
952+
challenge.pk, BASE_LOCATION))
974953

975954

976955
@throttle_classes([UserRateThrottle])

0 commit comments

Comments
 (0)