-
Notifications
You must be signed in to change notification settings - Fork 244
Python versions testing & support: drop 3.9, add 3.14 #5412
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
base: master
Are you sure you want to change the base?
Conversation
af670a0 to
d092e76
Compare
adamnovak
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.
This looks pretty good, but I'm overall negative on the auto-walrus-ification.
Most of the places where the tool is adding it get better, but some get worse, which I think means we can't put the tool in the same code translation pass as we use when upgrading Python versions and we need to treat its output as suggestions.
Some places where it kicks in are probably places that should eventually be refactored so you no longer need the offending variable, though probably not in this PR.
src/toil/leader.py
Outdated
| """ | ||
| maxJobDuration = self.config.maxJobDuration | ||
| jobsToKill = [] | ||
| if ( | ||
| maxJobDuration < 10000000 | ||
| ): # We won't bother doing anything if rescue time > 16 weeks. | ||
| maxJobDuration := self.config.maxJobDuration | ||
| ) < 10000000: # We won't bother doing anything if rescue time > 16 weeks. |
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'm not sure that, just because maxJobDuration happens not to be used outside the conditional, this is clearer code. We don't need a variable for this at all because it's not slow to compute. We're using one to reduce the number of moving parts we need to account for at a time, by grabbing the concept by a short name and keeping self and config out of our minds later.
But then when we try to do that at the same time as the comparison, now we have a statement that has 7 moving parts instead of two with 5 and 3 each, and 7 moving parts is starting to bump up against working memory. Especially if you have to worry about what's in the body and why.
Plus, the pragmatics of the walrus I think are something along the lines of "I need to generate this thing and work on it", and that's not what's happening here. The condition body isn't about processing maxJobDuration; we're using the condition to bail out early on the processing of something else. Probably what we really want is:
maxJobDuration = self.config.maxJobDuration
if maxJobDuration >= 10000000:
# We won't bother doing anything if rescue time > 16 weeks.
return
... other code using maxJobDuration ...
Then we can save a level of indentation. And maybe that could use a walrus (are we meant to use it when we want to define-and-validate for later code?).
It looks like auto-walrus doesn't have any notion of a complexity limit besides line length, and if we're also wrapping our lines properly I'm not sure it can hit a sensible line length limit. So I'm not sure we want to use it and take all its suggestions whenever we bump Python versions.
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 can drop the auto-walrus changes, if you'd like
| localID = self.handleLocalJob(command, jobNode) | ||
| if localID is not None: |
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.
Another place where I'm not sure it makes pragmatic sense to use the walrus is in cases where the assignment isn't meant to populate the variable but is primarily there for its side effects. Here, handleLocalJob is meant to do a bunch of work, and incidentally we need to save its return value so we can tell if it actually did the work, and so we can pass it along.
I'm not sure this makes more sense when the job handling happens as a side effect of the conditional.
The right design here is probably to move the responsibility for assessing whether a job actually is local out of handleLocalJob(), maybe into a separate helper method. Then handleLocalJob()'s return value can just get unconditionally returned in the cases where we need to call it, and we won't need to store any condition predicates to variables at all.
d0b3640 to
c0596ea
Compare
Which fixes the docs build
c0596ea to
e968716
Compare
|
@adamnovak Can you build and upload a new version of PR to update And then |
e968716 to
9fdee4f
Compare
adamnovak
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've updated the CI images and written the CI bypass commit out of this PR.
I think this is good to merge now. We probably wanted some of those walruses, but we don't need them.
|
When the tests pass, I'm going to force this as separate commits, so that just the mass reformatting commit ID can be noted in .git-blame-ignore-revs |
|
Looks like one of the WDL tests failed ( |
|
There's also a failing WDL conformance test in Probably I managed to merge that without it actually working right, somehow, and I need to add that WDL conformance test to the ones to skip because they aren't implemented. |
Changelog Entry
To be copied to the draft changelog by merger:
Reviewer Checklist
issues/XXXX-fix-the-thingin the Toil repo, or from an external repo.camelCasethat want to be insnake_case.docs/running/{cliOptions,cwl,wdl}.rstMerger Checklist