-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExitCodes refactoring so that their number fit in the range 0-255 #297
Conversation
…er fit between 0 and 255.
@MounaSafiHarab @nicolasbrossard I put you both to review this PR so it can make it to 19.1. Thank you!! |
uploadNeuroDB/NeuroDB/ExitCodes.pm
Outdated
|
||
7. Exit codes from DTIPrep/DTIPrepRegister.pl (exit codes from 120 to 139) | ||
6. Common other generic failures (exit codes from 80 to 149) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other common generic failures ;)
uploadNeuroDB/NeuroDB/ExitCodes.pm
Outdated
|
||
13. Exit codes from uploadNeuroDB/register_processed_data.pl (exit codes from | ||
240 to 259) | ||
11. Exit codes from uploadNeuroDB/minc_insertion.pl (exit codes from 180 to 189) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 I think ; so 12 and 13 below are off by 1 as well
@MounaSafiHarab I resolved your comments. Ready for another go. Once this is merged, I'll pull the changes to the other 19.1 PR so that the exit code exists with the proper number. Actually, I am going to add the need work before merging for the other one just to make sure. |
I checked if all the exit code constants that are used exist in ExitCodes.pm and they do. There are still uses of the exit function with hard-coded numeric values remaining though (DCMSUM.pm, Sawn.pm, etc..) Were they ignored on purpose? |
I just modified the exit codes for DCMSUM.pm, I somehow missed them... I also noticed I missed batch_upload_tarchive, which is fixed now. :) Everything under the MNI folder have not been modified since they are libraries coming from the MINC tools I think. As for the other scripts in dicom-archive, they all are old tools that we should probably move to the tools directory under an archive folder as I highly doubt they are being used by anyone. Some more spring cleaning for later! |
dicom-archive/DICOM/DCMSUM.pm
Outdated
} | ||
# do not allow to run diccomSummary with database option if the study has already been archived | ||
elsif (!$Archivemd5 && $row[3] ne "") { | ||
print "\n\n PROBLEM: This study has already been archived. You can only re-archive it using dicomTar!\n"; | ||
print " This is the information retained from the first time the study has been archived:\n $row[1]\n\n"; | ||
exit 33; } | ||
exit $NeuroDB::ExitCodes::FILE_NOT_UNIQUE; | ||
; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra set of ;
here
also not sure why the error is File_Not_Unique; is that really what is happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! Correcting the duplicated ;
For the exit code, that is what I undestand. The study archive (or file) has already been inserted into the database so is not unique (like on the tarchiveloader side with MINC files). Does that make sense?
dicom-archive/DICOM/DCMSUM.pm
Outdated
@@ -681,7 +684,7 @@ sub confirm_single_study { | |||
foreach my $studyUID (keys(%hash)) { | |||
print "'$studyUID'\n"; | |||
} | |||
exit 33; | |||
exit $NeuroDB::ExitCodes::FILE_TYPE_CHECK_FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nitpicking...
is this really a file_type failure? we happen to have files with 2 studyUIDs in the upload... so the file contents (headers) are wrong, but not the file type as it is DICOM...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a new exit code for NOT_A_SINGLE_STUDY.
uploadNeuroDB/NeuroDB/ExitCodes.pm
Outdated
our $MISSING_ARG = 3; # if missing script's argument(s) | ||
our $DB_SETTINGS_FAILURE = 4; # if DB settings in profile file are not set | ||
our $INVALID_PATH = 5; # if path to file or folder does not exist | ||
our $INVALID_ARG = 6; # if one of the program argument is invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguments
in plural
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MounaSafiHarab Thanks for the feedback! I think I resolved them. Let me know if you see anything else or if I missed something!
dicom-archive/DICOM/DCMSUM.pm
Outdated
} | ||
# do not allow to run diccomSummary with database option if the study has already been archived | ||
elsif (!$Archivemd5 && $row[3] ne "") { | ||
print "\n\n PROBLEM: This study has already been archived. You can only re-archive it using dicomTar!\n"; | ||
print " This is the information retained from the first time the study has been archived:\n $row[1]\n\n"; | ||
exit 33; } | ||
exit $NeuroDB::ExitCodes::FILE_NOT_UNIQUE; | ||
; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! Correcting the duplicated ;
For the exit code, that is what I undestand. The study archive (or file) has already been inserted into the database so is not unique (like on the tarchiveloader side with MINC files). Does that make sense?
dicom-archive/DICOM/DCMSUM.pm
Outdated
@@ -681,7 +684,7 @@ sub confirm_single_study { | |||
foreach my $studyUID (keys(%hash)) { | |||
print "'$studyUID'\n"; | |||
} | |||
exit 33; | |||
exit $NeuroDB::ExitCodes::FILE_TYPE_CHECK_FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a new exit code for NOT_A_SINGLE_STUDY.
uploadNeuroDB/NeuroDB/ExitCodes.pm
Outdated
our $MISSING_ARG = 3; # if missing script's argument(s) | ||
our $DB_SETTINGS_FAILURE = 4; # if DB settings in profile file are not set | ||
our $INVALID_PATH = 5; # if path to file or folder does not exist | ||
our $INVALID_ARG = 6; # if one of the program argument is invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
uploadNeuroDB/NeuroDB/ExitCodes.pm
Outdated
# -clobber was not set | ||
our $UNKNOWN_PROTOCOL = 84; # if could not find acquisition protocol | ||
# protocol of the file to be inserted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too too many many protocol protocol.... :)
I checked and there are no more uses of exit with a numeric literal. 👍 |
it is good by me, waiting on @nicolasbrossard feedback |
All my comments were addressed. Approving. |
me too, so am merging. |
As @nicolasbrossard pointed out in PR #289, the exit codes are limited to the range 0-255. If a value outside that range is used as an exit code, it is truncated to 8 bits.
In order to refactor this, the follow google doc has been created to map the old and new exit codes:
https://docs.google.com/spreadsheets/d/1QsDQl9rXvut6Li62Rba7iUFRBT8mq6bDfX9JjYRsVQY/edit#gid=0
NOTE: since the exit codes were not yet part of any release, it is the perfect time to refactor them within the upcoming release of 19.1.
Redmine ticket: https://redmine.cbrain.mcgill.ca/issues/14247