Replies: 2 comments
|
Filed the two concrete cases so they are not lost while this is open, and so nobody picks one up before it is settled:
Both say on their face that they are not up for grabs and point back here. Once there is an answer they are small changes and anyone can take them. |
|
Both settled. Thank you for laying the three forms out with the sites, and for refusing the obvious answer: "pick one form" was what I would have said before reading this, and you are right that it makes six sites worse. Question 1: yes, that is the rule. Errno form when there is nothing to add, message string when there is. The two bare sites are the only ones that move. Two calls on the details you raised: No helper. Eight sites do not earn Do not retrofit So the rule to write down: a bare Question 2: take the cheap version.
Worth putting a comment at those sites saying the class is deliberately wrong and why, so the next reader does not "fix" it without knowing the cost. Unblocking #101 and #102 now, both yours if you want them. #101 is the bare-to-errno move at One note on #101 while you are in there: |
Uh oh!
There was an error while loading. Please reload this page.
#95 moved four raise sites to the three-argument errno form and left two questions
open. @kstonekuan asked for them here rather than in a review, since the second one
changes an exception type on a public API.
Where the tree stands on
main(2f07aa0), there are three forms in use.Three-argument errno form (4 sites).
storage.py:656,_bundle.py:861and:895,_deploy.py:153and:168.str(error)is[Errno 2] No such file or directory: '/x/y.py'.error.filenameis set, so a caller can branch on the path without parsing the message.
Explanatory message string (6 sites).
app.py:211,:802,:1093,:1101,curation.py:140,_bundle.py:823.str(error)is that sentence.error.filenameisNoneanderrnoisNone.Bare path (2 sites).
storage.py:344,testing.py:514.str(error)is the path and nothing else. This is the one #26 was filed about.The forms are not equally defensible, and I do not think the answer is "pick one".
The explanatory sites are the good case. Each says what was looked for and what to do
next, and none of them is a plain "this path is missing": the bundle one means
upwasnever run, the
curation.pyone means the location is not a catalog root. Collapsingthose into
[Errno 2]would lose the only useful part. What they do give up iserror.filename, which nothing in the tree reads today.The bare sites are the bad case, and there is a concrete symptom.
StorageRoot.fetchhas two implementations that answer the same failure differently:
LocalStorageRoot.fetch(storage.py:344) raises the bare path.BucketStorageRoot.fetch(storage.py:510) does not raise at all:obstore.headraises, so the text is obstore's and the repo does not control it.
fetch_uri(storage.py:656), one screen down and named for the same job, uses theerrno form.
So the same missing object produces a different message depending on which root the
data path resolved to. That is worth fixing whichever way the convention lands.
Question 1. Is the rule "errno form whenever there is nothing to add, message string
when there is"? If so the two bare sites move to errno, the six explanatory sites stay,
and the interesting part is whether the explanatory ones should also set
filename,which needs the errno form plus a message and is not one call:
That still prints
[Errno 2] no rendered bundle ..., so the prefix arrives whether ornot it helps. A small
_missing(path, why=None)helper in one module would make thechoice once. I do not know if that is worth a helper for eight sites.
Question 2.
--pipeline <a-directory>currently reports "No such file or directory"about a path that exists, because every site tests
is_file()and raises ENOENT on thefalse branch. The accurate error is
IsADirectoryError(EISDIR).IsADirectoryErroris a subclass ofOSError, not ofFileNotFoundError, so anyexcept FileNotFoundErroraround these calls stops catching it. In the tree that iscli.py:467,:525,:566,:588,:632,:684,:698,:710, plusapp.py:1092and
_compose.py:49. Every one of those would need widening toOSErroror to a tuple,and downstream code outside this repo would break in a way that only shows up on the
directory input, which is exactly the input nobody tests.
The cheap version keeps the type and fixes only the text:
str(error)is then[Errno 21] Is a directory: '/x/y', which is accurate, while theclass stays
FileNotFoundError, which is a lie about the class but keeps every existinghandler working. I lean this way for now and would rather raise the honest type in a
release that is already breaking something else.
Happy to send a PR for whichever shape you want, or to leave it if the answer is that
eight sites is not enough to justify a convention.
All reactions