stale-tent-71107
02/19/2025, 3:01 AMpdf2image library and then run OCR on the image with pytesseract. While writing a unit test for this flow, I encountered an issue when running the test with Pants. Pants is unable to open the temporary image we get when converting a pdf -> image, and I’m seeing the error attached in the thread. Interestingly, the test runs fine with Poetry.
I suspect this might be related to how Pants sandboxes tests, potentially restricting access to certain temp files generated during execution. Has anyone else run into this issue or have any suggestions on how to resolve it?
Thanks!stale-tent-71107
02/19/2025, 3:02 AMpytesseract.pytesseract.TesseractError: (1, 'Error in fopenReadStream: failed to open locally with tail tess_c67xdrva_input.PPM for filename /tmp/tess_c67xdrva_input.PPM Leptonica Error in findFileFormat: image file not found: /tmp/tess_c67xdrva_input.PPM Error in fopenReadStream: failed to open locally with tail P6 for filename P6 Leptonica Error in pixRead: image file not found: P6 Image file P6 cannot be read! Error during processing.')broad-processor-92400
02/19/2025, 4:22 AM--keep-sandboxes=on_failure you'll see the failing test's sandbox printed, and then you can go to that directory and run the __run.sh... hopefully that reproduces the problem!
Once you've reproduced it outside of a pants ... invocation, you can then debug it like "normal" e.g. pytest --pdb .. or whatever you need to dostale-tent-71107
02/19/2025, 6:51 AMconvert_from_path function in pdf2image , it temporarily stores the image in a /tmp folder on my computer. Unfortunately since pants creates a sandbox, it probably doesn't have access to this created /tmp folder as it doesn't exist in the sandbox..broad-processor-92400
02/19/2025, 8:03 PM/tmp should work fine (we use them in my work repo).