simonsobs / simonsobs/socs

Log formatting error when initial state throws error in hwp supervisor

Open
#810 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

agent: hwp supervisor bug
Dominant language
Python
Stars
17
Forks
20
Avg merge
1h 22m
Merged PRs (30d)
2

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in socs/agents/hwp_supervisor/agent.py at ControlAction's state-setting method around line 769. Reproduce an initial-state error and inspect how txaio.logger formats the resulting event. Decide whether the message should remain one line or use the proposed multiline format, then verify that state-setting logs no longer trigger "Unable to format event".

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.