<@UKPS08ZGW>: re: porting code to v2
# development
w
@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
so
ListRoots
is such a task right?
w
yea, i think so.
h
sinceit just prints things to console and doens't have any outputs?
a
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
the only odd thing about
ListRoots
is that it doesn't interact with targets "at all"
h
oh okay, maybe I can take those and clean them up and get them merged
a
--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
i wouldn't recommend starting with those, because they're fairly large
h
yeah chatting with benjy, ListRoots came up as a good one to start with
a
and yes, but https://github.com/pantsbuild/pants/pull/7350 is quite small and partially reviewed already!
h
I'm just trying to figure out where a python to rust port for a task has already happened
a
good q
w
@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
ah, so this is going ot look like new rules in python that are execute by the rust engine
okay
w
yep
h
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
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
I'm definitely happy to take a look at the
--query
work
I just am not sure where to get started
a
we can implement rules in rust! there's something called intrinsics -- let me find them
hm you're right sorry
w
implementing a rule in rust is something that you can do, but only for very specialized (built-in/intrinsic) cases
h
okay, so should the new version of
ListRoots
be rust or python code?
w
python.
h
ok
a
^
w
so, when you're looking for examples of something like, this your simplest goto is going to be
list
a
we do it for process execution because we do fancy remote execution things in rust
h
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
ok
w
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
so does that mean I should define a new function
rules
in
core_tasks/register.py
w
see the other thread
h
that for now just returns the new version of the
list_roots
rule?
w
^
h
is this
list_targets
rule hooked up to the
targets
command line arg?
i.e. if I run
./pants targets
?
w
answered in the other thread.