Skip to content

Commit beb3505

Browse files
authored
Merge pull request #569 from NERSC/update-agent-docs
update agent docs
2 parents 0894ba7 + 4324174 commit beb3505

2 files changed

Lines changed: 78 additions & 16 deletions

File tree

backend/agent/README.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# Launch an agent
44

5-
The agent is the process that starts operator containers, coordinates their lifecycle, and talks to the platform over NATS. You need at least one running agent before operators can launch.
5+
The agent is the process that starts operator containers, coordinates their lifecycle, and talks to the rest of the platform over NATS. You need at least one running agent before operators can launch.
66

77
## Prerequisites
88

9-
Have a Python environment manager available (e.g., [`poetry`](https://python-poetry.org/docs/) or [`uv`](https://github.com/astral-sh/uv)).
9+
Have a Python environment manager available (e.g., [`uv`](https://github.com/astral-sh/uv)).
1010

1111
## Configure the environment
1212

@@ -23,10 +23,10 @@ cd backend/agent
2323
AGENT_NAME=SecretAgentMan # change to how you want it to display in the frontend
2424
```
2525

26-
- If you want to target specific resources, set tags:
26+
- If you want to run operators with specific tags on this agent, set your tags:
2727

2828
```bash
29-
AGENT_TAGS='["ncem-4dcamera","gpu"]'
29+
AGENT_TAGS='["ncem-4dcamera"]'
3030
```
3131

3232
## Install and run
@@ -43,12 +43,9 @@ or
4343
uv sync
4444
```
4545

46-
If an agent is running at NERSC, we will use `podman-hpc`:
46+
If an agent is running at NERSC, we will use `podman-hpc`. If using `uv`, it will attempt to use the python binary from the user account that ran this command first, which is normally stored in `~/.local/share/uv/python`. If you are sharing this agent between users, you can set the `UV_PYTHON_INSTALL_DIR` env var to a shared location.
4747

4848
```bash
49-
# note this will link the current user account's python (normally stored in ~/.local/share/uv/python)
50-
# if we need to share across accounts, you can set the `UV_PYTHON_INSTALL_DIR` env var to a shared location
51-
# prior to running the command below
5249
uv sync --extra hpc
5350
```
5451

@@ -65,3 +62,37 @@ or with `uv`:
6562
cd backend/agent
6663
uv run interactem-agent
6764
```
65+
66+
## Connecting an agent to a different NATS cluster
67+
68+
To connect into a different NATS cluster, we have to set the `.env` variables:
69+
70+
```bash
71+
NATS_SERVER_URL=nats://the.url.to.nats # could also be ws/wss (websocket/secure websocket)
72+
NATS_SERVER_URL_IN_CONTAINER=nats://the.url.to.nats # same as above
73+
NATS_CREDS_FILE=/path/to/backend.creds
74+
OPERATOR_CREDS_FILE=/path/to/operator.creds
75+
AGENT_NETWORKS='["your-network-name"]' # need to be changed
76+
ZMQ_BIND_INTERFACE="eth0" # interface you are planning to transmit data from on this agent.
77+
```
78+
79+
## Connecting agents and their resources
80+
81+
`AGENT_TAGS` and `AGENT_NETWORKS` matter for how the pipeline will be deployed.
82+
83+
Say you have Data Reader Operator and you want to always run it next to your microscope. You must do the following:
84+
85+
1. On your local agent, set `AGENT_TAGS='["a-unique-tag-name"]'.
86+
1. On your operator that you want to always run on the agent's machine, set the tag in the operator spec:
87+
88+
```json
89+
"tags": [
90+
{
91+
"value": "a-unique-tag-name",
92+
"description": "Required to run on agents with the tag a-unique-tag-name."
93+
}
94+
]
95+
```
96+
97+
1. Then, let's say this pipeline involves a processing step that is very heavy and needs gpus. Tag that operator with `gpu`, and it will be sent to an agent that also has the tag `gpu`.
98+
1. If the connection between these operators crosses a `AGENT_NETWORKS` boundary ONE TIME, it may not cross that boundary again. This is because we only allow OUTBOUND connections from Operator inputs, and thereby INBOUND connections to operator outputs. This is a bit of a quirk, and could be fixed by other means in the future.

docs/source/launch-agent.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Launch an agent
22

3-
The agent is the process that starts operator containers, coordinates their lifecycle, and talks to the platform over NATS. You need at least one running agent before operators can launch.
3+
The agent is the process that starts operator containers, coordinates their lifecycle, and talks to the rest of the platform over NATS. You need at least one running agent before operators can launch.
44

55
## Prerequisites
66

7-
Have a Python environment manager available (e.g., [`poetry`](https://python-poetry.org/docs/) or [`uv`](https://github.com/astral-sh/uv)).
7+
Have a Python environment manager available (e.g., [`uv`](https://github.com/astral-sh/uv)).
88

99
## Configure the environment
1010

@@ -21,10 +21,10 @@ cd backend/agent
2121
AGENT_NAME=SecretAgentMan # change to how you want it to display in the frontend
2222
```
2323

24-
- If you want to target specific resources, set tags:
24+
- If you want to run operators with specific tags on this agent, set your tags:
2525

2626
```bash
27-
AGENT_TAGS='["ncem-4dcamera","gpu"]'
27+
AGENT_TAGS='["ncem-4dcamera"]'
2828
```
2929

3030
## Install and run
@@ -41,12 +41,9 @@ or
4141
uv sync
4242
```
4343

44-
If an agent is running at NERSC, we will use `podman-hpc`:
44+
If an agent is running at NERSC, we will use `podman-hpc`. If using `uv`, it will attempt to use the python binary from the user account that ran this command first, which is normally stored in `~/.local/share/uv/python`. If you are sharing this agent between users, you can set the `UV_PYTHON_INSTALL_DIR` env var to a shared location.
4545

4646
```bash
47-
# note this will link the current user account's python (normally stored in ~/.local/share/uv/python)
48-
# if we need to share across accounts, you can set the `UV_PYTHON_INSTALL_DIR` env var to a shared location
49-
# prior to running the command below
5047
uv sync --extra hpc
5148
```
5249

@@ -63,3 +60,37 @@ or with `uv`:
6360
cd backend/agent
6461
uv run interactem-agent
6562
```
63+
64+
## Connecting an agent to a different NATS cluster
65+
66+
To connect into a different NATS cluster, we have to set the `.env` variables:
67+
68+
```bash
69+
NATS_SERVER_URL=nats://the.url.to.nats # could also be ws/wss (websocket/secure websocket)
70+
NATS_SERVER_URL_IN_CONTAINER=nats://the.url.to.nats # same as above
71+
NATS_CREDS_FILE=/path/to/backend.creds
72+
OPERATOR_CREDS_FILE=/path/to/operator.creds
73+
AGENT_NETWORKS='["your-network-name"]' # need to be changed
74+
ZMQ_BIND_INTERFACE="eth0" # interface you are planning to transmit data from on this agent.
75+
```
76+
77+
## Connecting agents and their resources
78+
79+
`AGENT_TAGS` and `AGENT_NETWORKS` matter for how the pipeline will be deployed.
80+
81+
Say you have Data Reader Operator and you want to always run it next to your microscope. You must do the following:
82+
83+
1. On your local agent, set `AGENT_TAGS='["a-unique-tag-name"]'.
84+
1. On your operator that you want to always run on the agent's machine, set the tag in the operator spec:
85+
86+
```json
87+
"tags": [
88+
{
89+
"value": "a-unique-tag-name",
90+
"description": "Required to run on agents with the tag a-unique-tag-name."
91+
}
92+
]
93+
```
94+
95+
1. Then, let's say this pipeline involves a processing step that is very heavy and needs gpus. Tag that operator with `gpu`, and it will be sent to an agent that also has the tag `gpu`.
96+
1. If the connection between these operators crosses a `AGENT_NETWORKS` boundary ONE TIME, it may not cross that boundary again. This is because we only allow OUTBOUND connections from Operator inputs, and thereby INBOUND connections to operator outputs. This is a bit of a quirk, and could be fixed by other means in the future.

0 commit comments

Comments
 (0)