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

console_rules can exit with exit codes #6654

Merged

Conversation

illicitonion
Copy link
Contributor

This will eagerly halt execution.

@illicitonion
Copy link
Contributor Author

Depends on #6653

@stuhood
Copy link
Member

stuhood commented Oct 18, 2018

This feels like a thing that we might have existing concepts for... TaskError is a semi-analogue, but also doesn't really have any substance to it. Adding John/Benjy for their thoughts.

@@ -536,6 +536,10 @@ def products_request(self, products, subjects):
throw_root_states = tuple(state for root, state in result.root_products if type(state) is Throw)
if throw_root_states:
unique_exceptions = tuple({t.exc for t in throw_root_states})

if len(unique_exceptions) == 1 and isinstance(unique_exceptions[0], GracefulTerminationException):
Copy link
Member

@stuhood stuhood Oct 18, 2018

Choose a reason for hiding this comment

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

Mmmm... this bit of magic is unpleasant.

It almost makes me wonder whether we shouldn't have a separate/explicit Scheduler entrypoint for @console_rule? Would likely be useful for @wisechengyi's UX PR.

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 for now

@@ -15,3 +16,15 @@ def fast_list(console, addresses):
"""A fast variant of `./pants list` with a reduced feature set."""
for address in addresses.dependencies:
console.print_stdout(address.spec)


# This should really be registered somehow as an in-repo plugin when testing, rather than living
Copy link
Member

Choose a reason for hiding this comment

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

Making this an explicit TODO would be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't TestBase support this via:

Or do console rules need special setup that TestBase doesn't handle? A naive scan through the relevant code looks like it should all work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved into pants-plugins/src/python/internal_backend/rules_for_testing

@stuhood stuhood force-pushed the dwagnerhall/v2/gracefultermination branch from 9b3d18a to 4164b9b Compare October 18, 2018 17:33
@stuhood
Copy link
Member

stuhood commented Oct 18, 2018

Rebased.

@@ -15,3 +16,15 @@ def fast_list(console, addresses):
"""A fast variant of `./pants list` with a reduced feature set."""
for address in addresses.dependencies:
console.print_stdout(address.spec)


# This should really be registered somehow as an in-repo plugin when testing, rather than living
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't TestBase support this via:

Or do console rules need special setup that TestBase doesn't handle? A naive scan through the relevant code looks like it should all work.

@@ -62,3 +62,28 @@ class BackendConfigurationError(BuildConfigurationError):

class IncompatiblePlatformsError(Exception):
"""Indicates that target platforms are incompatible with a target that contains native code."""


class GracefulTerminationException(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear why TaskError above with exit_code nonzero doesn't fit the bill. Granted there is the name and the fact it also carries failed_targets. Perhaps exceptions bound for the v2 rule world should live in a different file / package to help make it clear we're moving to new names? It really seems like this should live in pants.engine.rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved into src/python/pants/rules/core/exceptions.py - happy to re-use TaskError if that feels better to folks, but I quite like single-purpose exceptions for this kind of context

@illicitonion illicitonion force-pushed the dwagnerhall/v2/gracefultermination branch from 4164b9b to 802e6eb Compare October 19, 2018 09:34
@illicitonion illicitonion merged commit 3d22e95 into pantsbuild:master Oct 19, 2018
@illicitonion illicitonion deleted the dwagnerhall/v2/gracefultermination branch October 19, 2018 11:01
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.

3 participants