@@ -1252,6 +1252,8 @@ def install_cmdstan(
12521252 progress : bool = False ,
12531253 verbose : bool = False ,
12541254 cores : int = 1 ,
1255+ * ,
1256+ interactive : bool = False ,
12551257) -> bool :
12561258 """
12571259 Download and install a CmdStan release from GitHub. Downloads the release
@@ -1283,35 +1285,60 @@ def install_cmdstan(
12831285 :param cores: Integer, number of cores to use in the ``make`` command.
12841286 Default is 1 core.
12851287
1288+ :param interactive: Boolean value; if true, ignore all other arguments
1289+ to this function and run in an interactive mode, prompting the user
1290+ to provide the other information manually through the standard input.
1291+
1292+ This flag should only be used in interactive environments,
1293+ e.g. on the command line.
1294+
12861295 :return: Boolean value; ``True`` for success.
12871296 """
1297+ logger = get_logger ()
12881298 try :
1289- from .install_cmdstan import InstallationSettings , run_install
1290-
1291- args = InstallationSettings (
1292- version = version ,
1293- overwrite = overwrite ,
1294- verbose = verbose ,
1295- compiler = compiler ,
1296- progress = progress ,
1297- dir = dir ,
1298- cores = cores ,
1299+ from .install_cmdstan import (
1300+ InstallationSettings ,
1301+ InteractiveSettings ,
1302+ run_install ,
12991303 )
1304+
1305+ args : Union [InstallationSettings , InteractiveSettings ]
1306+
1307+ if interactive :
1308+ if any (
1309+ [
1310+ version ,
1311+ dir ,
1312+ overwrite ,
1313+ compiler ,
1314+ progress ,
1315+ verbose ,
1316+ cores != 1 ,
1317+ ]
1318+ ):
1319+ logger .warning (
1320+ "Interactive installation requested but other arguments"
1321+ " were used.\n \t These values will be ignored!"
1322+ )
1323+ args = InteractiveSettings ()
1324+ else :
1325+ args = InstallationSettings (
1326+ version = version ,
1327+ overwrite = overwrite ,
1328+ verbose = verbose ,
1329+ compiler = compiler ,
1330+ progress = progress ,
1331+ dir = dir ,
1332+ cores = cores ,
1333+ )
13001334 run_install (args )
13011335 # pylint: disable=broad-except
13021336 except Exception as e :
1303- logger = get_logger ()
1304- logger .warning ('CmdStan installation failed.' )
1305- logger .warning (str (e ))
1337+ logger .warning ('CmdStan installation failed.\n %s' , str (e ))
13061338 return False
13071339
1308- if dir is not None :
1309- if version is not None :
1310- set_cmdstan_path (os .path .join (dir , 'cmdstan-' + version ))
1311- else :
1312- set_cmdstan_path (
1313- os .path .join (dir , get_latest_cmdstan (dir )) # type: ignore
1314- )
1340+ set_cmdstan_path (args .dir )
1341+
13151342 return True
13161343
13171344
0 commit comments