-
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.
feat: add SageMaker model package promote modules (#61)
* Add model pkg group event module * Refactoring * Add sm model event bus module * Refactoring * Add sm model pkg promote module * Fix linging * Fix linting * Upd changelog * Fix typos * Fix linting problems * Fix format * Move event bus module to another location * Rename event bus module * Fix event bus module location * Upd readme with new modules * Fix module path --------- Co-authored-by: kukushking <[email protected]>
- Loading branch information
1 parent
b474d12
commit 9959455
Showing
59 changed files
with
2,740 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: event-bus | ||
path: modules/examples/events/event-bus | ||
targetAccount: tooling | ||
parameters: | ||
- name: event_bus_name | ||
value: mlops-bus | ||
- name: source_accounts | ||
value: '["123123123123"]' # Accounts that must have permissions to put events (source accounts) | ||
- name: tags | ||
value: '{"test": "test"}' |
33 changes: 33 additions & 0 deletions
33
examples/manifests/sagemaker-model-package-group-modules.yaml
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,33 @@ | ||
name: source-model-package-group | ||
path: modules/sagemaker/sagemaker-model-package-group | ||
targetAccount: primary | ||
parameters: | ||
- name: model_package_group_name | ||
value: mlops-test-model-group-source | ||
- name: target_event_bus_arn | ||
valueFrom: | ||
moduleMetadata: | ||
group: events | ||
name: event-bus | ||
key: EventBusArn | ||
- name: target_account_ids | ||
value: '["444333222555"]' # Accounts that must have read-only permissions on the model pkg group | ||
- name: sagemaker_project_id | ||
value: 123123 | ||
- name: sagemaker_project_name | ||
value: test | ||
--- | ||
name: target-model-package-group | ||
path: modules/sagemaker/sagemaker-model-package-group | ||
targetAccount: tooling | ||
parameters: | ||
- name: model_package_group_name | ||
value: mlops-test-model-group-tooling | ||
- name: model_package_group_description | ||
value: Test model package group module - Target | ||
- name: target_account_ids | ||
value: '["111222333444"]' # Accounts that must have read-only permissions on the model pkg group | ||
- name: sagemaker_project_id | ||
value: 123123 | ||
- name: sagemaker_project_name | ||
value: test |
24 changes: 24 additions & 0 deletions
24
examples/manifests/sagemaker-model-package-promote-pipeline-modules.yaml
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,24 @@ | ||
name: rappi-b2 | ||
path: modules/sagemaker/sagemaker-model-package-promote-pipeline | ||
targetAccount: tooling | ||
parameters: | ||
- name: source_model_package_group_arn | ||
valueFrom: | ||
moduleMetadata: | ||
group: registry | ||
name: source-model-package-group | ||
key: SagemakerModelPackageGroupArn | ||
- name: target_bucket_name | ||
value: my-bucket-name | ||
- name: event_bus_name | ||
valueFrom: | ||
moduleMetadata: | ||
group: events | ||
name: event-bus | ||
key: EventBusName | ||
- name: target_model_package_group_name | ||
valueFrom: | ||
moduleMetadata: | ||
group: registry | ||
name: target-model-package-group | ||
key: SagemakerModelPackageGroupName |
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,51 @@ | ||
# Event Bus | ||
|
||
## Description | ||
|
||
This module creates an Amazon EventBridge Bus for cross-account events. | ||
|
||
### Architecture | ||
|
||
![Event Bus Architecture](docs/_static/architecture.drawio.png "Event Bus Architecture") | ||
|
||
## Inputs/Outputs | ||
|
||
### Input Paramenters | ||
|
||
#### Required | ||
|
||
- `event_bus_name`: EventBridge Bus name. | ||
|
||
#### Optional | ||
|
||
- `source_accounts`: A list of account ids which shall have write access to the event bridge bus. Defaults None. | ||
- `tags`: A dictionary of tags. Defaults None. | ||
|
||
### Sample manifest declaration | ||
|
||
```yaml | ||
name: event-bus | ||
path: modules/examples/events/event-bus | ||
targetAccount: primary | ||
parameters: | ||
- name: event_bus_name | ||
value: mlops-bus | ||
- name: source_accounts | ||
value: '["111222333444", "555666777888"]' | ||
- name: tags | ||
value: '{"key": "value"}' | ||
``` | ||
### Module Metadata Outputs | ||
- `EventBusArn`: the EventBridge bus ARN. | ||
- `EventBusName`: the EventBridge bus name. | ||
|
||
#### Output Example | ||
|
||
```json | ||
{ | ||
"EventBusArn": "arn:aws:events:xx-xxxx-x:xxxxxxxxxx:event-bus/mlops-bus", | ||
"EventBusName": "mlops-bus", | ||
} | ||
``` |
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,26 @@ | ||
#!/usr/bin/env python3 | ||
"""Create a Event Bus Stack.""" | ||
|
||
import aws_cdk as cdk | ||
|
||
from event_bus.settings import ApplicationSettings | ||
from event_bus.stack import EventBusStack | ||
|
||
# Load application settings from env vars. | ||
app_settings = ApplicationSettings() | ||
|
||
env = cdk.Environment( | ||
account=app_settings.default.account, | ||
region=app_settings.default.region, | ||
) | ||
|
||
app = cdk.App() | ||
|
||
stack = EventBusStack( | ||
scope=app, | ||
construct_id=app_settings.settings.app_prefix, | ||
env=env, | ||
**app_settings.parameters.model_dump(), | ||
) | ||
|
||
app.synth() |
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,26 @@ | ||
publishGenericEnvVariables: true | ||
deploy: | ||
phases: | ||
install: | ||
commands: | ||
- env | ||
# Install whatever additional build libraries | ||
- npm install -g [email protected] | ||
- pip install -r requirements.txt | ||
build: | ||
commands: | ||
# execute the CDK | ||
- cdk deploy --require-approval never --progress events --app "python app.py" --outputs-file ./cdk-exports.json | ||
# Export metadata | ||
- seedfarmer metadata convert -f cdk-exports.json || true | ||
destroy: | ||
phases: | ||
install: | ||
commands: | ||
# Install whatever additional build libraries | ||
- npm install -g [email protected] | ||
- pip install -r requirements.txt | ||
build: | ||
commands: | ||
# execute the CDK | ||
- cdk destroy --force --app "python app.py" |
1 change: 1 addition & 0 deletions
1
modules/examples/events/event-bus/docs/_static/architecture.drawio
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 @@ | ||
<mxfile host="Electron" modified="2024-03-23T13:09:48.468Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.2.3 Chrome/102.0.5005.167 Electron/19.0.11 Safari/537.36" etag="0olYNljB-bfJTNhMpkqE" version="20.2.3" type="device"><diagram id="nOkpBZcZqbjnXywVXBLF" name="Page-1">7Vpbc9o4FP41PIbxHfKITUi3Tbtp2dlO9oVRbGHcCIvKMpf++pVsCWNJBHZC07CFZAbr+Ojio+9837Fxx43m61sCFrOPOIGo41jJuuMOO45j216ffXHLprZ4Pbc2pCRLhFNjGGc/oDBawlpmCSxajhRjRLNF2xjjPIcxbdkAIXjVdpti1J51AVKoGcYxQLr1a5bQWW3t+1ZjfwezdCZnti1xZg6kszAUM5Dg1Y7Jvem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VFw4qtkvf0jNj3uvw2toFcG5C2Xha7drd3rSPQO0FdvLaG9/Ok9zn6B7yL0J8Pn9LobwNJjiX+lNtXufjLLezlFvY3uIW1vYO3sHbPcC+1fWp1+lS19hU0l1LmdKWMoZLerqINR0uTkaNLnGep+GiIBn4Loa6OUM8A0FNIibGY6R0vJfrDl4uUXKTkDUvJgdLwv0nJ9hncq2iJMVdt56IlZ6wlh+5U9tLzuWjJ9fFa8umiJRct+W21xOn9ei3Rf1u7aMn/W0uuz0lL5HPeHSTCJIVyb/hvSTjFOUA3jTVkTJInW7g0PneYA6Haq2+Q0o3YcVBS3IZDPSdMtHditGcS8gn5wQSjgKRQ9N3/i4e+LQQiQBm9tmY1hbnqOiAEbHYchJo2I99zQ7PbrttmJFd9eeaAv2SwZovrFTQbvr2UF2DAP3cMOG8aA8pPf/Kds70YUP2D18BAcD4YePYB4BvFgJLXsuA4mgf8F2GANZsXAGv35jVK9+Zf</diagram></mxfile> |
Binary file added
BIN
+32.6 KB
modules/examples/events/event-bus/docs/_static/architecture.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
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,73 @@ | ||
"""Defines the stack settings.""" | ||
|
||
from abc import ABC | ||
from typing import Dict, List, Optional | ||
|
||
from pydantic import Field, computed_field | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
|
||
class CdkBaseSettings(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 SeedFarmerParameters(CdkBaseSettings): | ||
"""Seedfarmer Parameters. | ||
These parameters are required for the module stack. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="SEEDFARMER_PARAMETER_") | ||
|
||
event_bus_name: str | ||
|
||
source_accounts: Optional[List[str]] = Field(default=None) | ||
tags: Optional[Dict[str, str]] = Field(default=None) | ||
|
||
|
||
class SeedFarmerSettings(CdkBaseSettings): | ||
"""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 CdkDefaultSettings(CdkBaseSettings): | ||
"""CDK Default Settings. | ||
These parameters comes from AWS CDK by default. | ||
""" | ||
|
||
model_config = SettingsConfigDict(env_prefix="CDK_DEFAULT_") | ||
|
||
account: str | ||
region: str | ||
|
||
|
||
class ApplicationSettings(CdkBaseSettings): | ||
"""Application settings.""" | ||
|
||
settings: SeedFarmerSettings = Field(default_factory=SeedFarmerSettings) | ||
parameters: SeedFarmerParameters = Field(default_factory=SeedFarmerParameters) | ||
default: CdkDefaultSettings = Field(default_factory=CdkDefaultSettings) |
Oops, something went wrong.