Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cmdstanpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
cmdstan_version_before,
do_command,
get_logger,
returncode_msg,
)
from cmdstanpy.utils.filesystem import (
temp_inits,
Expand Down Expand Up @@ -2162,14 +2161,13 @@ def _timer_target() -> None:
get_logger().info('%s done processing', logger_prefix)

if retcode != 0:
retcode_summary = returncode_msg(retcode)
serror = ''
try:
serror = os.strerror(retcode)
except (ArithmeticError, ValueError):
pass
get_logger().error(
'%s error: %s %s', logger_prefix, retcode_summary, serror
"%s error: code '%d' %s", logger_prefix, retcode, serror
)

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions cmdstanpy/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
validate_dir,
wrap_url_progress_hook,
)
from .command import do_command, returncode_msg
from .command import do_command
from .data_munging import build_xarray_data, flatten_chains
from .filesystem import (
SanitizedOrTmpFilePath,
Expand Down Expand Up @@ -114,7 +114,6 @@ def show_versions(output: bool = True) -> str:
'parse_rdump_value',
'pushd',
'read_metric',
'returncode_msg',
'rload',
'set_cmdstan_path',
'set_make_env',
Expand Down
19 changes: 2 additions & 17 deletions cmdstanpy/utils/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,10 @@ def do_command(
serror = os.strerror(proc.returncode)
except (ArithmeticError, ValueError):
pass
msg = 'Command {}\n\t{} {}'.format(
cmd, returncode_msg(proc.returncode), serror
msg = "Command {}\n\texited with code '{}' {}".format(
cmd, proc.returncode, serror
)
raise RuntimeError(msg)
except OSError as e:
msg = 'Command: {}\nfailed with error {}\n'.format(cmd, str(e))
raise RuntimeError(msg) from e


def returncode_msg(retcode: int) -> str:
"""interpret retcode"""
if retcode < 0:
sig = -1 * retcode
return f'terminated by signal {sig}'
if retcode <= 125:
return 'error during processing'
if retcode == 126: # shouldn't happen
return ''
if retcode == 127:
return 'program not found'
sig = retcode - 128
return f'terminated by signal {sig}'
Loading