roualdes / bridgestan

BridgeStan provides efficient in-memory access through Python, Julia, and R to the methods of a Stan model.
https://roualdes.github.io/bridgestan
BSD 3-Clause "New" or "Revised" License
87 stars 12 forks source link

Better Error Message for Python Interface Automatically Downloading BridgeStan Source #156

Closed gil2rok closed 1 year ago

gil2rok commented 1 year ago

BridgeStan's Python interface can automatically download the BridgeStan source code "the first time you need it", as the documentation describes. In the code, this is performed by get_bridgestan_src() which is called by get_bridgestan_path which is called by compile_model(). Therefore "the first time you need" BridgeStan source code really means the first time a model is compiled.

While this makes sense, most of the (limited) BridgeStan examples I've seen begin with the set_bridgestan_path() function. When using BridgeStan for the first time, set_bridgestan_path() will call verify_bridgestan_path() and throw an error (since BridgeStan source code is not installed and get_bridgestan_src() was never called).

To resolve this issue, I had to dive into the source code and call get_bridgestan_src() manually. If indeed most BridgeStan projects begin with set_bridgestan_path(), I imagine many other new users may face the same issue.

I want to suggest two small improvements to fix this:

  1. In the documentation, replace "the first time you need it" with "the first time a model is compiled"
  2. Update the error message in verify_bridgestan_path() to suggest to users how to download the BridgeStan source code. Perhaps something like: "if this is your first time using BridgeStan, call get_bridgestan_src() immediately before the set_bridgestan_path() function." This may, however, negate the automatic downloading of BridgeStan source code that was intended in the first place.

Any suggestions or feedback is welcome.

WardBrian commented 1 year ago

If indeed most BridgeStan projects begin with set_bridgestan_path(), I imagine many other new users may face the same issue.

The only reason to do this is if you are using your own version of bridgestan, such as checking out the source repository, in which case the 'downloaded for you' feature is already moot. If you're hoping to benefit from the automatic downloading, using set_bridgestan_path is never necessary (and in general would prevent it)