This is surprising to me: ```python_tests( nam...
# general
b
This is surprising to me:
Copy code
python_tests(
    name="tests",
    resolve="reqs",
    dependencies=[
        ":fetch_test_data_adhoc",  <-- A python script to fetch
        ":test_dataset",           <-- The tarball that gets fetched
        ...
    ]
)


adhoc_tool(
    name="fetch_test_data_adhoc",
    runnable=":fetch_test_data_py",
    output_files=[
        "results_dataset.tar",
    ],
)

resource(
    name="test_dataset",
    source="test_dataset.tar",
)

python_source(
    name="fetch_test_data_py",
    source="fetch_test_data.py",
)
This is incorrect because
:test_dataset
, if included as a dependency to
tests
, shows up as an empty file:
Copy code
Engine traceback:
  in `test` goal

InvalidFieldException: The 'source' field in target test/python/mytest:test_dataset must have 1 file, but it had 0 files.
However if I remove the
:test_dataset
from the test dependencies, Pants is able to add the actual files into the sandbox, via adhoc_tool's
output_files
. Which seems to obviate the need for a
resource
target, and a test dependency... Thoughts? Am I doing this right?
b
That error suggests
test_dataset.tar
doesn’t exist as a file on disk adjacent to that BUILD file. Is that the case? Is that what you expect?
b
Yes, that's correct. The
python_source
runs a script that fetches test data from another repository... The reason I do this is to set a custom header on the request. It's for authentication.
At any rate, this seems to work. It's just not what I expected, and am wondering if there's a better way.
b
Ah, a target like
resource
is required for files on disk, it’s not required for ones generated by other targets that aren’t on disk.
👌 1