Skip to content
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

Merged
merged 5 commits into from
Apr 23, 2018

Conversation

cmadjar
Copy link
Collaborator

@cmadjar cmadjar commented Apr 11, 2018

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

@cmadjar
Copy link
Collaborator Author

cmadjar commented Apr 11, 2018

@MounaSafiHarab @nicolasbrossard I put you both to review this PR so it can make it to 19.1. Thank you!!


7. Exit codes from DTIPrep/DTIPrepRegister.pl (exit codes from 120 to 139)
6. Common other generic failures (exit codes from 80 to 149)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other common generic failures ;)


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)
Copy link
Contributor

@MounaSafiHarab MounaSafiHarab Apr 12, 2018

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

@cmadjar
Copy link
Collaborator Author

cmadjar commented Apr 12, 2018

@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.

@nicolasbrossard
Copy link
Collaborator

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?

@cmadjar
Copy link
Collaborator Author

cmadjar commented Apr 16, 2018

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!

}
# 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;
; }
Copy link
Contributor

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?

Copy link
Collaborator Author

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?

@@ -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;
Copy link
Contributor

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...

Copy link
Collaborator Author

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguments in plural

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator Author

@cmadjar cmadjar left a 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!

}
# 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;
; }
Copy link
Collaborator Author

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?

@@ -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;
Copy link
Collaborator Author

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.

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# -clobber was not set
our $UNKNOWN_PROTOCOL = 84; # if could not find acquisition protocol
# protocol of the file to be inserted
Copy link
Collaborator

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.... :)

@nicolasbrossard
Copy link
Collaborator

I checked and there are no more uses of exit with a numeric literal. 👍

@MounaSafiHarab
Copy link
Contributor

it is good by me, waiting on @nicolasbrossard feedback

@nicolasbrossard
Copy link
Collaborator

All my comments were addressed. Approving.

@MounaSafiHarab
Copy link
Contributor

me too, so am merging.

@MounaSafiHarab MounaSafiHarab merged commit 9072bd6 into aces:minor Apr 23, 2018
@cmadjar cmadjar deleted the RefactoringExitCodes branch May 31, 2018 15:19
@cmadjar cmadjar added this to the 20.0 (previously called 19.2) milestone Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants