Skip to content

Commit

Permalink
Fix minor error in exit_code_message; change to safe_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed Nov 21, 2023
1 parent 03d3aab commit d750dfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pyomo/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,11 @@ class will still create ``c`` instances that only have the single


def _dump(*args, **kwds):
# TODO: Change the default behavior to no longer be YAML.
# This was a legacy decision that may no longer be the best
# decision, given changes to technology over the years.
try:
from yaml import dump
from yaml import safe_dump as dump
except ImportError:
# dump = lambda x,**y: str(x)
# YAML uses lowercase True/False
Expand Down Expand Up @@ -1099,7 +1102,7 @@ def _value2string(prefix, value, obj):
try:
_data = value._data if value is obj else value
if getattr(builtins, _data.__class__.__name__, None) is not None:
_str += _dump(_data, default_flow_style=True).rstrip()
_str += _dump(_data, default_flow_style=True, allow_unicode=True).rstrip()
if _str.endswith("..."):
_str = _str[:-3].rstrip()
else:
Expand Down
4 changes: 3 additions & 1 deletion pyomo/solver/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def parse_sol_file(
f"ERROR READING `sol` FILE. Expected `objno`; received {line}."
)
result.extra_info.solver_message = message.strip().replace('\n', '; ')
exit_code_message = ''
if (exit_code[1] >= 0) and (exit_code[1] <= 99):
result.solution_status = SolutionStatus.optimal
result.termination_condition = TerminationCondition.convergenceCriteriaSatisfied
Expand Down Expand Up @@ -362,7 +363,8 @@ def parse_sol_file(
result.termination_condition = TerminationCondition.error

if result.extra_info.solver_message:
result.extra_info.solver_message += '; ' + exit_code_message
if exit_code_message:
result.extra_info.solver_message += '; ' + exit_code_message
else:
result.extra_info.solver_message = exit_code_message

Expand Down

0 comments on commit d750dfb

Please sign in to comment.