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

Flatten all argument lists in config files #408

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/agents/aggregator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ An example site-config entry is::

{'agent-class': 'AggregatorAgent',
'instance-id': 'aggregator',
'arguments': [['--initial-state', 'record'],
['--time-per-file', '3600'],
['--data-dir', '/data/hk']
]},
'arguments': ['--initial-state', 'record',
'--time-per-file', '3600',
'--data-dir', '/data/hk']},

.. note::
``/data/hk`` is used to avoid conflict with other collections of data. In
Expand Down
6 changes: 3 additions & 3 deletions docs/agents/fake_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ available arguments::

{'agent-class': 'FakeDataAgent',
'instance-id': 'fake-data1',
'arguments': [['--mode', 'acq'],
['--num-channels', '16'],
['--sample-rate', '4']]},
'arguments': ['--mode', 'acq',
'--num-channels', '16',
'--sample-rate', '4']},

Docker Compose
``````````````
Expand Down
12 changes: 6 additions & 6 deletions docs/agents/influxdb_publisher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Add an InfluxDBAgent to your OCS configuration file::

{'agent-class': 'InfluxDBAgent',
'instance-id': 'influxagent',
'arguments': [['--initial-state', 'record'],
['--host', 'influxdb'],
['--port', 8086],
['--protocol', 'line'],
['--gzip', True],
['--database', 'ocs_feeds']]},
'arguments': ['--initial-state', 'record',
'--host', 'influxdb',
'--port', 8086,
'--protocol', 'line',
'--gzip', True,
'--database', 'ocs_feeds']},

Docker Compose
``````````````
Expand Down
16 changes: 8 additions & 8 deletions docs/user/centralized_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ block would become:
'agent-instances': [
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo1',
'arguments': [['--serial-number', 'LSA11AA'],
['--mode', 'idle']]},
'arguments': ['--serial-number', 'LSA11AA',
'--mode', 'idle']},
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo2',
'arguments': [['--serial-number', 'LSA22BB'],
['--mode', 'acq']]},
'arguments': ['--serial-number', 'LSA22BB',
'--mode', 'acq']},
{'agent-class': 'HostManager',
'instance-id': 'hm-host-1'},
},
Expand Down Expand Up @@ -159,12 +159,12 @@ become:
{'agent-class': 'Lakeshore372Agent',
'instance-id': 'LSARR00',
'manage': 'docker',
'arguments': [['--serial-number', 'LSARR00'],
['--ip-address', '10.10.10.55']]},
'arguments': ['--serial-number', 'LSARR00',
'--ip-address', '10.10.10.55']},
{'agent-class': 'HostManager',
'instance-id': 'hm-host-1-docker',
'arguments': [['--initial-state', 'up'],
['--docker-compose', '/home/ocs/site-config/host-1-docker/docker-compose.yaml']]},
'arguments': ['--initial-state', 'up',
'--docker-compose', '/home/ocs/site-config/host-1-docker/docker-compose.yaml']},
]
}

Expand Down
38 changes: 19 additions & 19 deletions docs/user/site_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ instances (running two different classes of agent):
'agent-instances': [
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo1',
'arguments': [['--serial-number', 'LSA11AA'],
['--mode', 'idle']]},
'arguments': ['--serial-number', 'LSA11AA',
'--mode', 'idle']},
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo2',
'arguments': [['--serial-number', 'LSA22BB'],
['--mode', 'acq']]},
'arguments': ['--serial-number', 'LSA22BB',
'--mode', 'acq']},
]
}

Expand All @@ -76,8 +76,8 @@ instances (running two different classes of agent):
'agent-instances': [
{'agent-class': 'Lakeshore372Agent',
'instance-id': 'LSARR00',
'arguments': [['--serial-number', 'LSARR00'],
['--ip-address', '10.10.10.55']]},
'arguments': ['--serial-number', 'LSARR00',
'--ip-address', '10.10.10.55']},
]
}

Expand All @@ -101,13 +101,13 @@ instances (running two different classes of agent):
'agent-instances': [
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo3',
'arguments': [['--serial-number', 'LSA33CC'],
['--mode', 'init']]},
'arguments': ['--serial-number', 'LSA33CC',
'--mode', 'init']},
{'agent-class': 'AggregatorAgent',
'instance-id': 'aggregator',
'arguments': [['--initial-state', 'record'],
['--time-per-file', '3600'],
['--data-dir', '/data/']]},
'arguments': ['--initial-state', 'record',
'--time-per-file', '3600',
'--data-dir', '/data/']},
]
}

Expand Down Expand Up @@ -146,8 +146,8 @@ example look at the first 372 Agent::

