-
Notifications
You must be signed in to change notification settings - Fork 280
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
Expand an exception catching #2851
Conversation
I guess I don't see why we couldn't have this be an issue linking to the try block in the original code, rather than adding all of these exceptions into the codebase? |
An issue might get outdated and make it harder to keep track of the problem. While if the code itself gets outdated however, that is, if a new undue exception happens in future contributions, it will get caught before it's too late. Does this sound reasonable ? |
I am not sure how an issue talking about how this code could be improved could get outdated? If it gets outdated because the code improves that means it is resolved. If it gets outdated because the code is removed that means it is resolved.
I am not sure what you mean? Catching a broad exception (like what was done originally) here is clear, and making a list like this makes it likely that we are going to miss some exception that isn't in the list. Then what happens? Also adding code like this that is clearly something that we intend to fix is intentionally adding a maintenance burden to the codebase, rather than to our issue list. We're already limited in our developer time. I don't think we should add code to the codebase that we intend to change like this. |
So for the record, I would agree to switch the PR to draft and then try to handle the issues in-situ over time, but this will be a long standing and I expect it will end up to be pretty complicated to review.
I want respectfully disagree on this point. I guess it is possible that catching each and every exception could make sense, but this is generally to be avoided. I think the list already contains a minimum of 4 exceptions that should not be caught because they signal an actual malfunction rather than a missing field of some sort. Keeping the |
So as concluded in private discussion, I now align with your comment that this could be solved in a single PR, so I'm switching this to draft and will start deactivating/solving stuff here. |
d0fdacb
to
a341f01
Compare
a341f01
to
98f5f95
Compare
1ad9367
to
36ac7f7
Compare
36ac7f7
to
bda2457
Compare
note for the future:
given at least one of the two sample dataset is present on disk. |
@munkm I'm now tempted to close this because it takes forever to solve the multiple problems this is meant to reveal and I don't want this PR to rot away for ages. I still believe it has some value in its current state because of the amount of time I spent expanding it and because merging this would also help reduce the amount of "magic" (and impossible to track down bugs) in the code base ever so slightly. In any case let me know what you think is best, I just don't want to keep this around anymore. |
Hmmmm. Ok let me think about it a bit. |
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.
LGTM! only one question about the code changes.
More generally, I agree with @munkm that introducing a change as a placeholder to fix later is not ideal but I think it's worth it here. Having the minimal set of exceptions explicitly listed will definitely help break up the work of figuring this out and encourage people to give it a go. I think if we opened an issue and left the general exception it would feel too overwhelming... But we should also have an issue open to remind us of this PR.
fd = fi.get_dependencies(ds=self.ds) | ||
except (NotImplementedError, Exception) as e: # noqa: B014 | ||
except blacklist as err: | ||
print(f"{err.__class__} raised for field {field}") |
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.
is there a reason for using print
here instead of mylog
?
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.
+1 to this.
Thank you Chris ! |
bf076cf
to
7f57c41
Compare
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.
After a conversation in the triage meeting last week I agree that this can be merged as long as we have a companion issue that links to the lines of code where all of these exceptions are added (in check_derived_fields
).
fd = fi.get_dependencies(ds=self.ds) | ||
except (NotImplementedError, Exception) as e: # noqa: B014 | ||
except blacklist as err: | ||
print(f"{err.__class__} raised for field {field}") |
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.
+1 to this.
Oh no... too late. This is now failing because we let some other PRs in that introduce |
4649de5
to
ca095d3
Compare
PR Summary
This one try block catches a lot of unrelated stuff so I'm expanding it explicitly as a better signal this should be refactored.
Edit (march 4 2021);
The plan for this PR, as discussed in today's triage meeting is to write an lasting issue for it, then merge the expansion.
note: there's a bug upstream in flake8-bugbear that crashes flake8 with the code I'm writing here (is it that bad ??)
PyCQA/flake8-bugbear#153
I think I'll need to fix this myself at some point
edit: I fixed it here PyCQA/flake8-bugbear#161
edit 2: and the fix is now part of bugbear 20.3.2 🎉