Skip to content

Commit ece85e1

Browse files
authored
Improvement: adjust node config loading (#346)
* load node group config for orchestrator from env
1 parent 35df874 commit ece85e1

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ watch-validator:
9191

9292
watch-orchestrator:
9393
set -a; source ${ENV_FILE}; set +a; \
94-
cargo watch -w crates/orchestrator/src -x "run --bin orchestrator -- -r $$RPC_URL -k $$POOL_OWNER_PRIVATE_KEY -d 0 -p 8090 -i 10 -u http://localhost:8090 --compute-pool-id $$WORKER_COMPUTE_POOL_ID --bucket-name $$BUCKET_NAME -l $${LOG_LEVEL:-info} --hourly-s3-upload-limit $${HOURLY_S3_LIMIT:-3} --node-group-configs '[{\"name\": \"test-config\", \"min_group_size\": 1, \"max_group_size\": 1, \"compute_requirements\": null}]'"
94+
cargo watch -w crates/orchestrator/src -x "run --bin orchestrator -- -r $$RPC_URL -k $$POOL_OWNER_PRIVATE_KEY -d 0 -p 8090 -i 10 -u http://localhost:8090 --compute-pool-id $$WORKER_COMPUTE_POOL_ID --bucket-name $$BUCKET_NAME -l $${LOG_LEVEL:-info} --hourly-s3-upload-limit $${HOURLY_S3_LIMIT:-3}"
9595

9696
build-worker:
9797
cargo build --release --bin worker

crates/orchestrator/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ $([ ! -z "$BUCKET_NAME" ] && echo "--bucket-name $BUCKET_NAME") \
4444
$([ ! -z "$LOG_LEVEL" ] && echo "--log-level $LOG_LEVEL") \
4545
$([ ! -z "$HOURLY_S3_UPLOAD_LIMIT" ] && echo "--hourly-s3-upload-limit $HOURLY_S3_UPLOAD_LIMIT") \
4646
$([ ! -z "$WEBHOOK_URLS" ] && echo "--webhook-urls $WEBHOOK_URLS") \
47-
$([ ! -z "$NODE_GROUP_CONFIGS" ] && echo "--node-group-configs $NODE_GROUP_CONFIGS") \
4847
"$@"' > /entrypoint.sh && \
4948
chmod +x /entrypoint.sh
5049

crates/orchestrator/src/main.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ struct Args {
111111
/// Webhook urls (comma-separated string)
112112
#[arg(long, default_value = "")]
113113
webhook_urls: Option<String>,
114-
115-
/// Node group configurations in JSON format
116-
#[arg(long)]
117-
node_group_configs: Option<String>,
118114
}
119115

120116
#[tokio::main]
@@ -195,11 +191,11 @@ async fn main() -> Result<()> {
195191
let mut status_update_plugins: Vec<Box<dyn StatusUpdatePlugin>> = vec![];
196192
let mut node_groups_plugin: Option<Arc<NodeGroupsPlugin>> = None;
197193

198-
// This config loading is pretty ugly atm and should be optimized
199-
// Issue: https://github.com/PrimeIntellect-ai/protocol/issues/336
200-
if let Some(configs_json) = args.node_group_configs {
194+
// Load node group configurations from environment variable
195+
if let Ok(configs_json) = std::env::var("NODE_GROUP_CONFIGS") {
201196
match serde_json::from_str::<Vec<NodeGroupConfiguration>>(&configs_json) {
202197
Ok(configs) if !configs.is_empty() => {
198+
println!("configs for node groups: {:?}", configs);
203199
let group_plugin =
204200
NodeGroupsPlugin::new(configs, store.clone(), group_store_context);
205201
let status_group_plugin = group_plugin.clone();
@@ -209,10 +205,15 @@ async fn main() -> Result<()> {
209205
status_update_plugins.push(Box::new(status_group_plugin));
210206
}
211207
Ok(_) => {
212-
info!("No node group configurations provided, skipping plugin setup");
208+
info!(
209+
"No node group configurations provided in environment, skipping plugin setup"
210+
);
213211
}
214212
Err(e) => {
215-
panic!("Failed to parse node group configurations: {}", e);
213+
error!(
214+
"Failed to parse node group configurations from environment: {}",
215+
e
216+
);
216217
}
217218
}
218219
}

deployment/k8s/orchestrator-chart/templates/orchestrator-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
value: "{{ .root.Values.env.WEBHOOK_URLS }}"
6868
{{- end }}
6969
{{- if .root.Values.env.NODE_GROUP_CONFIGS }}
70-
- name: NODE_GROUP_CONFIGS
71-
value: "{{ .root.Values.env.NODE_GROUP_CONFIGS }}"
70+
- name: NODE_GROUP_CONFIGS
71+
value: "{{ .root.Values.env.NODE_GROUP_CONFIGS | trim | quote }}"
7272
{{- end }}
7373
{{- end }}
7474

deployment/k8s/orchestrator-chart/values.example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
DISCOVERY_REFRESH_INTERVAL: "60"
1111
BUCKET_NAME: "your-bucket-name"
1212
LOG_LEVEL: "info"
13+
NODE_GROUP_CONFIGS: '[{\"name\": \"h100-config\", \"min_group_size\": 1, \"max_group_size\": 1, \"compute_requirements\": \"gpu:model=h100;gpu:count=8\"}, {\"name\": \"a100-config\", \"min_group_size\": 2, \"max_group_size\": 2, \"compute_requirements\": \"gpu:model=a100;gpu:count=8\"}]'
1314

1415
secrets:
1516
coordinatorKey: "your-coordinator-private-key"

0 commit comments

Comments
 (0)