Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supervisor actions #628

Merged
merged 11 commits into from
Feb 20, 2024
Merged

Supervisor actions #628

merged 11 commits into from
Feb 20, 2024

Conversation

jlashner
Copy link
Collaborator

@jlashner jlashner commented Feb 2, 2024

Provides various updates to the HWP Supervisor required for site use.

Description

This PR adds some changes that are necessary for the Supervisor to be run through sorunlib and the scheduler. Mainly, we needed a better way to track if a user-commanded operation has finished, and to determine if it was successful.

Currently, the supervisor is done by a fairly simple state machine, where agent tasks would put the machine in a particular state, and states could put the machine into a new state depending on the update function.

This PR modifies this a bit, by grouping states together into "Actions", based around user requests. Now, when a user runs an operation like pid_to_freq, instead of just setting the PidToFreq state, this will request a new Action that begins in the PidToFreq state. This action can be monitored until it enters a "completed" state (i.e. Done, Error, or Abort) at which point the action will no longer be modified. Actions provide a bit more extra book-keeping, including a unique id, the current state, the state-history of the action, and whether the action is completed and successful.

Tasks now will create an action, and monitor it until the action is completed, at which point the task will finish.

An action can be aborted by running the abort_action task, which will put the current action into the "Abort" state at the next opportunity, and will put the state machine into an idle state.

Note: This requires changes from the hwp-emulation branch, so I set that as the base. I can change that after hwp-emulator is merged in.

Motivation and Context

Necessary behavior changes in order to add to next-line

How Has This Been Tested?

Certain operations such as pid_to_freq, and pmx_off have been tested with the HWP emulator. We hope to be able to be able to test more on a real platform.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@BrianJKoopman
Copy link
Member

Now that the tests in #606 are working can you rebase this?

Base automatically changed from hwp-emulation to main February 6, 2024 20:42
Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is look good. My comments/questions are mostly:

  • Documentation change requests/comments
  • Asking for clarification on how abort works
  • Checking in on task success verification and wondering what happens when Supervisor agent tasks fail

docs/agents/hwp_supervisor_agent.rst Outdated Show resolved Hide resolved
docs/agents/hwp_supervisor_agent.rst Outdated Show resolved Hide resolved
docs/agents/hwp_supervisor_agent.rst Outdated Show resolved Hide resolved
socs/testing/device_emulator.py Show resolved Hide resolved
socs/testing/device_emulator.py Show resolved Hide resolved
docs/agents/hwp_supervisor_agent.rst Outdated Show resolved Hide resolved
socs/agents/hwp_supervisor/agent.py Show resolved Hide resolved
socs/agents/hwp_supervisor/agent.py Show resolved Hide resolved
socs/agents/hwp_supervisor/agent.py Outdated Show resolved Hide resolved
socs/agents/hwp_supervisor/agent.py Show resolved Hide resolved
@jlashner
Copy link
Collaborator Author

Hi Brian, updated docs and tried to address all of your comments, so if you could re-review that would be great.

In the RST I added a couple of paragraphs that try to explain what a Control Action is within the agent. They are pretty much one-to-one with OCS operations, so its almost interchangeable, but not exactly the same thing.

Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Sorry, botched the review -- GitHub's comment response options make that easy to do, more comments.)

Thanks for the docs updates, the new section on Actions cleared things up for me. I do think we need to return action.success, instead of just True all the time. Other than that, looks good!

socs/agents/hwp_supervisor/agent.py Show resolved Hide resolved
socs/agents/hwp_supervisor/agent.py Outdated Show resolved Hide resolved
@jlashner
Copy link
Collaborator Author

Hey brian, just submitted a commit that addresses your last piece of feedback

Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the updates!

@BrianJKoopman BrianJKoopman merged commit af4b872 into main Feb 20, 2024
7 checks passed
@BrianJKoopman BrianJKoopman deleted the supervisor-actions branch February 20, 2024 19:39
hnakata-JP pushed a commit that referenced this pull request Apr 12, 2024
* Add device_emulator reconnect on lost connection

* HWP Supervisor Action system

* docs, misc changes

* Separate "gripper" and "driver" ibootbars

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Makes tcp reconnection optional

* Docs updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Addresses Brian's feedback

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
BrianJKoopman pushed a commit that referenced this pull request May 8, 2024
* Add device_emulator reconnect on lost connection

* HWP Supervisor Action system

* docs, misc changes

* Separate "gripper" and "driver" ibootbars

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Makes tcp reconnection optional

* Docs updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Addresses Brian's feedback

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants