https://pantsbuild.org/ logo
w

witty-crayon-22786

07/09/2019, 9:45 PM
@hundreds-breakfast-49010: re: porting code to v2
good candidates for that are tasks that have relatively few "product dependencies" in a v1 sense (https://www.pantsbuild.org/dev_tasks.html#product_types-and-require_data-why-test-comes-after-compile)
another requirement (right now) is that tasks don't depend heavily on the shape of Target objects (because v2 does not construct the existing
class Target
type)
h

hundreds-breakfast-49010

07/09/2019, 9:48 PM
so
ListRoots
is such a task right?
w

witty-crayon-22786

07/09/2019, 9:48 PM
yea, i think so.
h

hundreds-breakfast-49010

07/09/2019, 9:48 PM
sinceit just prints things to console and doens't have any outputs?
a

aloof-angle-91616

07/09/2019, 9:48 PM
here are some examples of tasks i've tried to port to v2, most are working code modulo rebase conflicts: - python thrift namespace checking: https://github.com/pantsbuild/pants/pull/7419 -
--query
pipelining (a fun one!): https://github.com/pantsbuild/pants/pull/7356 - execute scalafmt hermetically: https://github.com/pantsbuild/pants/pull/7552 - graal native-image hermetic creation (larger and more out-of-date, will fix soon): https://github.com/pantsbuild/pants/pull/6893
in case any of those can be inspiration
w

witty-crayon-22786

07/09/2019, 9:49 PM
the only odd thing about
ListRoots
is that it doesn't interact with targets "at all"
h

hundreds-breakfast-49010

07/09/2019, 9:49 PM
oh okay, maybe I can take those and clean them up and get them merged
a

aloof-angle-91616

07/09/2019, 9:49 PM
--query
is very close to my heart and if we were able to make progress on that a lot of people's CI would be much faster, including twitter's
w

witty-crayon-22786

07/09/2019, 9:49 PM
i wouldn't recommend starting with those, because they're fairly large
h

hundreds-breakfast-49010

07/09/2019, 9:50 PM
yeah chatting with benjy, ListRoots came up as a good one to start with
a

aloof-angle-91616

07/09/2019, 9:50 PM
and yes, but https://github.com/pantsbuild/pants/pull/7350 is quite small and partially reviewed already!
h

hundreds-breakfast-49010

07/09/2019, 9:50 PM
I'm just trying to figure out where a python to rust port for a task has already happened
a

aloof-angle-91616

07/09/2019, 9:50 PM
good q
w

witty-crayon-22786

07/09/2019, 9:51 PM
@hundreds-breakfast-49010: so, i don't want to burst your bubble (and this might), but: v2 doesn't mean "python to rust" port
it means porting from the v1 task API (in python) to the v2 rule API (also in python)
h

hundreds-breakfast-49010

07/09/2019, 9:51 PM
ah, so this is going ot look like new rules in python that are execute by the rust engine
okay
w

witty-crayon-22786

07/09/2019, 9:51 PM
yep
h

hundreds-breakfast-49010

07/09/2019, 9:51 PM
I forget if implementing a rule in rust is something we can do now, or something we can't do now but want to implement
a

aloof-angle-91616

07/09/2019, 9:51 PM
ListRoots
sounds like it would be a fantastic intro to the initial setup work for
--query
!! https://github.com/pantsbuild/pants/pull/7350 just in case you want to look into that
h

hundreds-breakfast-49010

07/09/2019, 9:52 PM
I'm definitely happy to take a look at the
--query
work
I just am not sure where to get started
a

aloof-angle-91616

07/09/2019, 9:52 PM
we can implement rules in rust! there's something called intrinsics -- let me find them
hm you're right sorry
w

witty-crayon-22786

07/09/2019, 9:52 PM
implementing a rule in rust is something that you can do, but only for very specialized (built-in/intrinsic) cases
h

hundreds-breakfast-49010

07/09/2019, 9:52 PM
okay, so should the new version of
ListRoots
be rust or python code?
w

witty-crayon-22786

07/09/2019, 9:52 PM
python.
h

hundreds-breakfast-49010

07/09/2019, 9:52 PM
ok
a

aloof-angle-91616

07/09/2019, 9:52 PM
^
w

witty-crayon-22786

07/09/2019, 9:53 PM
so, when you're looking for examples of something like, this your simplest goto is going to be
list
a

aloof-angle-91616

07/09/2019, 9:53 PM
we do it for process execution because we do fancy remote execution things in rust
h

hundreds-breakfast-49010

07/09/2019, 9:53 PM
so right now, it looks like all tasks are registered in
core_tasks/register.py
with calls to either
Goal.register
or
TaskRegistrar
@hundreds-breakfast-49010: that's v1
h

hundreds-breakfast-49010

07/09/2019, 9:53 PM
ok
w

witty-crayon-22786

07/09/2019, 9:55 PM
in v2, you still register things in
register.py
but you do it via
def rules
, which is a list of v2 rules that the backend includes
h

hundreds-breakfast-49010

07/09/2019, 9:59 PM
so does that mean I should define a new function
rules
in
core_tasks/register.py
w

witty-crayon-22786

07/09/2019, 9:59 PM
see the other thread
h

hundreds-breakfast-49010

07/09/2019, 9:59 PM
that for now just returns the new version of the
list_roots
rule?
w

witty-crayon-22786

07/09/2019, 9:59 PM
^
h

hundreds-breakfast-49010

07/09/2019, 10:03 PM
is this
list_targets
rule hooked up to the
targets
command line arg?
i.e. if I run
./pants targets
?
w

witty-crayon-22786

07/09/2019, 10:05 PM
answered in the other thread.