-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
sagemaker-custom-kernel
module to use Pydantic (#106)
* chore: Refactor sagemaker-custom-kernel to use pydantic for inputs * update requirements.txt * add tags * fix tests * update changelog * fix mount_path parameter * fix unit tests
- Loading branch information
1 parent
323cf1a
commit c9f3ee7
Showing
10 changed files
with
161 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
aws-cdk-lib==2.135.0 | ||
constructs>=10.0.0,<11.0.0 | ||
cdk-nag==2.12.29 | ||
cdk-ecr-deployment==3.0.43 | ||
cdk-ecr-deployment==3.0.43 | ||
pydantic==2.7.2 | ||
pydantic-settings==2.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"""Defines the stack settings.""" | ||
|
||
from abc import ABC | ||
from typing import Dict, Optional | ||
|
||
from pydantic import Field, computed_field | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
|
||
class EnvBaseSettings(BaseSettings, ABC): | ||
"""Defines common configuration for settings.""" | ||
|
||
model_config = SettingsConfigDict( | ||
case_sensitive=False, | ||
env_nested_delimiter="__", | ||
protected_namespaces=(), | ||
extra="ignore", | ||
populate_by_name=True, | ||
) | ||
|
||
|
||
class ModuleSettings(EnvBaseSettings): | ||
"""Seedfarmer Parameters. | ||
These parameters are required for the module stack. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="SEEDFARMER_PARAMETER_") | ||
|
||
studio_domain_id: str | ||
studio_domain_name: str | ||
studio_execution_role_arn: str | ||
ecr_repo_name: str | ||
|
||
sagemaker_image_name: Optional[str] = Field(default=None) | ||
app_image_config_name: Optional[str] = Field(default=None) | ||
custom_kernel_name: Optional[str] = Field(default=None) | ||
|
||
kernel_user_uid: int = Field(default=1000) | ||
kernel_user_gid: int = Field(default=100) | ||
kernel_user_home_mount_path: str = Field(default="/home/sagemaker-user") | ||
|
||
tags: Optional[Dict[str, str]] = Field(default=None) | ||
|
||
|
||
class SeedFarmerSettings(EnvBaseSettings): | ||
"""Seedfarmer Settings. | ||
These parameters comes from seedfarmer by default. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="SEEDFARMER_") | ||
|
||
project_name: str = Field(default="") | ||
deployment_name: str = Field(default="") | ||
module_name: str = Field(default="") | ||
|
||
@computed_field # type: ignore | ||
@property | ||
def app_prefix(self) -> str: | ||
"""Application prefix.""" | ||
prefix = "-".join([self.project_name, self.deployment_name, self.module_name]) | ||
return prefix | ||
|
||
|
||
class CDKSettings(EnvBaseSettings): | ||
"""CDK Default Settings. | ||
These parameters comes from AWS CDK by default. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="CDK_DEFAULT_") | ||
|
||
account: str | ||
region: str | ||
|
||
|
||
class ApplicationSettings(EnvBaseSettings): | ||
"""Application settings.""" | ||
|
||
seedfarmer_settings: SeedFarmerSettings = Field(default_factory=SeedFarmerSettings) | ||
module_settings: ModuleSettings = Field(default_factory=ModuleSettings) | ||
cdk_settings: CDKSettings = Field(default_factory=CDKSettings) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters