alert-architect-36218
05/01/2024, 2:45 PMadhoc_tool
, which according to this generates file
sources by default
My adhoc_tool
is a python script that generates some files and I want to consume those in my code, I add a dependency on adhoc_tool
and try to open(<filepath>)
. I do specify output_direcotries
in my adhoc_tool
target.
However, during the execution of my script that tries to find the file, it is unable to do so. As I was debugging I realized that the files are saved at /var/tmp/pants-sandbox/...
, but my code executes with cwd
at the root of my project, so relative path to the files doesn't work anymore. Adding experimental_wrap_as_resources
doesn't help to open with regular io
command like open(filepath, "r")
It does work if I read the file with importlib.resources
, but that's not exactly what I wanted. Is there a way to make relative open work ? Am I possibly misconfiguring something ?broad-processor-92400
05/01/2024, 7:50 PM__file__
(ie source code’s current location and then manipulating that) are the best way to open these. This sort of file ends up being packaged “within” the application, so needs to be opened relative to the source code not the working directory.
To make cwd-relative paths work, these generated files would have to be written into the repository itself, which sounds a bit unexpected.
Can you describe more about what you’re trying to do with these generated files?alert-architect-36218
05/02/2024, 8:39 AM