Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace-settings-update-ag-2863 #2377

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 49 additions & 30 deletions libs/agno/agno/workspace/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
from typing import List, Optional

from pydantic import ValidationInfo, field_validator
from pydantic import Field, ValidationInfo, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict

from agno.api.schemas.workspace import WorkspaceSchema
Expand All @@ -18,21 +18,12 @@ class WorkspaceSettings(BaseSettings):
ws_root: Path
# Workspace git repo url
ws_repo: Optional[str] = None

# -*- Workspace Environments
dev_env: str = "dev"
dev_key: Optional[str] = None
stg_env: str = "stg"
stg_key: Optional[str] = None
prd_env: str = "prd"
prd_key: Optional[str] = None

# default env for `agno ws` commands
# default env for agno ws commands
default_env: Optional[str] = "dev"
# default infra for `agno ws` commands
# default infra for agno ws commands
default_infra: Optional[str] = None

# -*- Image Settings
# Image Settings
# Repository for images
image_repo: str = "agnohq"
# 'Name:tag' for the image
Expand All @@ -46,7 +37,19 @@ class WorkspaceSettings(BaseSettings):
# Force pull images in FROM
force_pull_images: bool = False

# -*- `ag` cli settings
# Development Settings
dev_env: str = "dev"
dev_key: Optional[str] = None

# Staging Settings
stg_env: str = "stg"
stg_key: Optional[str] = None

# Production Settings
prd_env: str = "prd"
prd_key: Optional[str] = None

# ag cli settings
# Set to True if Agno should continue creating
# resources after a resource creation has failed
continue_on_create_failure: bool = False
Expand All @@ -58,21 +61,27 @@ class WorkspaceSettings(BaseSettings):
# resources after a resource patch has failed
continue_on_patch_failure: bool = False

# -*- AWS settings
# AWS settings
# Region for AWS resources
aws_region: Optional[str] = None
# Profile for AWS resources
aws_profile: Optional[str] = None
# Availability Zones for AWS resources
# AWS Subnet Ids
aws_subnet_ids: List[str] = Field(default_factory=list)
# Public subnets. 1 in each AZ.
aws_public_subnets: List[str] = Field(default_factory=list)
# Private subnets. 1 in each AZ.
aws_private_subnets: List[str] = Field(default_factory=list)
Comment on lines +71 to +74
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the public/private subnets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user could still leverage them in their app right?

# AWS Availability Zone
aws_az1: Optional[str] = None
aws_az2: Optional[str] = None
aws_az3: Optional[str] = None
# Subnets for AWS resources
aws_subnet_ids: Optional[List[str]] = None
# Security Groups for AWS resources
aws_security_group_ids: Optional[List[str]] = None
aws_az4: Optional[str] = None
aws_az5: Optional[str] = None
# Security Group Ids
aws_security_group_ids: List[str] = Field(default_factory=list)

# -*- Other Settings
# Other Settings
# Use cached resource if available, i.e. skip resource creation if the resource already exists
use_cache: bool = True
# WorkspaceSchema provided by the api
Expand All @@ -87,13 +96,13 @@ def set_dev_key(cls, dev_key, info: ValidationInfo):

ws_name = info.data.get("ws_name")
if ws_name is None:
raise ValueError("ws_name invalid")
raise ValueError("ws_name is None: Please set a valid value")

dev_env = info.data.get("dev_env")
if dev_env is None:
raise ValueError("dev_env invalid")
raise ValueError("dev_env is None: Please set a valid value")

return f"{ws_name}-{dev_env}"
return f"{dev_env}-{ws_name}"

@field_validator("stg_key", mode="before")
def set_stg_key(cls, stg_key, info: ValidationInfo):
Expand All @@ -102,13 +111,13 @@ def set_stg_key(cls, stg_key, info: ValidationInfo):

ws_name = info.data.get("ws_name")
if ws_name is None:
raise ValueError("ws_name invalid")
raise ValueError("ws_name is None: Please set a valid value")

stg_env = info.data.get("stg_env")
if stg_env is None:
raise ValueError("stg_env invalid")
raise ValueError("stg_env is None: Please set a valid value")

return f"{ws_name}-{stg_env}"
return f"{stg_env}-{ws_name}"

@field_validator("prd_key", mode="before")
def set_prd_key(cls, prd_key, info: ValidationInfo):
Expand All @@ -117,10 +126,20 @@ def set_prd_key(cls, prd_key, info: ValidationInfo):

ws_name = info.data.get("ws_name")
if ws_name is None:
raise ValueError("ws_name invalid")
raise ValueError("ws_name is None: Please set a valid value")

prd_env = info.data.get("prd_env")
if prd_env is None:
raise ValueError("prd_env invalid")
raise ValueError("prd_env is None: Please set a valid value")

return f"{prd_env}-{ws_name}"

@field_validator("aws_subnet_ids", mode="before")
def set_subnet_ids(cls, aws_subnet_ids, info: ValidationInfo):
if aws_subnet_ids is not None:
return aws_subnet_ids

aws_public_subnets = info.data.get("aws_public_subnets", [])
aws_private_subnets = info.data.get("aws_private_subnets", [])

return f"{ws_name}-{prd_env}"
return aws_public_subnets + aws_private_subnets