Skip to content

Commit

Permalink
Incorporate feedback from @erfz
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Aug 11, 2022
1 parent 328c5ba commit f695d23
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/developer/writing_an_agent/arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ precedent over the configuration file:

.. code-block::
$ python3 barebones_agent.py --mode count
$ OCS_CONFIG_DIR=/path/to/your/ocs-site-config/ python3 barebones_agent.py --mode count
2022-07-27T01:52:11+0000 Using OCS version 0.9.3
2022-07-27T01:52:11+0000 Log directory does not exist: /home/<user>/log/ocs/
2022-07-27T01:52:11+0000 ocs: starting <class 'ocs.ocs_agent.OCSAgent'> @ observatory.barebones1
Expand Down
59 changes: 57 additions & 2 deletions docs/developer/writing_an_agent/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,46 @@ will help with deployment on user's machines. Start by creating a file called
CMD ["--site-hub=ws://crossbar:8001/ws", \
"--site-http=http://crossbar:8001/call"]
At this point you should have a directory structure that looks somewhat like this:

.. code-block:: bash
├── ocs
│   ├── agents
│   │   ├── aggregator
│   │   ├── barebones_agent
│   │   │   ├── barebones_agent.py
│   │   │   └── Dockerfile
│   │   ├── fake_data
│   │   ├── host_manager
│   │   ├── influxdb_publisher
│   │   ├── ocs_plugin_standard.py
│   │   └── registry
│   ├── bin
│   ├── CONTRIBUTING.rst
│   ├── docker
│   ├── docker-compose.yml
│   ├── Dockerfile
│   ├── docs
│   ├── example
│   ├── LICENSE.txt
│   ├── Makefile
│   ├── MANIFEST.in
│   ├── ocs
│   ├── pyproject.toml
│   ├── README.rst
│   ├── requirements
│   ├── requirements.txt
│   ├── setup.cfg
│   ├── setup.py
│   ├── tests
│   ├── versioneer.py
└── ocs-site-configs
   ├── default.yaml
   └── docker-compose.yaml
We can now build the Docker image for the Agent. First we need to make sure the
ocs base container is built. From the root of the repository run:
ocs base container is built. From the root of the ocs repository run:

.. code-block:: bash
Expand Down Expand Up @@ -113,7 +151,24 @@ Now we can run the Agent with ``docker-compose``:
$ docker-compose up -d
The Agent's logs should be available:
Once the containers have started, you can see the running containers with:

.. code-block:: bash
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80cc47c7b476 ocs:latest "bash" 4 seconds ago Up 1 second barebones-agent-dev-ocs-client-1
e4dac1f43450 ocs-barebones-agent "dumb-init python3 -…" 4 seconds ago Up 2 seconds barebones-agent-dev-ocs-barebones-agent-1
c7e124c543e6 grafana/grafana:7.1.0 "/run.sh" 4 seconds ago Up 2 seconds 127.0.0.1:3000->3000/tcp barebones-agent-dev-grafana-1
ed64b4aca954 ocs-fake-data-agent:latest "dumb-init python3 -…" 4 seconds ago Up 2 seconds barebones-agent-dev-fake-data1-1
1d37cf0d8d22 ocs-influxdb-publisher-agent:latest "dumb-init python3 -…" 4 seconds ago Up 2 seconds barebones-agent-dev-ocs-influx-publisher-1
4f0a8fa762f5 ocs-web:latest "docker-entrypoint.s…" 4 seconds ago Up 2 seconds 8080/tcp, 127.0.0.1:3002->80/tcp barebones-agent-dev-ocs-web-1
b5ce20809c73 simonsobs/ocs-crossbar:v0.8.0 "crossbar start --cb…" 4 seconds ago Up 2 seconds 8000/tcp, 8080/tcp, 0.0.0.0:8001->8001/tcp, :::8001->8001/tcp barebones-agent-dev-crossbar-1
1bd06acf8da6 ocs-registry-agent:latest "dumb-init python3 -…" 4 seconds ago Up 2 seconds ocs-registry
6f785c871bc7 influxdb:1.7 "/entrypoint.sh infl…" 4 seconds ago Up 2 seconds 0.0.0.0:8086->8086/tcp, :::8086->8086/tcp influxdb
The Agent's logs should be available (using the container name from the
``docker ps`` output):

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/writing_an_agent/next.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ each one of which should contain an ``ocs_plugin_<experiment>.py`` file. This
script registers all of the agents so that Host Manager can start and stop
them. An example (of the standard ocs library plugin file) is shown here:

.. include:: ../../agents/ocs_plugin_standard.py
.. include:: ../../../agents/ocs_plugin_standard.py
:code: python

Development Tips
Expand Down
1 change: 1 addition & 0 deletions docs/developer/writing_an_agent/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Our Agent in full now looks like this:
session.set_status('running')
# Initialize the counter
self._count=True
counter = 0
print("Starting the count!")
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/writing_an_agent/publish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ an OCS Feed. We can inspect the feed on the commandline using the ``ocs-client-c

.. code-block::
$ ocs-client-cli listen observatory.barebones1.feeds.feed_name
$ OCS_CONFIG_DIR=/path/to/your/ocs-site-config/ ocs-client-cli listen observatory.barebones1.feeds.feed_name
Subscribing to observatory.barebones1.feeds.feed_name
2022-07-27T01:30:02+0000 [observatory.barebones1.feeds.feed_name] [{'count': {'block_name': 'count', 'data': {'value': [51, 52]}, 'timestamps': [1658885401.7566712, 1658885402.7578506]}}, {'agent_address': 'observatory.barebones1', 'agg_params': {'frame_length': 600}, 'feed_name': 'feed_name', 'address': 'observatory.barebones1.feeds.feed_name', 'record': True, 'session_id': '1658885340.4431145', 'agent_class': 'BarebonesAgent'}]
2022-07-27T01:30:04+0000 [observatory.barebones1.feeds.feed_name] [{'count': {'block_name': 'count', 'data': {'value': [53, 54]}, 'timestamps': [1658885403.7590535, 1658885404.7613802]}}, {'agent_address': 'observatory.barebones1', 'agg_params': {'frame_length': 600}, 'feed_name': 'feed_name', 'address': 'observatory.barebones1.feeds.feed_name', 'record': True, 'session_id': '1658885340.4431145', 'agent_class': 'BarebonesAgent'}]
Expand Down

0 comments on commit f695d23

Please sign in to comment.