{'agent-class': 'Lakeshore372Agent',
'instance-id': 'LSARR00',
'arguments': [['--serial-number', 'LSARR00'],
['--ip-address', '10.10.10.55']]},
'arguments': ['--serial-number', 'LSARR00',
'--ip-address', '10.10.10.55']},

The ``agent-class`` is given by the actual Agent which will be running. This
must match the name defined in the Agent's code. The ``instance-id`` is a
Expand Down Expand Up @@ -212,15 +212,15 @@ To set at the host level:
# crossbar timeout set to 30 seconds
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo1',
'arguments': [['--serial-number', 'LSA11AA'],
['--mode', 'idle'],
['--crossbar-timeout', 30]]},
'arguments': ['--serial-number', 'LSA11AA',
'--mode', 'idle',
'--crossbar-timeout', 30]},
# crossbar timeout disabled
{'agent-class': 'Lakeshore240Agent',
'instance-id': 'thermo2',
'arguments': [['--serial-number', 'LSA22BB'],
['--mode', 'acq'],
['--crossbar-timeout', 0]]},
'arguments': ['--serial-number', 'LSA22BB',
'--mode', 'acq',
'--crossbar-timeout', 0]},
]
}

Expand Down
6 changes: 3 additions & 3 deletions example/docs/agent_template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ An example site-config-file block::

{'agent-class': 'TemplateAgent',
'instance-id': 'template',
'arguments': [['--argument-1', 'value1'],
['--argument-2', 42],
['--argument-3']]},
'arguments': ['--argument-1', 'value1',
'--argument-2', 42,
'--argument-3']},

Docker Compose
``````````````
Expand Down
4 changes: 2 additions & 2 deletions example/miniobs/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ hosts:
'arguments': []},
{'agent-class': 'AggregatorAgent',
'instance-id': 'agg1',
'arguments': [['--initial-state', 'record'],
['--data-dir', './data/']]},
'arguments': ['--initial-state', 'record',
'--data-dir', './data/']},
{'agent-class': 'FakeDataAgent',
'instance-id': 'data1',
'arguments': []},
Expand Down
6 changes: 1 addition & 5 deletions ocs/site_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ def from_dict(cls, data, parent=None):

``arguments`` (list, optional):
A list of arguments that should be passed back to the
agent. Historically the arguments have been grouped into
into key value pairs, e.g. [['--key1', 'value'],
['--key2', 'value']] but these days whatever you passed in
gets flattened to a single list (i.e. that is equivalent
to ['--key1', 'value', '--key2', 'value'].
agent.

``manage`` (str, optional):
A string describing how a HostManager should manage this
Expand Down
36 changes: 18 additions & 18 deletions tests/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,41 @@ hosts:
{'agent-class': 'FakeDataAgent',
'instance-id': 'fake-data-local',
'manage': 'host/down',
'arguments': [['--mode', 'idle'],
['--num-channels', '16'],
['--sample-rate', '5'],
['--frame-length', '10']]},
'arguments': ['--mode', 'idle',
'--num-channels', '16',
'--sample-rate', '5',
'--frame-length', '10']},
{'agent-class': 'RegistryAgent',
'instance-id': 'registry',
'manage': 'host/up',
'arguments': []},
{'agent-class': 'AggregatorAgent',
'instance-id': 'aggregator-local',
'manage': 'ignore',
'arguments': [['--initial-state', 'idle'],
['--time-per-file', '30'],
['--data-dir', '/tmp/data/']]},
'arguments': ['--initial-state', 'idle',
'--time-per-file', '30',
'--data-dir', '/tmp/data/']},
{'agent-class': 'InfluxDBAgent',
'instance-id': 'influxagent-local',
'arguments': [['--initial-state', 'idle'],
['--host', 'localhost'],
['--port', 18086],
['--database', 'ocs_feeds']]},
'arguments': ['--initial-state', 'idle',
'--host', 'localhost',
'--port', 18086,
'--database', 'ocs_feeds']},
]
}

ocs-docker: {
'agent-instances': [
{'agent-class': 'FakeDataAgent',
'instance-id': 'fake-data1',
'arguments': [['--mode', 'acq'],
['--num-channels', '16'],
['--sample-rate', '5'],
['--frame-length', '10']]},
'arguments': ['--mode', 'acq',
'--num-channels', '16',
'--sample-rate', '5',
'--frame-length', '10']},
{'agent-class': 'AggregatorAgent',
'instance-id': 'aggregator',
'arguments': [['--initial-state', 'record'],
['--time-per-file', '30'],
['--data-dir', '/data/']]},
'arguments': ['--initial-state', 'record',
'--time-per-file', '30',
'--data-dir', '/data/']},
]
}