Hi,
After a Mac update I am unable to run a certain model.
I tried to create a new conda environment and re-installed Stan as follows
python3 -m pip install pystan
but the problem still occurred.
I ran the standard “hello-world” example and this worked as expected.
However, if I I try to compile and run the second model I am getting the following error:
Building…
Error handling request from 127.0.0.1
Traceback (most recent call last):
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/aiohttp/web_protocol.py”, line 480, in _handle_request
resp = await request_handler(request)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/aiohttp/web_app.py”, line 569, in _handle
return await handler(request)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/httpstan/views.py”, line 103, in handle_create_model
_, stanc_warnings = httpstan.compile.compile(program_code, stan_model_name)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/httpstan/compile.py”, line 37, in compile
completed_process = subprocess.run(run_args, capture_output=True, timeout=1)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/subprocess.py”, line 505, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/subprocess.py”, line 1154, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/subprocess.py”, line 2022, in _communicate
self._check_timeout(endtime, orig_timeout, stdout, stderr)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/subprocess.py”, line 1198, in _check_timeout
raise TimeoutExpired(
subprocess.TimeoutExpired: Command ‘[PosixPath(’/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/httpstan/stanc’), ‘–name’, ‘model_lvfvy52u’, ‘–warn-pedantic’, ‘–print-cpp’, ‘/var/folders/dp/f415vsl54j3gxzlnnbndwsq40000gn/T/httpstan_b7n0tb55/model_lvfvy52u.stan’]’ timed out after 1 seconds
Traceback (most recent call last):
File “/Users/User/PycharmProjects/ufc/models/betancourt/analysis.py”, line 143, in
model = stan.build(stan_program, random_seed=4938483, data=data)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/stan/model.py”, line 519, in build
return asyncio.run(go())
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/nest_asyncio.py”, line 30, in run
return loop.run_until_complete(task)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/nest_asyncio.py”, line 98, in run_until_complete
return f.result()
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/asyncio/futures.py”, line 201, in result
raise self._exception.with_traceback(self._exception_tb)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/asyncio/tasks.py”, line 232, in __step
result = coro.send(None)
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/stan/model.py”, line 486, in go
match = re.search(r"““ValueError('"['”])”“”, resp.json()[“message”])
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/stan/common.py”, line 25, in json
return simdjson.loads(self.content) # type: ignore
File “/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/simdjson/init.py”, line 52, in loads
return parser.parse(s, True)
File “simdjson/csimdjson.pyx”, line 452, in csimdjson.Parser.parse
ValueError: TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
I believe that the problem is located in
subprocess.TimeoutExpired: Command ‘[PosixPath(’/Users/User/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/httpstan/stanc’), ‘–name’, ‘model_lvfvy52u’, ‘–warn-pedantic’, ‘–print-cpp’, ‘/var/folders/dp/f415vsl54j3gxzlnnbndwsq40000gn/T/httpstan_b7n0tb55/model_lvfvy52u.stan’]’ timed out after 1 seconds
If I inspect this directory I see that the directory “httpstan_b7n0tb55” doesn’t exists.
The “hello-world”-model is found in the cache directory after compiling. I deleted all the cached models from the following location:
from pathlib import Path
def cache_directory() -> Path:
"""Get httpstan cache path."""
return Path(appdirs.user_cache_dir("httpstan", version=httpstan.__version__))
print(cache_directory())
>>/Users/user/Library/Caches/httpstan/4.13.0
Any idea why httpstan
is for the “hello-world” script checking the cache directory and, if not found compiling it, whereas it checks a different non-exisiting directory for the other model and giving an error?
Help is much appreciated!
MacOS Sequoia (15.3.1)
httpstan (4.13.0)
pystan (3.10.0)