Skip to content

Commit

Permalink
Merge pull request #704 from tillahoffmann/example
Browse files Browse the repository at this point in the history
Always run `compile_example` in `install_cmdstan` (fixes #703).
  • Loading branch information
WardBrian authored Sep 22, 2023
2 parents 2cf6120 + 2895639 commit d4839e0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions cmdstanpy/install_cmdstan.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,22 @@ def compile_example(verbose: bool = False) -> None:
:param verbose: Boolean value; when ``True``, show output from make command.
"""
cmd = [
MAKE,
Path(
os.path.join('examples', 'bernoulli', 'bernoulli' + EXTENSION)
).as_posix(),
]
path = Path('examples', 'bernoulli', 'bernoulli').with_suffix(EXTENSION)
if path.is_file():
path.unlink()

cmd = [MAKE, path.as_posix()]
try:
if verbose:
do_command(cmd)
else:
do_command(cmd, fd_out=None)
except RuntimeError as e:
# pylint: disable=raise-missing-from
raise CmdStanInstallError(f'Command "make clean-all" failed\n{e}')
raise CmdStanInstallError(f'Command "{" ".join(cmd)}" failed:\n{e}')

if not path.is_file():
raise CmdStanInstallError("Failed to generate example binary")


def rebuild_cmdstan(
Expand Down Expand Up @@ -421,8 +423,6 @@ def install_version(
clean_all(verbose)
print('Rebuilding version {}'.format(cmdstan_version))
build(verbose, progress=progress, cores=cores)
print('Test model compilation')
compile_example(verbose)
print('Installed {}'.format(cmdstan_version))


Expand Down Expand Up @@ -638,6 +638,10 @@ def run_install(args: Union[InteractiveSettings, InstallationSettings]) -> None:
else:
print('CmdStan version {} already installed'.format(args.version))

with pushd(cmdstan_version):
print('Test model compilation')
compile_example(args.verbose)


def parse_cmdline_args() -> Dict[str, Any]:
parser = argparse.ArgumentParser("install_cmdstan")
Expand Down

0 comments on commit d4839e0

Please sign in to comment.