You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In NodesTreeWidget._update_tree_node, we call AiiDA's calc_info CLI command, which in turn tries to do process_state = node.process_state.value.capitalize(), which will raise an exception if process_state is None. When using the NodesTreeWidget as part of the ProcessMonitor, I believe the exception will cause the monitor to disable future tree updates.
I recommend a guard in the CLI command for the next AiiDA release. In the meantime, perhaps we bail on the update if there's not yet a process state.
def_update_tree_node(self, tree_node):
ifisinstance(tree_node, AiidaProcessNodeTreeNode):
process_node=orm.load_node(tree_node.pk)
# PROPOSED CHANGEifnot (hasattr(process_node, "process_state") andprocess_node.process_state):
return# END PROPOSALtree_node.name=calc_info(process_node)
# Override the process state in case that the process node has failed:# (This could be refactored with structural pattern matching with py>=3.10.)process_state= (
engine.ProcessState.EXCEPTEDifprocess_node.is_failedelseprocess_node.process_state
)
tree_node.icon_style=self.PROCESS_STATE_STYLE.get(
process_state, self.PROCESS_STATE_STYLE_DEFAULT
)
Not sure if we need the hasattr part, but I suppose it doesn't hurt. Also, the check is boolean in general, not specifically is not None, assuming that bailing on empty states is also okay. Correct me if I'm wrong. Though I don't think we can have empty states, as ProcessState is an Enum.
The text was updated successfully, but these errors were encountered:
Sounds reasonable to me, thanks! I'd start with the fix in aiida-core since that might inform the fix in AWB, such as...
Not sure if we need the hasattr part, but I suppose it doesn't hurt.
I'd be surprised if it is needed, I'd hope that process_state is part of the Process ORM and should be there always. Would be nice to avoid hasattr if we can for performance reasons.
Also, the check is boolean in general, not specifically is not None, assuming that bailing on empty states is also okay. Correct me if I'm wrong. Though I don't think we can have empty states, as ProcessState is an Enum.
Sounds reasonable! 👍
Thank you for a very clear write up and for discovering this!
Look at the process_state property method of process node
@propertydefprocess_state(self) ->Optional[ProcessState]:
"""Return the process state :returns: the process state instance of ProcessState enum """state=self.base.attributes.get(self.PROCESS_STATE_KEY, None)
ifstateisNone:
returnstatereturnProcessState(state)
The condition can simplified to:
ifprocess_node.process_stateisnotNone:
I guess? Meanwhile, I think the process_state of process_node can be None, see my comment on aiidateam/aiida-core#6682
In
NodesTreeWidget._update_tree_node
, we call AiiDA'scalc_info
CLI command, which in turn tries to doprocess_state = node.process_state.value.capitalize()
, which will raise an exception ifprocess_state
isNone
. When using theNodesTreeWidget
as part of theProcessMonitor
, I believe the exception will cause the monitor to disable future tree updates.I recommend a guard in the CLI command for the next AiiDA release. In the meantime, perhaps we bail on the update if there's not yet a process state.
Not sure if we need the
hasattr
part, but I suppose it doesn't hurt. Also, the check is boolean in general, not specificallyis not None
, assuming that bailing on empty states is also okay. Correct me if I'm wrong. Though I don't think we can have empty states, asProcessState
is anEnum
.The text was updated successfully, but these errors were encountered: