Skip to content

Commit 4df712a

Browse files
authored
Merge pull request #529 from NERSC/operator-env-passthru
pass extra env vars through to operators
2 parents 3d055ff + 8243b56 commit 4df712a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

backend/agent/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ZMQ_BIND_INTERFACE="lo"
1111
AGENT_NETWORKS='["perlmutter"]'
1212
AGENT_NAME="SecretAgentMan"
1313
NATS_STREAM_STORAGE_TYPE=file
14+
OPERATOR_EXTRA_ENV='{"CUDA_VISIBLE_DEVICES":"0","MY_FLAG":"enabled"}'
1415

1516
# Vector log aggregation
1617
VECTOR_AGGREGATOR_ADDR=host.containers.internal:6000

backend/agent/interactem/agent/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def log_hook(details: stamina.instrumentation.RetryDetails) -> None:
9393

9494
set_on_retry_hooks([log_hook])
9595

96-
GLOBAL_ENV = {k: str(v) for k, v in cfg.model_dump().items()}
96+
GLOBAL_ENV = {
97+
k: str(v) for k, v in cfg.model_dump(exclude={"OPERATOR_EXTRA_ENV"}).items()
98+
}
99+
GLOBAL_ENV.update(cfg.OPERATOR_EXTRA_ENV)
97100
GLOBAL_ENV["NATS_SERVER_URL"] = GLOBAL_ENV["NATS_SERVER_URL_IN_CONTAINER"]
98101

99102
OPERATOR_CREDS_TARGET = "/operator.creds"

backend/agent/interactem/agent/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Settings(BaseSettings):
4646
VECTOR_AGGREGATOR_ADDR: str | None = None
4747
LOG_DIR: Path = Path("~/.interactem/logs").expanduser().resolve()
4848
VECTOR_CONFIG_PATH: Path | None = None
49+
OPERATOR_EXTRA_ENV: dict[str, str] = Field(default_factory=dict)
4950

5051
@model_validator(mode="after")
5152
def ensure_operator_creds_file(self) -> "Settings":

0 commit comments

Comments
 (0)