Skip to content

Commit c612110

Browse files
committed
Stop trying to munge return codes from subprocess
1 parent f3c29b3 commit c612110

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

cmdstanpy/model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
cmdstan_version_before,
5555
do_command,
5656
get_logger,
57-
returncode_msg,
5857
)
5958
from cmdstanpy.utils.filesystem import (
6059
temp_inits,
@@ -2162,14 +2161,13 @@ def _timer_target() -> None:
21622161
get_logger().info('%s done processing', logger_prefix)
21632162

21642163
if retcode != 0:
2165-
retcode_summary = returncode_msg(retcode)
21662164
serror = ''
21672165
try:
21682166
serror = os.strerror(retcode)
21692167
except (ArithmeticError, ValueError):
21702168
pass
21712169
get_logger().error(
2172-
'%s error: %s %s', logger_prefix, retcode_summary, serror
2170+
"%s error: code '%d' %s", logger_prefix, retcode, serror
21732171
)
21742172

21752173
@staticmethod

cmdstanpy/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
validate_dir,
2121
wrap_url_progress_hook,
2222
)
23-
from .command import do_command, returncode_msg
23+
from .command import do_command
2424
from .data_munging import build_xarray_data, flatten_chains
2525
from .filesystem import (
2626
SanitizedOrTmpFilePath,
@@ -114,7 +114,6 @@ def show_versions(output: bool = True) -> str:
114114
'parse_rdump_value',
115115
'pushd',
116116
'read_metric',
117-
'returncode_msg',
118117
'rload',
119118
'set_cmdstan_path',
120119
'set_make_env',

cmdstanpy/utils/command.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,10 @@ def do_command(
7171
serror = os.strerror(proc.returncode)
7272
except (ArithmeticError, ValueError):
7373
pass
74-
msg = 'Command {}\n\t{} {}'.format(
75-
cmd, returncode_msg(proc.returncode), serror
74+
msg = "Command {}\n\texited with code '{}' {}".format(
75+
cmd, proc.returncode, serror
7676
)
7777
raise RuntimeError(msg)
7878
except OSError as e:
7979
msg = 'Command: {}\nfailed with error {}\n'.format(cmd, str(e))
8080
raise RuntimeError(msg) from e
81-
82-
83-
def returncode_msg(retcode: int) -> str:
84-
"""interpret retcode"""
85-
if retcode < 0:
86-
sig = -1 * retcode
87-
return f'terminated by signal {sig}'
88-
if retcode <= 125:
89-
return 'error during processing'
90-
if retcode == 126: # shouldn't happen
91-
return ''
92-
if retcode == 127:
93-
return 'program not found'
94-
sig = retcode - 128
95-
return f'terminated by signal {sig}'

0 commit comments

Comments
 (0)