https://promptfoo.dev/ logo
Can I set environment variables inside of an 'exec...
# ❓|questions
m
I want to test a complex chat app end-to-end. I've written a python script using the exec provider as outlined here: https://www.promptfoo.dev/docs/guides/evaluate-rag. However, I need to set the PYTHONPATH to give the script access to the code. Things I've tried: - Set PYTHONPATH before calling promptfoo. This doesn't work. I think because the child process spawned by promptfoo doesn't inherit the environment? - Set it inline in the exec definition, e.g.
['exec: PYTHONPATH=mypath python my_path/test_app.py']
, but I'm getting an ENOENT error, even though "my_path" is accessible by promptfoo if I only run the script. Any thoughts? Maybe I'm going about this wrong?
i
The child process should get all the environment variables of the parent process, including
PYTHONPATH
. I've just confirmed this myself by running an
exec
provider with the following:
Copy code
PYTHONPATH=foo/bar TEST_VAR=1 promptfoo eval
How are you setting the envars?
m
I tried to do it exactly as your did, but it didn't seem to be working yesterday. That said, I refactored everything to use a Python Provider (https://promptfoo.dev/docs/providers/python) instead of this approach: https://www.promptfoo.dev/docs/guides/evaluate-rag/ and it's working :). Thank you for your quick response.