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

Wait for GHA eval results instead of falling back to local evaluation #451

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GaetanLepage
Copy link
Contributor

@GaetanLepage GaetanLepage commented Jan 5, 2025

The default evaluation mode (github) attempts at fetching the evaluation results from the GitHub actions result.
Those will only be available a few minutes after the PR has been opened as they are not trivial to compute.

Currently, if the results are not available right away, nixpkgs-review falls back to local evaluation.
This PR changes this behavior. Now it will keep re-trying until the results are available.

Note: It is still possible to force local evaluation by using --eval local.

Motivation: Local evaluation is very resource-intensive (especially RAM). It should be an opt-in behavior.
This new approach is more predictable.

Questions:

  • Does this work (at all) ?
  • Is 10s a good value for the timeout ? -> Switched to 30s. Still open to feedback.
  • Should we add a maximum amount of retries ?
  • Handle Ctrl-C correctly (i.e. properly delete the worktree on exit)

@GaetanLepage
Copy link
Contributor Author

Maybe we should silence the warning:

image

@GaetanLepage
Copy link
Contributor Author

This implementation is quite naive. We could eventually wait within the function and thus not restarting the fetching process from scratch each time.

packages_per_system = self.github_client.get_github_action_eval_result(pr)
timeout: int = 30
while packages_per_system is None:
print(f"...Results are not (yet) available. Retrying in {timeout}s")
Copy link
Owner

@Mic92 Mic92 Jan 5, 2025

Choose a reason for hiding this comment

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

Maybe just print this message just once and just add a dot add the end each time it's not finished to indicate progress.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea ! Done.

if packages_per_system is not None:
print("-> Successfully fetched rebuilds: no local evaluation needed")
packages_per_system = self.github_client.get_github_action_eval_result(pr)
timeout: int = 30
Copy link
Owner

Choose a reason for hiding this comment

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

I'd say 10s here. We have a fair amount of requests we can do our token.

@GaetanLepage
Copy link
Contributor Author

Maybe we should silence the warning:

I removed them all. Do you have a better idea ?


packages_per_system = self.github_client.get_github_action_eval_result(pr)
Copy link
Owner

Choose a reason for hiding this comment

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

I believe this also returns None if the evaluation failed. However in this case we shouldn't wait as we would wait forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we crash in this case then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be another reason why we would want to wait 'within' the github function. I.e. we would wait only in the case where we know that the results are currently computed.

@GaetanLepage GaetanLepage force-pushed the wait branch 4 times, most recently from 471bd4f to 0247365 Compare January 5, 2025 14:08
timeout: int = 10
print(f"...Results are not (yet) available. Retrying in {timeout}s")
while packages_per_system is None:
print(".", end="")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work. Nothing is printed. If I remove end = "", it works.

Copy link
Owner

Choose a reason for hiding this comment

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

I think it's line buffered. Try flushing sys.stdout.flush()

nixpkgs_review/review.py Outdated Show resolved Hide resolved
@GaetanLepage
Copy link
Contributor Author

I confirm that printing is fixed:
image

@GaetanLepage
Copy link
Contributor Author

Should we add a tip:
"Use --eval local if you prefer running the evaluation locally."
?

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