Skip to content

src_info() need to use the include_paths  #516

@segasai

Description

@segasai

Summary:

src_info() method returns incorrect results when the model has includes.

Description:

While debugging the #506 issue, I was trying to figure out what part of the compilation fails (as that's the condition when before #507 cwd was corrupted). That lead me to the src_info()
which apparently fails I think when the model has includes, because the src_info() call does not pass the include_paths to the stanc

Here is my python program it just basically compiles a stan file (the model doesn't matter, it just needs an include of the file in the same directory)

from cmdstanpy import CmdStanModel
import os
import logging
logging.basicConfig(level=logging.DEBUG)
M = CmdStanModel('pmfit', 'models/pmfit.stan')
M.compile()

And here is the output

DEBUG:cmdstanpy:cmd: ./bin/stanc --info /home/skoposov/science/orphan2/models/pmfit.stan
cwd: /home/skoposov/soft/cmdstan-2.28.2
DEBUG:cmdstanpy:Command ['./bin/stanc', '--info', '/home/skoposov/science/orphan2/models/pmfit.stan']
	error during processing Operation not permitted
INFO:cmdstanpy:found newer exe file, not recompiling
INFO:cmdstanpy:found newer exe file, not recompiling
INFO:cmdstanpy:deleting tmpfiles dir: /tmp/tmpr54y238j
INFO:cmdstanpy:done

If I try to run --info without include-paths
I get an error

$ $HOME/soft/cmdstan-2.28.2/bin/stanc  --info /home/skoposov/science/orphan2/models/pmfit.stan
Syntax error in '/home/skoposov/science/orphan2/models/pmfit.stan', line 3, column 0, include error:
   -------------------------------------------------
     1:  functions
     2:  {
     3:  #include spline.stan
         ^
     4:  }
     5:  data
   -------------------------------------------------

While it works if include-paths are specified

$ $HOME/soft/cmdstan-2.28.2/bin/stanc --include-paths /home/skoposov/science/orphan2/models/  --info /home/skoposov/science/orphan2/models/pmfit.stan
{ "inputs": { "n_stars": { "type": "int", "dimensions": 0},
              "n_pm_nodes": { "type": "int", "dimensions": 0},
....

So my understanding is that the includes need to be passed to the src_info(). s

Additional Information:

CMDstan is provided through the environment variable and I use 2.28.2 version.
It's linux and python 3.8

Current Version:

the develop version of cmdstanpy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions