Skip to content

Commit

Permalink
Fix solver query in queue manager
Browse files Browse the repository at this point in the history
Must get solver from inputs table, not subscenario table.
  • Loading branch information
anamileva committed Oct 29, 2020
1 parent f8bfaeb commit 698f448
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions ui/server/run_queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,46 @@ def manage_queue(db_path):
GROUP BY scenario_id
""").fetchone()

# # Get the requested solver
solver_query = c.execute("""
SELECT name
FROM subscenarios_options_solver
WHERE solver_options_id = (
SELECT solver_options_id
# Get the requested solver
solver_options_id = c.execute("""
SELECT solver_options_id
FROM scenarios
WHERE scenario_id = {}
);
""".format(next_scenario_to_run[0])
).fetchone()
""".format(next_scenario_to_run[0])
).fetchone()[0]

solver_query = c.execute("""
SELECT DISTINCT solver
FROM inputs_options_solver
WHERE solver_options_id = {};
""".format(solver_options_id)
).fetchone()
if solver_query is None:
# TODO: we shoud specify the default solver as a
# TODO: we should specify the default solver as a
# global variable somewhere
solver = 'cbc'
else:
solver = solver_query[0]
# Check that there's only one solver specified for the
# solver_options_id
one_solver_check = c.execute("""
SELECT COUNT()
FROM (
SELECT DISTINCT solver
FROM inputs_options_solver
WHERE solver_options_id = {}
)
;
""".format(solver_options_id)
).fetchone()[0]
if one_solver_check > 1:
raise ValueError("""
Only one solver can be specified per
solver_options_id. Check the solver_options_id {}
in the the inputs_options_solver table.
""".format(solver_options_id)
)
else:
solver = solver_query[0]
sio.emit(
"launch_scenario_process",
{"scenario": next_scenario_to_run[0], "solver": solver,
Expand Down

0 comments on commit 698f448

Please sign in to comment.