Barebones Agent

The Barebones Agent is provided with OCS to provide a starting point for Agent development. It is heavily used throughout the Agent development guide.

Configuration File Examples

Below are configuration examples for the ocs config file and for running the Agent in a docker container.

OCS Site Config

To configure the Fake Data Agent we need to add a FakeDataAgent block to our ocs configuration file. Here is an example configuration block using all of the available arguments:

{'agent-class': 'BarebonesAgent',
 'instance-id': 'barebones-1',
 'arguments': []},

Docker Compose

An example docker compose configuration:

ocs-barebones-1:
    image: simonsobs/ocs:latest
    hostname: ocs-docker
    environment:
      - LOGLEVEL=info
      - INSTANCE_ID=barebones-1
    volumes:
      - ${OCS_CONFIG_DIR}:/config:ro

Agent API

class ocs.agents.barebones.agent.BarebonesAgent(agent)[source]

Barebone Agent demonstrating writing an Agent from scratch.

This Agent is meant to be an example for Agent development, and provides a clean starting point when developing a new Agent.

Parameters:

agent (OCSAgent) – OCSAgent object from ocs.ocs_agent.init_site_agent().

agent

OCSAgent object from ocs.ocs_agent.init_site_agent().

Type:

OCSAgent

log

Logger object used to log events within the Agent.

Type:

txaio.tx.Logger

lock

TimeoutLock object used to prevent simultaneous commands being sent to hardware.

Type:

TimeoutLock

_count

Internal tracking of whether the Agent should be counting or not. This is used to exit the Process loop by changing it to False via the count.stop() command. Your Agent won’t use this exact attribute, but might have a similar one.

Type:

bool

count(test_mode=False)[source]

Process - Count up from 0.

The count will restart if the process is stopped and restarted.

Notes

The most recent value is stored in the session data object in the format:

>>> response.session['data']
{"value": 0,
 "timestamp":1600448753.9288929}
print(text='hello world')[source]

Task - Print some text passed to a Task.

Parameters:

text (str) – Text to print out. Defaults to ‘hello world’.

Notes

The session data will be updated with the text:

>>> response.session['data']
{'text': 'hello world',
 'last_updated': 1660249321.8729222}