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

Make precomputing fail more usefully #7994

Merged

Conversation

blorente
Copy link
Contributor

@blorente blorente commented Jul 2, 2019

Problem

DaemonPantsRunner precomputes the v2 graph products at creation time (before run). If that raised an exception, it would store a return code of 1, run normally, and then exit with 1 at the end:

class DaemonPantsRunner:
...
  def run(self):
    ....
    else:
        self._exiter.exit(self.**exit_code** if self.exit_code else PANTS_SUCCEEDED_EXIT_CODE)

This hints that the behaviour that we want is to actually fail the run if the precomputation fails. If that is the case, we would like to fail more usefully, with a real exception.

Solution

Create a wrapper exception type that wraps whatever error happened in the precomputation. Then, in DPR.run(), re-raise this deferred exception immediately after setting up logging and stdio channels.

Result

What before seemed to succeed and returned 1, should now return a proper exception.

@@ -102,6 +102,21 @@ def exit_code(self):
return self._exit_code


class _PantsProductPrecomputeFailed(Exception):
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

So, at a fundamental level, there is no need to "precompute" or "warm" anything anymore. So we should actually be able to delete the warming codepath entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO :)

Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks. Would be good to revisit this in a form that we're less worried about cherry-picking.


# TODO This can probably be moved to the try:except block in DaemonPantsRunner.run() function
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Linking to a ticket that explains why, or expanding the description here would be good. There is definitely dead code in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #8002, I hope it's enough for most people to pick up, but would definitely love feedback to make it more approachable.

@Eric-Arellano
Copy link
Contributor

Oh no, just noticed the needs cherry-pick label 😢 this can't use Py3 features like f-strings if this needs to be included in 1.17.x.

Copy link
Contributor

@ity ity left a comment

Choose a reason for hiding this comment

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

ah, looks like you have enough comments re: py2 vs 3 - lgtm otherwise!

src/python/pants/bin/daemon_pants_runner.py Outdated Show resolved Hide resolved
@blorente blorente force-pushed the blorente/make-precomputing-fail-properly branch from dce73e1 to 4470df9 Compare July 3, 2019 11:00
@blorente
Copy link
Contributor Author

blorente commented Jul 4, 2019

I added some unit tests for these specific cases, if CI is green I will merge tomorrow.

@blorente blorente merged commit f44f2c0 into pantsbuild:master Jul 5, 2019
@blorente blorente deleted the blorente/make-precomputing-fail-properly branch July 5, 2019 16:37
blorente added a commit to blorente/pants that referenced this pull request Jul 5, 2019
**Problem**
DaemonPantsRunner precomputes the v2 graph products at creation time (before run). If that raised an exception, it would store a return code of 1, run normally, and then exit with 1 at the end:

class DaemonPantsRunner:
...
  def run(self):
    ....
    else:
        self._exiter.exit(self.**exit_code** if self.exit_code else PANTS_SUCCEEDED_EXIT_CODE)
This hints that the behaviour that we want is to actually fail the run if the precomputation fails. If that is the case, we would like to fail more usefully, with a real exception.

**Solution**
Create a wrapper exception type that wraps whatever error happened in the precomputation. Then, in DPR.run(), re-raise this deferred exception immediately after setting up logging and stdio channels.

**Result**
What before seemed to succeed and returned 1, should now return a proper exception.
blorente added a commit to blorente/pants that referenced this pull request Jul 8, 2019
It introduced failures in the nightly cron (pantsbuild#8023), and a bunch more
errors when we tested it on Twitter internal targets.
blorente added a commit that referenced this pull request Jul 10, 2019
It introduced failures in the nightly cron (#8023), and a bunch more
errors when we tested it on Twitter internal targets.
illicitonion pushed a commit that referenced this pull request Jul 10, 2019
It introduced failures in the nightly cron (#8023), and a bunch more
errors when we tested it on Twitter internal targets.
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.

None yet

5 participants