Skip to content

Create UKKID Controller agent - #1083

Open
wenlockedge wants to merge 20 commits into
mainfrom
ukkid_agent
Open

Create UKKID Controller agent#1083
wenlockedge wants to merge 20 commits into
mainfrom
ukkid_agent

Conversation

@wenlockedge

Copy link
Copy Markdown

Creating a pull request as request by Brian Koopman on 10 July 2026.

Description

Motivation and Context

How Has This Been Tested?

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
BrianJKoopman self-requested a review September 1, 2026 18:27
@BrianJKoopman BrianJKoopman changed the title Ukkid agent - pull request to main Create UKKID Controller agent Sep 1, 2026
@BrianJKoopman BrianJKoopman added the new agent New OCS agent needs to be created label Sep 2, 2026

@BrianJKoopman BrianJKoopman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for PRing this @wenlockedge, and apologies it took so long to get to. Lots of comments below. I'm happy to help addressing some of them, like the packaging bits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's not commit a 49 MB .csv file here. That ~doubles the size of cloning this entire repo.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi,
Yes, it makes sense to only allow actual code, rather than ancillary data files, in the repo. However, this file is required for the code to work properly in mocked mode. Do you have a recommendation for the best place for it can go such that it is publicly accessible and can be downloaded by someone following the install procedure in README.md? Something like a personal google drive/dropbox/ or git repo doesn't seem like the right solution...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Drop this one too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

See above.


2. souk_readout_tools. This is the python code for the readout client
described above (note this repository also contains the code for the
readout server software that runs on the RFSoCs). **Use branch main**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The "Use branch main" conflicts with "Be sure to select branch dev/1.3.0 from the pull down menu on github before cloning this repository." below. Which branch is recommended?

Comment on lines +327 to +328
The way I am doing this (there may be a more elegant way) is to create a soflink from the default "agents" directory in your default OCS installed to point at the
ukkid_controller directory within the SOCS directory tree. On my system I had installed ocs in /home/leechj/ocs and socs in /home/leechj/socs, so I did.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, there is a more elegant way. ocs is capable of launching any agent registered with a given 'ocs plugin'. socs is an ocs plugin. All agents within socs are 'registered' in the file plugin.py.

So a few recommendations to match the standards already in place in socs are:

  1. Rename ukkid_controller.py to agent.py. (Just for consistency really.)
  2. Add a line in plugin.py for the UKKIDController.
  3. Create an __init__.py file in socs/socs/agents/ukkid_controller/. This makes a regular package that can be imported. This'll be a blank file.

Once you do this, remove this whole "Making the UKKID_controller.py agent available to your OCS install" section.

Comment on lines +52 to +62
1. An Observatory Control System (OCS) installation.

2. souk_readout_tools. This is the python code for the readout client
described above (note this repository also contains the code for the
readout server software that runs on the RFSoCs). **Use branch main**
for compatibility with the ukkid_controller agent.

3. The ukkid_controller agent itself - i.e. everything within the
agents/UKKIDcontroller directory. This can be obtained by checking out
the "ukkid_agent" branch of the official "socs" Simons Observatory
repository.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might make sense for a guide on Confluence or similar, but 1 and 3 don't really make sense to include in this context. ocs is a requirement for socs (i.e. it gets installed by the socs installation automatically. And the ukkid_controller agent is getting packaged into socs -- of course it's included.

Comment on lines +1408 to +1410
while self.client.get_info(['server'])[0]['latest_sweep_data_valid'] is False:
self.log.info('Waiting for scan to complete, sleeping for 1 second.')
time.sleep(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if the server never reports a valid sweep? Seems like we could get stuck here if there's an issue on the server end.

Comment on lines +1454 to +1459
def _abort_narrow_band_sweep(self, session, params):
if session.status == 'running':
session.set_status('stopping')

if session.status != 'running':
return False, 'Aborted narrow band sweep data.'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Like the others, this aborter doesn't do anything unless the task handles the change in status appropriately.

self.log.info('Accurate Frequencies extracted from ' + f_accurate_filename)

# At this point. f_accurate_list should defined.
self.log.info('set_tone_frequencies: Will use tone frequencies of ' + str(f_accurate_list))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How long is this list in practice?

# JL write something to the feed here?
return True, 'set_tone_frequencies: complete.'

def get_tone_frequencies(self, session, params=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How are these 'get_X' tasks used in practice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've left some of these as detailed comments below, but some general comments:

  • You don't need to/shouldn't publish log style messages to the feed. Things like "Expected key f_guess_list not found in json file..." don't need to be kept forever in the .g3 file archive. That's more appropriate as a log message. They're useful when that message just occurred, but less so on data that's years old.
  • You probably don't need to put those types of log messages into session.data either. Some sort of 'status' key/value like 'streaming: True' makes sense, but long log messages fit better in the stdout log.
  • There's a lot of 'go find the latest relevant file' code in this agent, which would probably make more sense to abstract away to either a 'driver module' or to the souk_readout_tools package. This doesn't have to happen now, but it would clean up the agent a bit to do it eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new agent New OCS agent needs to be created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants