Stan-dev/stan tests: generating .hpp from .stan files

Hi all,

I was trying to run some tests locally and ran into problems. From a clean clone of Stan, this is what I’m seeing:

> ./runTests.py src/test/unit/services/optimize/bfgs_test.cpp
------------------------------------------------------------
make -j1 test/test-models/good/optimization/rosenbrock.hpp
make: *** No rule to make target `test/test-models/good/optimization/rosenbrock.hpp'.  Stop.
make -j1 test/test-models/good/optimization/rosenbrock.hpp failed
exit now (01/06/22 09:09:23 EST)

Are there any additional steps that need to happen before I can run these tests?

At the very least, it looks like there’s no dependency on bin/stanc, so there’s no mechanism to generate the .hpp files from .stan files.

I’m going to dig through the Jenkinsfile to see if there’s a way around it. (I know how to generate the .hpp files by hand, but if there’s something I can do to fix the Makefile, I will… but only after it’s verified that there’s a problem.)

I am able to run this locally and the tests pass.

The runtest python script checks if the test file needs a Stan file compiled and the makefile here: stan/tests at develop · stan-dev/stan · GitHub downloads the stanc3 binary, etc.

1 Like

Yup. That’s what I was expecting. I’ll keep digging to see why it’s not working locally.

If I interpret your message correctly, the Python script should download bin/stanc? Or is that still handled with make?

The download happens in the makefiles: stan/tests at 293295db6910a4ce4e6ac29f8e3c8dbb3737ced7 · stan-dev/stan · GitHub

The Python script only makes sure to call make for all stan models that are required in the supplied tests files: stan/runTests.py at 293295db6910a4ce4e6ac29f8e3c8dbb3737ced7 · stan-dev/stan · GitHub

1 Like

@rok_cesnovar, thanks! That’s what I found too, but I didn’t see it download bin/stanc and even after I manually downloaded it, it didn’t trigger the build. I’ll try to see what’s up with the makefile.

I’m on an M1 Macbook with the default Make installed with XCode, so there might be a version difference with Make.

If you remove the binary and run make bin/stanc does that download the binary?

If that works what happens if you then try:

make test/test-models/good/model/valid.hpp

Yes.

That was exactly what I tried first. =)

Here’s my output:

> make test/test-models/good/model/valid.hpp
make: *** No rule to make target `test/test-models/good/model/valid.hpp'.  Stop.

So it’s not recognizing the target (with my setup). I even added a -p to show the full instruction set in make to try to debug.

1 Like

Ah, that is weird.

So that probably also means

make src/test/test-models/good/model/valid.hpp

doesn’t work right?

Exactly.

I was looking at the full make output (with the -p option) and my guess is that findfiles might not be resolving to the right thing on a Mac. But that’s a wild guess that I’ll confirm in a little bit.

@jsocolar helped me out!

I had failed to pull down the git submodules. (I thought I did, but I looked at the lib/stan_math folder and it was empty.)

I’m past the error now by running:

git submodule update --init --recursive

(We should probably check if the submodule is there and fail earlier if it’s doable. But that’s a different issue.)

@rok_cesnovar, thanks for trying to dig into it with me. And thanks @jsocolar for helping me figure it out.

2 Likes