Skip to content

Commit e4b39b5

Browse files
authored
feat: Adds helm config to Agent Environment (#125)
* feat: Adds helm config to Agent Environment * Lint
1 parent 94932ec commit e4b39b5

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

src/agentex/lib/cli/handlers/deploy_handlers.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import os
2-
import subprocess
32
import tempfile
4-
from pathlib import Path
3+
import subprocess
54
from typing import Any
5+
from pathlib import Path
66

77
import yaml
8-
from pydantic import BaseModel, Field
8+
from pydantic import Field, BaseModel
99
from rich.console import Console
1010

11-
from agentex.lib.cli.utils.exceptions import DeploymentError, HelmError
12-
from agentex.lib.sdk.config.environment_config import AgentEnvironmentConfig
13-
from agentex.lib.cli.utils.kubectl_utils import check_and_switch_cluster_context
14-
from agentex.lib.cli.utils.path_utils import calculate_docker_acp_module, PathResolutionError
11+
from agentex.lib.utils.logging import make_logger
12+
from agentex.lib.cli.utils.exceptions import HelmError, DeploymentError
13+
from agentex.lib.cli.utils.path_utils import PathResolutionError, calculate_docker_acp_module
1514
from agentex.lib.environment_variables import EnvVarKeys
15+
from agentex.lib.cli.utils.kubectl_utils import check_and_switch_cluster_context
1616
from agentex.lib.sdk.config.agent_config import AgentConfig
1717
from agentex.lib.sdk.config.agent_manifest import AgentManifest
18-
19-
from agentex.lib.utils.logging import make_logger
18+
from agentex.lib.sdk.config.environment_config import AgentEnvironmentConfig
2019

2120
logger = make_logger(__name__)
2221
console = Console()
@@ -46,23 +45,23 @@ def check_helm_installed() -> bool:
4645
return False
4746

4847

49-
def add_helm_repo() -> None:
48+
def add_helm_repo(helm_repository_name: str, helm_repository_url: str) -> None:
5049
"""Add the agentex helm repository if not already added"""
5150
try:
5251
# Check if repo already exists
5352
result = subprocess.run(
5453
["helm", "repo", "list"], capture_output=True, text=True, check=True
5554
)
5655

57-
if "scale-egp" not in result.stdout:
56+
if helm_repository_name not in result.stdout:
5857
console.print("Adding agentex helm repository...")
5958
subprocess.run(
6059
[
6160
"helm",
6261
"repo",
6362
"add",
64-
"scale-egp",
65-
"https://scale-egp-helm-charts-us-west-2.s3.amazonaws.com/charts",
63+
helm_repository_name,
64+
helm_repository_url,
6665
],
6766
check=True,
6867
)
@@ -265,7 +264,7 @@ def merge_deployment_configs(
265264
if not helm_overrides_command:
266265
add_acp_command_to_helm_values(helm_values, manifest, manifest_path)
267266

268-
print("Deploying with the following helm values: ", helm_values)
267+
console.print("Deploying with the following helm values: ", helm_values)
269268
return helm_values
270269

271270

@@ -318,8 +317,14 @@ def deploy_agent(
318317
else:
319318
console.print(f"[yellow]⚠[/yellow] No environments.yaml found, skipping environment-specific config")
320319

320+
if agent_env_config:
321+
helm_repository_name = agent_env_config.helm_repository_name
322+
helm_repository_url = agent_env_config.helm_repository_url
323+
else:
324+
helm_repository_name = "scale-egp"
325+
helm_repository_url = "https://scale-egp-helm-charts-us-west-2.s3.amazonaws.com/charts"
321326
# Add helm repository/update
322-
add_helm_repo()
327+
add_helm_repo(helm_repository_name, helm_repository_url)
323328

324329
# Merge configurations
325330
helm_values = merge_deployment_configs(manifest, agent_env_config, deploy_overrides, manifest_path)
@@ -349,7 +354,7 @@ def deploy_agent(
349354
"helm",
350355
"upgrade",
351356
release_name,
352-
"scale-egp/agentex-agent",
357+
f"{helm_repository_name}/agentex-agent",
353358
"--version",
354359
AGENTEX_AGENTS_HELM_CHART_VERSION,
355360
"-f",
@@ -371,7 +376,7 @@ def deploy_agent(
371376
"helm",
372377
"install",
373378
release_name,
374-
"scale-egp/agentex-agent",
379+
f"{helm_repository_name}/agentex-agent",
375380
"--version",
376381
AGENTEX_AGENTS_HELM_CHART_VERSION,
377382
"-f",

src/agentex/lib/sdk/config/environment_config.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
from __future__ import annotations
99

10-
from pathlib import Path
1110
from typing import Any, Dict, override
11+
from pathlib import Path
1212

1313
import yaml
14-
from pydantic import BaseModel, Field, field_validator
14+
from pydantic import Field, BaseModel, field_validator
1515

1616
from agentex.lib.utils.model_utils import BaseModel as UtilsBaseModel
1717

@@ -73,6 +73,14 @@ class AgentEnvironmentConfig(BaseModel):
7373
...,
7474
description="Authentication and authorization configuration"
7575
)
76+
helm_repository_name: str = Field(
77+
default="scale-egp",
78+
description="Helm repository name for the environment"
79+
)
80+
helm_repository_url: str = Field(
81+
default="https://scale-egp-helm-charts-us-west-2.s3.amazonaws.com/charts",
82+
description="Helm repository url for the environment"
83+
)
7684
helm_overrides: Dict[str, Any] = Field(
7785
default_factory=dict,
7886
description="Helm chart value overrides for environment-specific tuning"

0 commit comments

Comments
 (0)