-
Notifications
You must be signed in to change notification settings - Fork 4
Address corner case bugs in the check access and get file size helpers in fileio.py
#379
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
Address corner case bugs in the check access and get file size helpers in fileio.py
#379
Conversation
|
I think these changes ought to be covered by a regression test. |
I agree and they will be in PR #377 as e.g. with the commented out line with a matching TODO in The other ones in the check access helpers like in |
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
5d8e46f to
6e2be74
Compare
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
6e2be74 to
f338c2a
Compare
albu-diku
left a comment
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'd like to see a test being enabled/changed as part of this commit so that the fix is covered by a regression test.
f338c2a to
9d67fa4
Compare
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
9d67fa4 to
7e61e24
Compare
* Switch from old `setUp` to `before_each` init structure using 'testconfig' * Replace direct `os.makedirs` calls with the `ensure_dirs_exist` helper * Converge on string constants for almost everything and greater reuse * Strip dir-prefix part of path constants and adjust asserts accordingly Please note that make unittest still fails the three tests of #378 yet to be fixed by #379.
…in the PR review. Rebased after merging #377.
7e61e24 to
7cfe979
Compare
|
Rebased after merging #377 and I'll proceed with merging when CI completes since the previous reviews already cover the code in question. |
| """Write message to notify home""" | ||
| if not logger: | ||
| logger = null_logger("dummy") | ||
| filepath = 'UNDEFINED' |
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.
In the case of an excetion being thrown, will we not now try to remove a file named UNDEFINED in whatever the cwd happens to be?
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.
Yes, it will effectively try/except on os.remove('UNDEFINED') and fail silently when no such file exists in the cwd - i.e. the mig user home for deployed use.
We could of course make it conditional in the catch-all clean up handler or change filepath to something even more ridiculously improbable if it's a concern.
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.
Yeah - for me that is clearly explicit is better than implcit, and relying on an exception because we chose
a non-existent name is pretty implicit. I think it is generally better not to attempt a remove when we already know the file can't exist - in this case an empty or None path would be better than a UNDEFINED.
A bare remove like this relies pretty heavily on cwd being the user home, which - while the intent might be true - that is not clear to a reader here and I think it is reasonable to view with some suspicion.
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'd say the reliance is less on the CWD than on the fact that trying to remove a file called 'UNDEFINED' anywhere (most likely in mig-user home) will not cause trouble.
Yet, I addressed it directly with an absolute non-existent path in
5a6fc1a
since this PR was already merged.
Address a few corner case bugs in the check access and get file size helpers of the
fileio.pymodule as explained in issue #378 and covered by the unit tests in PR #377.Addresses a couple of old unrelated pylint
used-before-assignmentwarnings to make linting actions happy.