-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix errors when loading strain designs * New FBA error message with community editions * Better handling of community edition errors * Add XLSX generation with all in and out fluxes * Fix missing newline character in net conversion * Refactoring; More community errors; Qt fix * More to core_gui * Remove special Gurobi handling; Point size fix * Better language * Remove edge error case; Import fix * simplification * Fix RGB color function argument typing --------- Co-authored-by: axelvonkamp <[email protected]>
- Loading branch information
1 parent
b4cc359
commit 46e7a36
Showing
9 changed files
with
244 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import gurobipy | ||
import io | ||
import traceback | ||
import cobra | ||
from qtpy.QtWidgets import QMessageBox | ||
|
||
|
||
def except_likely_community_model_error() -> None: | ||
"""Shows a message in the case that using a (size-limited) community edition solver version probably caused an error.""" | ||
community_error_text = "Solver error. One possible reason: You set CPLEX or Gurobi as solver although you only use their\n"+\ | ||
"Community edition which only work for small models. To solve this, either follow the instructions under\n"+\ | ||
"'Config->Configure IBM CPLEX full version' or 'Config->Configure Gurobi full version', or use a different solver such as GLPK." | ||
msgBox = QMessageBox() | ||
msgBox.setWindowTitle("Error") | ||
msgBox.setText(community_error_text) | ||
msgBox.setIcon(QMessageBox.Warning) | ||
msgBox.exec() | ||
|
||
|
||
def get_last_exception_string() -> str: | ||
output = io.StringIO() | ||
traceback.print_exc(file=output) | ||
return output.getvalue() | ||
|
||
|
||
def has_community_error_substring(string: str) -> bool: | ||
return ("Model too large for size-limited license" in string) or ("1016: Community Edition" in string) | ||
|
||
|
||
def model_optimization_with_exceptions(model: cobra.Model) -> None: | ||
try: | ||
return model.optimize() | ||
except Exception: | ||
exstr = get_last_exception_string() | ||
# Check for substrings of Gurobi and CPLEX community edition errors | ||
if has_community_error_substring(exstr): | ||
except_likely_community_model_error() |
Oops, something went wrong.