Skip to content
Snippets Groups Projects
Commit e2e3b889 authored by Ivan Kondov's avatar Ivan Kondov
Browse files

fix job state check, add unreserved and lost jobs checks

parent 0239c16e
No related branches found
No related tags found
1 merge request!334Resolve "Detect unreserved and lost launches and show more metadata in overview"
......@@ -248,6 +248,9 @@ class SessionManager(InteractiveConsole):
print('vary:', formatter(self.session.get_vary_df()))
elif model.com in ('hist', 'history'):
print(get_prettytable(get_model_history(self.lpad, self.uuid)))
unres = self.session.wfe and self.session.wfe.get_unreserved_nodes() or []
lostj = self.session.wfe and self.session.wfe.get_lost_jobs() or []
print(f'Unreserved: {unres}, Lost: {lostj}' if unres or lostj else '')
elif model.com == 'tag':
print(formatter(get_model_tag(self.lpad, self.uuid)))
elif model.com == 'find':
......
......@@ -7,7 +7,7 @@ from fireworks import Workflow, Firework, FWorker, Launch
from fireworks.utilities.fw_serializers import load_object
from fireworks.core.rocket_launcher import rapidfire, launch_rocket
from virtmat.middleware.resconfig import get_default_resconfig
from virtmat.middleware.utilities import exec_cancel
from virtmat.middleware.utilities import get_slurm_job_state, exec_cancel
from virtmat.language.utilities.errors import FILE_READ_EXCEPTIONS
from virtmat.language.utilities.errors import ObjectFromFileError, UpdateError
from virtmat.language.utilities.mongodb import get_iso_datetime
......@@ -179,7 +179,8 @@ def cancel_eval(lpad, fw_id, restart=False, deactivate=False):
res_id = lpad.get_reservation_id_from_fw_id(fw_id)
if fw['spec']['_category'] == 'batch':
try:
exec_cancel(res_id)
if get_slurm_job_state(res_id) in ['PENDING', 'RUNNING']:
exec_cancel(res_id)
except RuntimeError as err:
raise UpdateError(str(err)) from err
if fw['state'] == 'RESERVED':
......@@ -205,7 +206,7 @@ def rerun_vars(lpad, uuid, var_names):
change_vars(lpad, uuid, var_names, mapping)
def cancel_vars(lpad, uuid, var_names):
def cancel_vars(lpad, uuid, var_names): # not covered
"""manually change the state of a list of variables: apply cancel"""
mapping = {'FIZZLED': lpad.defuse_fw,
'PAUSED': lpad.defuse_fw,
......@@ -233,7 +234,7 @@ def change_vars(lpad, uuid, var_names, mapping):
not_found = next(n for n in var_names if n not in var_names_found)
raise UpdateError(f'Variable {not_found} not found in the model.')
for node, name in zip(wfs[0]['nodes'], var_names_found):
if node['state'] not in mapping:
if node['state'] not in mapping: # not covered
msg = f'State of variable {name} not allowed: {node["state"]}'
raise UpdateError(msg)
mapping[node['state']](node['fw_id'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment