hundreds-father-404
01/07/2020, 5:06 PMAddressSpec
discussion. I think the other type of top-level Spec
should be a FilesystemSpec
, which may either be a FileSpec
, DirectorySpec
, and some still-unknown type for globs. Rules would then request AddressSpec
or FilesystemSpec
It wasn’t clear to me until recently that FileSpec
and DirectorySpec
need to have the same superclass so that rules can request FilesystemSpecs
without caring whether users specifying them as files or directories, just as they don’t care how AddressSpecs
were specified on the command line.
Sound good?aloof-angle-91616
01/07/2020, 8:56 PMSpec
types herealoof-angle-91616
01/07/2020, 8:56 PMhundreds-father-404
01/07/2020, 8:57 PMFilesystemSpec
while keeping it generalizable enough to allow future specsaloof-angle-91616
01/07/2020, 8:58 PMwitty-crayon-22786
01/07/2020, 10:39 PMFileSpec
vs DirectorySpec
requires filesystem access to determine... i don't think it can be determined via parsing, as with the rest of these.witty-crayon-22786
01/07/2020, 10:39 PMsrc/com/blah/thing
may be either a file or a directoryhundreds-father-404
01/07/2020, 10:40 PMwitty-crayon-22786
01/07/2020, 10:57 PMwitty-crayon-22786
01/07/2020, 10:57 PMwitty-crayon-22786
01/07/2020, 10:58 PMhundreds-father-404
01/07/2020, 10:59 PMwitty-crayon-22786
01/07/2020, 11:05 PMwitty-crayon-22786
01/07/2020, 11:06 PMwitty-crayon-22786
01/07/2020, 11:07 PMwitty-crayon-22786
01/07/2020, 11:07 PMPathGlobs->Snapshot
API to capture Snapshotswitty-crayon-22786
01/07/2020, 11:08 PMwitty-crayon-22786
01/07/2020, 11:09 PM--owner-of
with other root selection, then you generally would not actually expose the raw parsed inputswitty-crayon-22786
01/07/2020, 11:11 PMSingleAddress
from a file or a directory... which it can't really do without filesystem accesswitty-crayon-22786
01/07/2020, 11:12 PM--query
... i think in one of the lead-up commits.witty-crayon-22786
01/07/2020, 11:13 PMaloof-angle-91616
01/07/2020, 11:15 PMaloof-angle-91616
01/07/2020, 11:15 PMaloof-angle-91616
01/07/2020, 11:15 PMaloof-angle-91616
01/07/2020, 11:15 PMwitty-crayon-22786
01/07/2020, 11:23 PMaloof-angle-91616
01/07/2020, 11:25 PMhundreds-father-404
01/07/2020, 11:28 PMi think it would be good to talk more about where you are trying to go with this.The goal is to go from
FilesystemSpec
to something like Snapshot
(or PathGlobs
, unclear). There would be an optional rule to go from FilesystemSpec -> Address
(or maybe Snapshot -> Address
?), but generally a FilesystemSpec
in no way needs to correspond to an address. The path does need to exist on the FS, but it doesn’t need to be linked to a BUILD file
Motivating use case for this: ./pants buildgen
run on a brand new repo won’t have any BUILD files defined yetwitty-crayon-22786
01/07/2020, 11:33 PM./pants buildgen
...?hundreds-father-404
01/07/2020, 11:34 PM./pants buildgen src/python
would generate BUILD files for all of src/python
witty-crayon-22786
01/07/2020, 11:34 PMaloof-angle-91616
01/07/2020, 11:34 PMsrc/python::
?witty-crayon-22786
01/07/2020, 11:34 PM./pants buildgen src/python::
hundreds-father-404
01/07/2020, 11:35 PM./pants cloc src/python/pants/backend/lint/isort/rules.py
should only run on rules.py
, not be expanded to the whole target (the whole folder)aloof-angle-91616
01/07/2020, 11:35 PMsrc/python::
is still a valid spec (which just matches 0 targets) if the dir doesn’t existaloof-angle-91616
01/07/2020, 11:36 PMsrc/python
suddenly points to a target now which doesn’t existaloof-angle-91616
01/07/2020, 11:36 PMowner-of
option entirely and just use file paths ^ re eric abovewitty-crayon-22786
01/07/2020, 11:37 PM./pants test $filename
probably wanting to run the tests for the target owning the file, possibly with the test running filtering to the file in some runner-specific way.witty-crayon-22786
01/07/2020, 11:37 PMaloof-angle-91616
01/07/2020, 11:39 PMsrc/python::
vs src/python/::
aloof-angle-91616
01/07/2020, 11:40 PMsrc/python::
personally but users at twitter are mostly conditioned to use the /::
style i’ve noticed and both seem finewitty-crayon-22786
01/07/2020, 11:41 PMaloof-angle-91616
01/07/2020, 11:41 PMthe cloc example is a good one. but i think that it is probably rare compared tothe runner-specific part is what we could potentially cut out here by allowing direct paths to files in the command line, i was thinkingprobably wanting to run the tests for the target owning the file, possibly with the test running filtering to the file in some runner-specific way../pants test $filename
witty-crayon-22786
01/07/2020, 11:42 PMaloof-angle-91616
01/07/2020, 11:42 PMwitty-crayon-22786
01/07/2020, 11:42 PMaloof-angle-91616
01/07/2020, 11:43 PMaloof-angle-91616
01/07/2020, 11:43 PMaloof-angle-91616
01/07/2020, 11:44 PMwitty-crayon-22786
01/07/2020, 11:48 PMaloof-angle-91616
01/07/2020, 11:48 PMbut if you did expose the raw parsed inputs, the parser would need to be able to differentiatetrue, but if we can trust pantsd being alive, we would be able to trust that we have an up-to-date view of the filesystem in the engine available at all times that we can query very quickly if pantsd is upfrom a file or a directory... which it can't really do without filesystem accessSingleAddress
aloof-angle-91616
01/07/2020, 11:48 PMright: owner of is what i'm suggesting. but that is not what (i think) Eric was suggesting with the cloc example.oh! sorry! i missed this part!
aloof-angle-91616
01/07/2020, 11:48 PMaloof-angle-91616
01/07/2020, 11:49 PMhundreds-father-404
01/07/2020, 11:50 PMAddressSpecs
(or TransitiveHydratedTargets
, BuildFileAddresses
, etc)
2. raw files without any target information, then request FilesystemSpecs
3. allow file system specs, but ultimately the rule needs targets to work, e.g. `./pants test`; use the rule that converts FilesystemSpecs -> Address
, which is the rule implementation as --owner-of
My main point is that we should allow this second use case. Most goals do need target information to work properly, like test, but some don’t need it at all, like cloc and buildgenaloof-angle-91616
01/07/2020, 11:50 PMAddressSpecs
vs FilesystemSpecs
?aloof-angle-91616
01/07/2020, 11:51 PMaloof-angle-91616
01/07/2020, 11:53 PMAddressSpec
first, and then a FilesystemSpec
hundreds-father-404
01/07/2020, 11:53 PMSpecs
(soon to be AddressSpecs
). That will still be supported.
We will allow instead requesting in the rule signature FilesystemSpecs
, which you could convert into something like PathGlobs
or Snapshot
.
I’m not sure yet what exactly the rule signature would look like to request "either FilesystemSpec or AddressSpec is fine"
aloof-angle-91616
01/07/2020, 11:54 PM@union
classes to be used as arguments directlyaloof-angle-91616
01/07/2020, 11:56 PM@union
class is expanded into a version of the rule for each of its union members, at rule indexing time)aloof-angle-91616
01/07/2020, 11:56 PMwitty-crayon-22786
01/07/2020, 11:57 PMwitty-crayon-22786
01/08/2020, 12:01 AMaloof-angle-91616
01/08/2020, 12:01 AMaloof-angle-91616
01/08/2020, 12:01 AMaloof-angle-91616
01/08/2020, 12:01 AMhundreds-father-404
01/08/2020, 12:02 AMthat visionwhich vision? My proposed 3 use cases or the vision of parsing in the engine?
aloof-angle-91616
01/08/2020, 12:02 AMaloof-angle-91616
01/08/2020, 12:02 AMwitty-crayon-22786
01/08/2020, 12:15 AMwitty-crayon-22786
01/08/2020, 12:15 AMwitty-crayon-22786
01/08/2020, 12:16 AMaloof-angle-91616
01/08/2020, 12:34 AM--query
PRhappy-kitchen-89482
01/08/2020, 2:37 AM./pants <some flags> goal <positional args to the goal>
(ignoring multiple goals, for simplification, but same principle applies).
Currently the positional args are always interpreted as address specs (and are in fact validated as such pretty early on - i.e., they cannot reference nonexistent targets, and must refer to at least one existing target).
At the other extreme we could say that positional args can be anything at all, and it's up to the goal to interpret them. E.g., if the goal knows that it expects addresses, it can request BuildFileAddresses and if the positional args cannot be converted to valid addresses, then and only then do we error.aloof-angle-91616
01/08/2020, 2:37 AMhappy-kitchen-89482
01/08/2020, 2:37 AMaloof-angle-91616
01/08/2020, 2:37 AMhappy-kitchen-89482
01/08/2020, 2:38 AMhappy-kitchen-89482
01/08/2020, 2:41 AMhappy-kitchen-89482
01/08/2020, 2:41 AMhappy-kitchen-89482
01/08/2020, 2:41 AMhappy-kitchen-89482
01/08/2020, 2:42 AMhappy-kitchen-89482
01/08/2020, 2:42 AMhappy-kitchen-89482
01/08/2020, 2:42 AMaloof-angle-91616
01/08/2020, 2:43 AM./pants buildgen src/python::
syntax but i have no issue starting the positional args conversation earlierhappy-kitchen-89482
01/08/2020, 2:43 AM./pants test src/python/foo/bar_test.py
aloof-angle-91616
01/08/2020, 2:43 AMthere are several cases where we don't actually need target information, just the content of the source file.i hadn't considered this! thanks
happy-kitchen-89482
01/08/2020, 2:43 AMhappy-kitchen-89482
01/08/2020, 2:44 AMhappy-kitchen-89482
01/08/2020, 2:44 AMaloof-angle-91616
01/08/2020, 2:44 AMthe user's intent is obvious:great to identify cases like this where the current pants model holds us back
happy-kitchen-89482
01/08/2020, 2:45 AMaloof-angle-91616
01/08/2020, 2:45 AMhappy-kitchen-89482
01/08/2020, 2:46 AMaloof-angle-91616
01/08/2020, 2:47 AM./pants run
reliable and fast, individual teams can ship tools just as targets in our monorepo instead of having to supply them elsewherehappy-kitchen-89482
01/08/2020, 2:47 AMaloof-angle-91616
01/08/2020, 2:47 AMaloof-angle-91616
01/08/2020, 2:47 AMhappy-kitchen-89482
01/08/2020, 2:48 AM