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

Needs better error reporting for badly named filenames. #841

Open
s-pearce opened this issue Aug 5, 2021 · 0 comments
Open

Needs better error reporting for badly named filenames. #841

s-pearce opened this issue Aug 5, 2021 · 0 comments

Comments

@s-pearce
Copy link
Member

s-pearce commented Aug 5, 2021

When I ran unit tests locally, 3 errors/failures were thrown because a new ADCPAM calibration filename had 1 underscore in it instead of 2 before the calibration date. The error messages printed did not point to the exact problem and suggested that there was a cascading failure that was not caught.
The problem is that within the method:
asset-management/test/test_base.py > class: AssetManagementUnitTest > method: parse_cal_filename
a split statement that tries to split the filename by the double underscore within a try except block does not throw an exception when there aren't 2 underscores. It normally would return a list with 2 elements split by the 2 underscores, but instead, if the split function does not see the delimiter in a string, it returns the same string in a 1 element list. So instead of failing at the parse_cal_filename method, it fails outside of the method in the CalibrationFileUnitTest subclass when the method is called (here, here, and here). Instead it fails for ValueError where the output expects 2 items returned from the function but only one is returned. This then escapes the FileNameException exception clause and therefore does not accurately report the problem. Since the base function failed in 3 separate test functions, the single failure appears as 3.

Although it was relatively quick to figure out what the problem was, I recommend updating the parse_cal_filename method (and perhaps similar methods) to catch badly formed filenames by either checking that it splits the filename as expected, or perhaps using a regex to truly make sure a filename follows the intended format.
-Stuart

reedan88 added a commit that referenced this issue Mar 24, 2022
New Cal CSVs plus P18 cruise-specific Cal CSVs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant