polite-garden-50641
01/17/2020, 12:18 AMhundreds-father-404
01/17/2020, 12:19 AMGoalSubsystem
in the method of a Subsystem
, not in a rule
Normally, we’d do this with MySubsystem.global_instance()
, but `global_instance isn't defined on GoalSubsystem
and I’m unclear if it should be?
Any ideas? CC @witty-crayon-22786aloof-angle-91616
01/17/2020, 12:26 AMGoalSubsystem
wouldn't be a Subsystem
?hundreds-father-404
01/17/2020, 12:27 AMOptionable
and SubsystemClientMixin
but not Subsystem
. I’m not sure why that is, though?aloof-angle-91616
01/17/2020, 12:28 AMpolite-garden-50641
01/17/2020, 12:31 AMhundreds-father-404
01/17/2020, 12:34 AMwitty-crayon-22786
01/17/2020, 12:35 AMhundreds-father-404
01/17/2020, 12:36 AMGoal.Options
inherited SubsystemClientMixin
and Optionable
, rather than Subsystem
. Do you remember why that is?witty-crayon-22786
01/17/2020, 12:36 AMpolite-garden-50641
01/17/2020, 12:36 AMlocal_pants_runner
https://github.com/pantsbuild/pants/blob/master/src/python/pants/bin/local_pants_runner.py#L270 maybe we should just do the same for stream handlers ?witty-crayon-22786
01/17/2020, 12:38 AMpolite-garden-50641
01/17/2020, 12:39 AMwitty-crayon-22786
01/17/2020, 12:39 AMwitty-crayon-22786
01/17/2020, 12:41 AMpolite-garden-50641
01/17/2020, 12:41 AMGoalSubsystem
subsystem implements the logic (and rules) to handle auth with our servers (OAuth flow, storing access tokens, etc...) so our stream handlers implementation needs to access the options to figure out where the access token is stored in order to load & use it.witty-crayon-22786
01/17/2020, 12:42 AMhundreds-father-404
01/17/2020, 12:42 AM./pants auth --foo
rather than ./pants --auth-subsystem-foo
witty-crayon-22786
01/17/2020, 12:42 AMpolite-garden-50641
01/17/2020, 12:43 AMpolite-garden-50641
01/17/2020, 12:44 AMhundreds-father-404
01/17/2020, 12:45 AMGoalSubsystem
inherits Subsystem
(which possibly makes sense - would need to audit more)
The main downside I see is the namespace, as pointed out above.witty-crayon-22786
01/17/2020, 12:45 AMwitty-crayon-22786
01/17/2020, 12:46 AMpants.ini
because they don't change with every invokehundreds-breakfast-49010
01/17/2020, 12:46 AMauth
goal, maybe that's a sign that it shouldn't be namespaced under auth
hundreds-father-404
01/17/2020, 12:55 AM--base-url
- --local-port
- --output
(enum type)
- --from-env-var
Conceptually, I think it does make sense to have these options live in the goal, just as we have ./pants login --to
as an option. They modify how the goal runs. This goal is pretty simple - it doesn’t wrap any other tool like Flake8
.
It’s convenient and natural to be able to do ./pants auth --output=console
, as opposed to ./pants --authentication-output=console auth
--
The only subsystem names I could come up with are AuthSettings
and Authentication
, which is confusing why that’s distinct from the AuthOptions(GoalSubsystem)
. That is, there’s no “natural” subsystem that comes to my mind, unlike the Flake8
, PythonSetup
, and ScalaFix
subsystems, which all map to something very naturally.hundreds-breakfast-49010
01/17/2020, 12:56 AMGoalSubsystem
should be a normal Subsystem
that you can call global_instance
onhundreds-father-404
01/17/2020, 12:57 AMGoalSubsystem
should inherit Subsystem
. I can’t think of a strong conceptual motivation why we would not want that.
(We should, though, still keep GoalSubsystem
as a distinct class so that we can distinguish between normal subsystems. A Goal.subsystem_cls
should only allow GoalSubsystem
instances, not general Subsystem
instances)witty-crayon-22786
01/17/2020, 1:00 AMwitty-crayon-22786
01/17/2020, 1:00 AMhundreds-father-404
01/17/2020, 1:01 AMpants.ini
under the scope auth
witty-crayon-22786
01/17/2020, 1:01 AMhundreds-breakfast-49010
01/17/2020, 1:03 AMhundreds-father-404
01/17/2020, 1:03 AMthen it shouldn’t matter whether they are on a goal or not?What matters is the namespace. We want the options to live under the namespace
auth
(the same namespace as the goal). It’s confusing for us to have options defined on some subsystem called Authentication
, so that you have to do --authentication-local-port
rather than --auth-local-port
. There’s no compelling reason for a new options scope, other than the constraints of Pantshundreds-breakfast-49010
01/17/2020, 1:03 AMwitty-crayon-22786
01/17/2020, 1:04 AMwitty-crayon-22786
01/17/2020, 1:04 AMhundreds-breakfast-49010
01/17/2020, 1:04 AMhundreds-breakfast-49010
01/17/2020, 1:04 AMwitty-crayon-22786
01/17/2020, 1:05 AMhundreds-father-404
01/17/2020, 1:06 AM@rules
should not be able to request a GoalSubsystem
hundreds-breakfast-49010
01/17/2020, 1:06 AMhundreds-breakfast-49010
01/17/2020, 1:06 AM.global_instance
eitherhundreds-breakfast-49010
01/17/2020, 1:07 AMwitty-crayon-22786
01/17/2020, 1:07 AMhundreds-father-404
01/17/2020, 1:07 AMIt feels like there are compositional/circular concernsThis would be true with
Goal.Options
, but now `GoalSubsystem`s can be used without ever needing to touch the Goal
. They’re still closely coupled, but decoupled enough that it’s safe for a normal rule to consume the GoalSubsystem
without any circular dependency on the Goal
hundreds-breakfast-49010
01/17/2020, 1:07 AMhundreds-father-404
01/17/2020, 1:08 AMhm, global_instance isn’t safe to use in a v2 rule?No, you should request the subsystem in your rule signature and that subsystem should be registered via a
subsystem_rule()
witty-crayon-22786
01/17/2020, 1:08 AMhundreds-father-404
01/17/2020, 1:15 AMGoalSubsystem
being able to stand on its own, whereas the Goal
needs the GoalSubsystem
to work.
For example, I think it does make sense to have in pants.ini
options defined on your goal, like [dependencies] transitive: True
because that’s the default you decide you want for your organization. It makes sense to have that option configured without running ./pants dependencies
. That is, the goal options conceptually can stand on their own.witty-crayon-22786
01/17/2020, 2:14 AMwitty-crayon-22786
01/17/2020, 2:15 AM