Skip to content

Log formatting error when initial state throws error in hwp supervisor #810

@BrianJKoopman

Description

@BrianJKoopman

Originally posted by @ykyohei in https://github.com/simonsobs/chwp-discussions/discussions/31.

If the initial state of a ControlAction throws an error the txaio.logger will also error out with the usual "Unable to format event" message. This can be fixed with something like:

diff --git a/socs/agents/hwp_supervisor/agent.py b/socs/agents/hwp_supervisor/agent.py
index 3957b126..4c9d1cfd 100644
--- a/socs/agents/hwp_supervisor/agent.py
+++ b/socs/agents/hwp_supervisor/agent.py
@@ -769,7 +769,7 @@ class ControlAction:
         """
         self.cur_state_info = ControlStateInfo(state)
         self.state_history.append(self.cur_state_info)
-        self.log.info(f"Setting state: {state}")
+        self.log.info(f"Setting state:\n{state}", state=state)
         if isinstance(state, ControlState.completed_states):
             self.completed = True
         if isinstance(state, ControlState.Done):

This will make every state setting log two lines, which maybe we don't always want? Will leave it up to @jlashner.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions