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

task iteration improvements #16

Merged
merged 1 commit into from
May 27, 2021

Conversation

oliver-sanders
Copy link

No description provided.

return {
itask for itask in itasks
if self._match_ext_trigger(itask)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saves building and destroying an intermediate list.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems I wasn't aware of the existence of set comphrehensions (until a recent previous review, anyway) .. 🤦

Comment on lines +1756 to +1765
if any(
itask for itask in self.pool.get_tasks()
if itask.state(
TASK_STATUS_PREPARING,
TASK_STATUS_SUBMITTED,
TASK_STATUS_RUNNING
)
or (itask.state(TASK_STATUS_WAITING)
and not itask.state.is_runahead)
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will stop iterating on the first match.

TASK_STATUS_EXPIRED
)
or itask.is_manual_submit
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification, avoids building and destroying intermediate lists.

Comment on lines +324 to +332
if points or all(
not itask.state(
TASK_STATUS_FAILED,
TASK_STATUS_SUCCEEDED,
TASK_STATUS_EXPIRED
):
has_unfinished_itasks = True
break
if not points and not has_unfinished_itasks:
# We need to begin with an unfinished cycle point.
continue
points.append(point)
)
for itask in itasks
):
points.append(point)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to iterate itasks if not points.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Except that should be any() not all())

Comment on lines +397 to +403
for itask in (
itask
for point, itask_id_map in self.main_pool.items()
for itask in itask_id_map.values()
if point <= latest_allowed_point
if itask.state.is_runahead
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saves building and destroying intermediate list.

Copy link
Owner

@hjoliver hjoliver May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this one broke some tests, which did my head in for a bit because I could not see how your code could give a different result. The problem is, the release_runahead_tasks() call inside the loop can sometimes result in the dictionary changing size during iteration (because: parent-less tasks get spawned when their previous instance gets released from runahead-limiting). So the intermediate list is necessary here. I'll insert a comment to explain why, for future reference.

Copy link
Owner

@hjoliver hjoliver May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The original can still be improved a bit though: use your version to build the list).

Comment on lines +374 to +377
satisfied = {
itask for itask in itasks
if itask.state.xtriggers_all_satisfied()
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saves building and destroying intermediate list.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Copy link
Owner

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for straightening out my bad coding 😓

@hjoliver hjoliver merged commit c85155b into hjoliver:pflag-refactor May 27, 2021
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

Successfully merging this pull request may close these issues.

2 participants