https://pantsbuild.org/ logo
#development
Title
# development
m

melodic-thailand-99227

12/02/2021, 11:01 AM
I was hacking around this - https://pantsbuild.slack.com/archives/C0D7TNJHL/p1638423622110100?thread_ts=1638346952.082700&cid=C0D7TNJHL And I have something working but I have a few questions: 1. I have an address and I want to get a target from it, what API should I use? 2. My goal_rule accepts two addresses (which I verify) but I get them in sorted order and not in the input order, is there a way around this? 3. Is there a mixin line LineOriented for JSON?
c

curved-television-6568

12/02/2021, 11:23 AM
I can take a stab at this, until @witty-crayon-22786 wakes up. 1. You can`await Get(WrappedTarget, Address, my_address)` 2. I can think of two workarounds: a) If there are no link from tgt1 to tgt2, try again with the order reversed. or b) have one of the targets as an option instead:
./pants graphs --from-target=tgt1 tgt2
3. I’ve got no answer for this one.
m

melodic-thailand-99227

12/02/2021, 11:37 AM
Actually I also get implicit addresses as well 😐 I pass
subdir/a.py
subdir/b.py
and I get in the goal 3 addresses
subdir/a.py
subdir/b.py
subdir:main
@curved-television-6568 is there a special option for an address?
Copy code
meta=address
or something?
c

curved-television-6568

12/02/2021, 11:42 AM
Ah, I think that
subdir:main
is the generator for those other two.. not sure why it shows up, though.. guess that’s an implementation detail. Perhaps you only want to work with file targets, though.. so you could filter those addresses on
addr.is_file_target
( https://github.com/pantsbuild/pants/blob/main/src/python/pants/build_graph/address.py#L288 )
is there a special option for an address?
meta=address
or something?
Don’t understand this question..
m

melodic-thailand-99227

12/02/2021, 11:51 AM
If I add an option for the
--from
is the option builder for address
c

curved-television-6568

12/02/2021, 11:57 AM
Oh, right, now I get it
m

melodic-thailand-99227

12/02/2021, 11:58 AM
And what’s the way to resolve a string to an address?
c

curved-television-6568

12/02/2021, 11:59 AM
I don’t think there is.. but you can go from an unparsed raw string to an adress or target:
await Get(Targets, UnparsedAddressInputs, unparsed)
m

melodic-thailand-99227

12/02/2021, 1:35 PM
👀 1
🙌 1
👍 1
c

curved-television-6568

12/02/2021, 1:54 PM
That looks great!