so I guess `run_rule` is the correct way to do thi...
# development
h
so I guess
run_rule
is the correct way to do this?
a
let me check
nvm, mac updating. 12 mins
h
actually it looks like
run_rule
expects you to mock out a
yield Get
but that's exactly what I want to test here
a
mock out a yield Get how?
h
the docstring says that if you use yield get in a rule, you have to provide a function that will do that
uh, maybe I don't need that here though
a
omg
h
wait, no, that can't work
the intrinsic is exactly what I need to test here
and in non-test code that's exactly what the engine would handle implicitly in the yield
a
that’s kind of why i was leaning towards the solution you first proposed
h
okay so acutally do go with product_request, then?
a
well
h
I'm not 100% sure how that works, I just see other tests using it
a
those other tests might not be all up to date
it works exactly the same as a yield Get
can confirm any of this in a few when my laptop restarts
h
ok
yeah I figured it was basically a yield Get, I just wanted to make sure it was still valid in v2 code
a
the scheduler product_request() method in general is intended to be a hack for v1 and removing calls to it should be a v2 migration goal imo, at a very high level (someone correct me if i’m wrong) but for an intrinsic like you’re doing it seems like the right choice
h
so does that mean that eventually there should be another way of deliberately invoking an intrinsic from a python test?
or that this is the only thing that product_request() should be used for in v2?
a
that’s vaguely what i was thinking, but not sure what that might look like as of now
h
when I run
./pants test tests/python/pants_test/engine:isolated_process
I get this error:
Copy code
E       pants.engine.scheduler.ExecutionError: 1 Exception encountered:
                     E       Computing Select(FileContent(path=some.filename, content=(len:23)), ExecuteProcessResult)
                     E         Computing Task(current_rule(), FileContent(path=some.filename, content=(len:23)), ExecuteProcessResult, true)
                     E           Throw(WithDeps(Inner(InnerEntry { params: {InputFileContent}, rule: Task(Task { product: ExecuteProcessResult, clause: [Select { product: InputFileContent }], gets: [Get { product: Digest, subject: InputFileContent }], func: current_rule(), cacheable: true }) })) did not declare a dependency on JustGet(Get { product: ExecuteProcessResult, subject: ExecuteProcessRequest }))
                     E             Traceback (no traceback):
                     E               <pants native internals>
                     E             Exception: WithDeps(Inner(InnerEntry { params: {InputFileContent}, rule: Task(Task { product: ExecuteProcessResult, clause: [Select { product: InputFileContent }], gets: [Get { product: Digest, subject: InputFileContent }], func: current_rule(), cacheable: true }) })) did not declare a dependency on JustGet(Get { product: ExecuteProcessResult, subject: ExecuteProcessRequest })
so, somehow I'm not setting up the rules correctly?
but other tests in that same file are somehow successfully getting an
ExecuteProcessResult
from an
ExecuteProcessRequest
(what I want to do here is basically generate a Digest from an InputFileContent, and then execute a process to cat it, and make sure the output is the same as the original file specification)
a
oh wow, i thought we linted that
h
linted?
a
i didn’t think that having a
yield Get()
as the final expression in a rule was supposed to work for some reason (but i don’t know why that shouldn’t work)
and i thought that we tried to lint for that in the
@rule
decorator
h
oh
a
i have a laptop now, checking why that wouldn’t be it
h
well I disabled linting when I commited this since it's still a WIP
a
when i said “lint” i meant that the
@rule
decorator raises an error when seeing certain constructs in rules
h
btw is there a way to only run a single test within a pants test target?
a
use passthrough args or test.pytest --args to add the argument
-k regexp
to match the name of the test you want to run. pytest has several other options too
h
ah, ok
need to head out for the day now, I'll pick this up again tomorrow
a
i just looked at the
@rule
decorator and your rule is supposed to be working
so yeah let’s pick this up tomorrow
h
but yeah removing the Get from the end of the line now mkaes the error be something in the rust code
that looks FFI-related
a
amazing
h
which sucks but at least I"m past this problem
a
yes indeed
i might ask you to please add a TODO above the Get noting that it should work to have a yield Get() at the end of a rule, but currently doesn’t, and that we should check this or fix it
i’d investigate but v tired right now
ok, i am tired but also have managed to repro the final yield Get() issue with a test rule in test_scheduler.py, so i plan to investigate on the plane or tomorrow
h
oh cool
a
`@rule`s can now end in
yield Get(...)
expressions: https://github.com/pantsbuild/pants/pull/8227
🎉 2
h
cool, I'll take a look at this