Skip to content

Commit

Permalink
feat(agents): add env var overrides for agent configs (#189)
Browse files Browse the repository at this point in the history
* Update macros to provide config overrides via environment vars

* Add environment var overrides

* Add empty environment var override bblocks

* Add environment var override hook to agent ctor

* Add env fixture for agent tests

* Add environment var override test

* Fix formatting

* Add environment var override test

* Fix linting error

* Add settings for tests

* Fix linting errors

* Update CHANGELOG

* Pull in changes from main

* Fix formatting

* Clean up unused imports

* Add missing env var to fix broken test

* Fix formatting

* Remove unused enabled flag from agents project-wide

* Update CHANGELOG

* Add note about the use of $self_ in macros

* Upate CHANGELOGs

* Update CHANGELOGs
  • Loading branch information
lattejed authored Jun 8, 2022
1 parent 616e7ee commit a374222
Show file tree
Hide file tree
Showing 24 changed files with 385 additions and 197 deletions.
4 changes: 4 additions & 0 deletions agents/kathy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### 1.0.0

- bumps version for first release
Expand Down
43 changes: 42 additions & 1 deletion agents/kathy/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,48 @@ mod test {
use super::*;
use nomad_base::{get_remotes_from_env, NomadAgent};
use nomad_test::test_utils;
use nomad_xyz_configuration::AgentSecrets;
use nomad_xyz_configuration::{agent::kathy::ChatGenConfig, AgentSecrets};

#[test]
#[serial_test::serial]
fn it_overrides_settings_from_env() {
test_utils::run_test_with_env_sync("../../fixtures/env.test-agents", move || {
let run_env = dotenv::var("RUN_ENV").unwrap();
let agent_home = dotenv::var("AGENT_HOME_NAME").unwrap();

let settings = KathySettings::new().unwrap();

let config = nomad_xyz_configuration::get_builtin(&run_env).unwrap();

let remotes = get_remotes_from_env!(agent_home, config);
let mut networks = remotes.clone();
networks.insert(agent_home.clone());

let secrets = AgentSecrets::from_env(&networks).unwrap();

settings
.base
.validate_against_config_and_secrets(
crate::Kathy::AGENT_NAME,
&agent_home,
&remotes,
config,
&secrets,
)
.unwrap();
assert_eq!(
settings.agent.chat,
ChatGenConfig::OrderedList {
messages: vec![
"Chat message 1".to_string(),
"Chat message 2".to_string(),
"Chat message 3".to_string(),
]
}
);
assert_eq!(settings.agent.interval, 999);
});
}

async fn test_build_from_env_file(path: &str) {
test_utils::run_test_with_env(path, || async move {
Expand Down
3 changes: 3 additions & 0 deletions agents/processor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- prevent processor from retrying messages it has previously attempted to
process
- improve prove/process tracing
- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### 1.0.0

Expand Down
4 changes: 4 additions & 0 deletions agents/relayer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### 1.0.0

- bumps version for first release
Expand Down
4 changes: 4 additions & 0 deletions agents/updater/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### 1.0.0

- bumps version for first release
Expand Down
4 changes: 4 additions & 0 deletions agents/watcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### 1.0.0

- bumps version for first release
Expand Down
4 changes: 4 additions & 0 deletions configuration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

- add environment variable overrides for agent configuration
- add tests for agent environment variable overrides
- remove `enabled` flag from agents project-wide

### v0.1.0-rc.25

- adds transaction submitters type to replace transaction signers
Expand Down
75 changes: 25 additions & 50 deletions configuration/configs/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,10 @@
"level": "info"
},
"updater": {
"interval": 5,
"enabled": true
"interval": 5
},
"relayer": {
"interval": 10,
"enabled": true
"interval": 10
},
"processor": {
"allowed": null,
Expand All @@ -552,19 +550,16 @@
"bucket": "nomadxyz-development-proofs",
"region": "us-west-2"
},
"interval": 5,
"enabled": true
"interval": 5
},
"watcher": {
"interval": 5,
"enabled": true
"interval": 5
},
"kathy": {
"chat": {
"type": "default"
},
"interval": 500,
"enabled": true
"interval": 500
}
},
"goerli": {
Expand All @@ -576,12 +571,10 @@
"level": "info"
},
"updater": {
"interval": 5,
"enabled": true
"interval": 5
},
"relayer": {
"interval": 10,
"enabled": true
"interval": 10
},
"processor": {
"allowed": null,
Expand All @@ -596,19 +589,16 @@
"bucket": "nomadxyz-development-proofs",
"region": "us-west-2"
},
"interval": 5,
"enabled": true
"interval": 5
},
"watcher": {
"interval": 5,
"enabled": true
"interval": 5
},
"kathy": {
"chat": {
"type": "default"
},
"interval": 500,
"enabled": true
"interval": 500
}
},
"evmostestnet": {
Expand All @@ -620,12 +610,10 @@
"level": "info"
},
"updater": {
"interval": 5,
"enabled": true
"interval": 5
},
"relayer": {
"interval": 10,
"enabled": true
"interval": 10
},
"processor": {
"allowed": null,
Expand All @@ -640,19 +628,16 @@
"bucket": "nomadxyz-development-proofs",
"region": "us-west-2"
},
"interval": 5,
"enabled": true
"interval": 5
},
"watcher": {
"interval": 5,
"enabled": true
"interval": 5
},
"kathy": {
"chat": {
"type": "default"
},
"interval": 500,
"enabled": true
"interval": 500
}
},
"kovan": {
Expand All @@ -664,12 +649,10 @@
"level": "info"
},
"updater": {
"interval": 5,
"enabled": true
"interval": 5
},
"relayer": {
"interval": 10,
"enabled": true
"interval": 10
},
"processor": {
"allowed": null,
Expand All @@ -684,19 +667,16 @@
"bucket": "nomadxyz-development-proofs",
"region": "us-west-2"
},
"interval": 5,
"enabled": true
"interval": 5
},
"watcher": {
"interval": 5,
"enabled": true
"interval": 5
},
"kathy": {
"chat": {
"type": "default"
},
"interval": 500,
"enabled": true
"interval": 500
}
},
"neontestnet": {
Expand All @@ -708,12 +688,10 @@
"level": "info"
},
"updater": {
"interval": 5,
"enabled": true
"interval": 5
},
"relayer": {
"interval": 10,
"enabled": true
"interval": 10
},
"processor": {
"allowed": null,
Expand All @@ -728,19 +706,16 @@
"bucket": "nomadxyz-development-proofs",
"region": "us-west-2"
},
"interval": 5,
"enabled": true
"interval": 5
},
"watcher": {
"interval": 5,
"enabled": true
"interval": 5
},
"kathy": {
"chat": {
"type": "default"
},
"interval": 500,
"enabled": true
"interval": 500
}
}
},
Expand Down
Loading

0 comments on commit a374222

Please sign in to comment.