├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── mlops-multi-account-cdk
├── README.md
├── __init__.py
├── diagrams
│ ├── BatchInferencePipeline.png
│ ├── DAG.png
│ ├── InitialPhase.png
│ ├── MaturityLevel.png
│ ├── ReliablePhase1-Latest-Version.png
│ ├── ReliablePhase2-Latest-Version.png
│ ├── RepeatablePhase.png
│ ├── ScalePhase-Latest-Version.png
│ ├── ScalePhase-Studio-Latest-Version.png
│ ├── TrainingPipeline.png
│ ├── challenges.png
│ ├── datastructure.png
│ ├── deploymentcicd.png
│ ├── integrationwithdatalake.png
│ └── modelbuildcicd.png
├── mlops-infra
│ ├── .githooks
│ │ └── pre-commit
│ ├── .gitignore
│ ├── .pre-commit-config.yaml
│ ├── ADVANCED_TOPICS.md
│ ├── DEVELOPER_GUIDE.md
│ ├── LICENSE.txt
│ ├── Makefile
│ ├── README.md
│ ├── add_comments_to_empty_files.sh
│ ├── app.py
│ ├── cdk.json
│ ├── diagrams
│ │ ├── CodeCommit_repositories_in_governance.png
│ │ ├── CodePipelines_in_governance.png
│ │ ├── MLOPs Foundation Architecture-mlops infrastructure architecture.jpg
│ │ ├── MLOPs Foundation Architecture-mlops secure networking.jpg
│ │ └── MLOPs Foundation Architecture-sagemaker studio stack.jpg
│ ├── functions
│ │ └── sm_studio
│ │ │ └── enable_sm_projects
│ │ │ ├── index.py
│ │ │ └── requirements.txt
│ ├── mlops_infra
│ │ ├── __init__.py
│ │ ├── cdk_helper_scripts
│ │ │ └── zip-image
│ │ │ │ └── Dockerfile
│ │ ├── codecommit_stack.py
│ │ ├── config
│ │ │ ├── accounts.json
│ │ │ ├── config_mux.py
│ │ │ ├── constants.py
│ │ │ └── dev
│ │ │ │ ├── constants.py
│ │ │ │ ├── data_scientists.yml
│ │ │ │ └── lead_data_scientists.yml
│ │ ├── constructs
│ │ │ ├── networking.py
│ │ │ └── sm_roles.py
│ │ ├── networking_stack.py
│ │ ├── pipeline_stack.py
│ │ └── sagemaker_studio_stack.py
│ ├── requirements-dev.txt
│ └── requirements.txt
├── mlops-sm-project-template
│ ├── .githooks
│ │ └── pre-commit
│ ├── .gitignore
│ ├── ADVANCED_TOPICS.md
│ ├── DEVELOPER_GUIDE.md
│ ├── LICENSE.txt
│ ├── Makefile
│ ├── README.md
│ ├── add_comments_to_empty_files.sh
│ ├── app.py
│ ├── cdk.json
│ ├── diagrams
│ │ ├── MLOPs Foundation Architecture-mlops project cicd architecture.jpg
│ │ ├── MLOPs Foundation Architecture-sagemaker project architecture.jpg
│ │ ├── SageMaker_organization_templates.png
│ │ ├── Service_catalog_portfolio.png
│ │ ├── building.png
│ │ ├── deployment.png
│ │ └── mlops-sm-project-general-architecture.jpg
│ ├── mlops_sm_project_template
│ │ ├── __init__.py
│ │ ├── cdk_helper_scripts
│ │ │ ├── __init__.py
│ │ │ ├── seed_code_helper.py
│ │ │ └── zip-image
│ │ │ │ └── Dockerfile
│ │ ├── codecommit_stack.py
│ │ ├── config
│ │ │ ├── accounts.json
│ │ │ └── constants.py
│ │ ├── pipeline_stack.py
│ │ ├── service_catalog_stack.py
│ │ └── templates
│ │ │ ├── __init__.py
│ │ │ ├── common_seed_code
│ │ │ ├── abalone_build_app
│ │ │ │ ├── .githooks
│ │ │ │ │ └── pre-commit
│ │ │ │ ├── .pre-commit-config.yaml
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── ml_pipelines
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── __version__.py
│ │ │ │ │ ├── _utils.py
│ │ │ │ │ ├── get_pipeline_definition.py
│ │ │ │ │ ├── run_pipeline.py
│ │ │ │ │ └── training
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── _utils.py
│ │ │ │ │ │ └── pipeline.py
│ │ │ │ ├── notebooks
│ │ │ │ │ ├── README.md
│ │ │ │ │ └── sm_pipelines_runbook.ipynb
│ │ │ │ ├── setup.cfg
│ │ │ │ ├── setup.py
│ │ │ │ └── source_scripts
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── evaluate
│ │ │ │ │ └── evaluate_xgboost
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── main.py
│ │ │ │ │ │ └── requirements.txt
│ │ │ │ │ ├── helpers
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── logger.py
│ │ │ │ │ ├── requirements.txt
│ │ │ │ │ ├── s3_helper.py
│ │ │ │ │ └── test
│ │ │ │ │ │ └── test_a.py
│ │ │ │ │ ├── preprocessing
│ │ │ │ │ └── prepare_abalone_data
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── main.py
│ │ │ │ │ │ └── requirements.txt
│ │ │ │ │ └── training
│ │ │ │ │ └── xgboost
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __main__.py
│ │ │ │ │ ├── requirements.txt
│ │ │ │ │ └── test
│ │ │ │ │ └── test_a.py
│ │ │ └── endpoint_deploy_app
│ │ │ │ ├── .githooks
│ │ │ │ └── pre-commit
│ │ │ │ ├── .pre-commit-config.yaml
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── app.py
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── cdk.json
│ │ │ │ ├── config
│ │ │ │ ├── cfn_nag_ignore.yml
│ │ │ │ ├── config_mux.py
│ │ │ │ ├── constants.py
│ │ │ │ ├── dev
│ │ │ │ │ ├── constants.py
│ │ │ │ │ └── endpoint-config.yml
│ │ │ │ ├── prod
│ │ │ │ │ ├── constants.py
│ │ │ │ │ └── endpoint-config.yml
│ │ │ │ └── staging
│ │ │ │ │ ├── constants.py
│ │ │ │ │ └── endpoint-config.yml
│ │ │ │ ├── deploy_endpoint
│ │ │ │ ├── __init__.py
│ │ │ │ ├── deploy_endpoint_stack.py
│ │ │ │ └── get_approved_package.py
│ │ │ │ ├── requirements-dev.txt
│ │ │ │ ├── requirements.txt
│ │ │ │ ├── source.bat
│ │ │ │ └── tests
│ │ │ │ ├── README.md
│ │ │ │ ├── integration_tests
│ │ │ │ ├── __init__.py
│ │ │ │ ├── buildspec.yml
│ │ │ │ └── endpoint_test.py
│ │ │ │ └── unittests
│ │ │ │ ├── __init__.py
│ │ │ │ └── test_deploy_app_stack.py
│ │ │ ├── constructs
│ │ │ ├── __init__.py
│ │ │ ├── build_pipeline.py
│ │ │ ├── conf
│ │ │ │ ├── cfn_nag_ignore.yml
│ │ │ │ └── default_deploy_buildspec.yml
│ │ │ ├── deploy_pipeline.py
│ │ │ ├── iot_deploy_pipeline.py
│ │ │ └── ssm.py
│ │ │ ├── finetune_deploy_llm_product
│ │ │ ├── __init__.py
│ │ │ ├── project.py
│ │ │ └── seed_code
│ │ │ │ └── build_app
│ │ │ │ ├── .pre-commit-config.yaml
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── ml_pipelines
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __version__.py
│ │ │ │ ├── _utils.py
│ │ │ │ ├── get_pipeline_definition.py
│ │ │ │ ├── run_pipeline.py
│ │ │ │ └── text2sql_finetune
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── pipeline.py
│ │ │ │ ├── notebooks
│ │ │ │ ├── README.md
│ │ │ │ └── sm_pipelines_runbook.ipynb
│ │ │ │ ├── setup.cfg
│ │ │ │ ├── setup.py
│ │ │ │ └── source_scripts
│ │ │ │ ├── data_processing.py
│ │ │ │ ├── evaluate.py
│ │ │ │ ├── preprocess.py
│ │ │ │ ├── requirements.txt
│ │ │ │ └── train.py
│ │ │ ├── train_deploy_basic_product
│ │ │ ├── __init__.py
│ │ │ └── project.py
│ │ │ ├── train_deploy_batch_inference_product
│ │ │ ├── __init__.py
│ │ │ ├── project.py
│ │ │ └── seed_code
│ │ │ │ ├── build_app
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── get_approved_package.py
│ │ │ │ ├── get_model_location.py
│ │ │ │ ├── ml_pipelines
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── __version__.py
│ │ │ │ │ ├── _utils.py
│ │ │ │ │ ├── get_pipeline_definition.py
│ │ │ │ │ ├── inference
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── _utils.py
│ │ │ │ │ │ └── pipeline.py
│ │ │ │ │ ├── run_pipeline.py
│ │ │ │ │ └── training
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── _utils.py
│ │ │ │ │ │ └── pipeline.py
│ │ │ │ ├── notebooks
│ │ │ │ │ ├── README.md
│ │ │ │ │ └── sm_pipelines_runbook.ipynb
│ │ │ │ ├── setup.py
│ │ │ │ └── source_scripts
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── evaluate
│ │ │ │ │ └── evaluate_xgboost
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── main.py
│ │ │ │ │ │ └── requirements.txt
│ │ │ │ │ ├── helpers
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── logger.py
│ │ │ │ │ ├── requirements.txt
│ │ │ │ │ ├── s3_helper.py
│ │ │ │ │ └── test
│ │ │ │ │ │ └── test_a.py
│ │ │ │ │ ├── preprocessing
│ │ │ │ │ └── prepare_abalone_data
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── main.py
│ │ │ │ │ │ └── requirements.txt
│ │ │ │ │ └── training
│ │ │ │ │ └── xgboost
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __main__.py
│ │ │ │ │ ├── requirements.txt
│ │ │ │ │ └── test
│ │ │ │ │ └── test_a.py
│ │ │ │ └── deploy_app
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── app.py
│ │ │ │ ├── backend_stack.py
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── cdk.json
│ │ │ │ ├── config
│ │ │ │ ├── config_mux.py
│ │ │ │ ├── constants.py
│ │ │ │ ├── dev
│ │ │ │ │ └── constants.py
│ │ │ │ ├── preprod
│ │ │ │ │ └── constants.py
│ │ │ │ └── prod
│ │ │ │ │ └── constants.py
│ │ │ │ ├── deploy_sagemaker_pipeline
│ │ │ │ ├── __init__.py
│ │ │ │ └── deploy_sm_pipeline.py
│ │ │ │ ├── requirements-dev.txt
│ │ │ │ ├── requirements.txt
│ │ │ │ ├── source.bat
│ │ │ │ └── tests
│ │ │ │ ├── README.md
│ │ │ │ ├── integration_tests
│ │ │ │ ├── __init__.py
│ │ │ │ ├── buildspec.yml
│ │ │ │ └── endpoint_test.py
│ │ │ │ └── unittests
│ │ │ │ ├── __init__.py
│ │ │ │ └── test_deploy_app_stack.py
│ │ │ ├── train_deploy_byoc_product
│ │ │ ├── __init__.py
│ │ │ ├── project.py
│ │ │ └── seed_code
│ │ │ │ └── build_app
│ │ │ │ ├── .githooks
│ │ │ │ └── pre-commit
│ │ │ │ ├── .pre-commit-config.yaml
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── ml_pipelines
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __version__.py
│ │ │ │ ├── _utils.py
│ │ │ │ ├── get_pipeline_definition.py
│ │ │ │ ├── run_pipeline.py
│ │ │ │ └── training
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── _utils.py
│ │ │ │ │ └── pipeline.py
│ │ │ │ ├── notebooks
│ │ │ │ └── README.md
│ │ │ │ ├── setup.cfg
│ │ │ │ ├── setup.py
│ │ │ │ └── source_scripts
│ │ │ │ ├── Dockerfile
│ │ │ │ ├── README.md
│ │ │ │ ├── docker-build.sh
│ │ │ │ ├── docker_helpers
│ │ │ │ ├── entrypoint.R
│ │ │ │ └── run.sh
│ │ │ │ ├── evaluate
│ │ │ │ ├── README.md
│ │ │ │ └── evaluation.R
│ │ │ │ ├── helpers
│ │ │ │ ├── README.md
│ │ │ │ ├── logger.py
│ │ │ │ ├── requirements.txt
│ │ │ │ ├── s3_helper.py
│ │ │ │ └── test
│ │ │ │ │ └── test_a.py
│ │ │ │ ├── preprocessing
│ │ │ │ ├── README.md
│ │ │ │ └── prepare_abalone_data
│ │ │ │ │ └── preprocessing.R
│ │ │ │ └── training
│ │ │ │ ├── README.md
│ │ │ │ ├── deploy.R
│ │ │ │ ├── endpoints.R
│ │ │ │ ├── test
│ │ │ │ └── test_a.py
│ │ │ │ └── train.R
│ │ │ ├── train_deploy_genai_cv_product
│ │ │ ├── __init__.py
│ │ │ ├── project.py
│ │ │ └── seed_code
│ │ │ │ └── build_app
│ │ │ │ ├── .pre-commit-config.yaml
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.md
│ │ │ │ ├── buildspec.yml
│ │ │ │ ├── ml_pipelines
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── __version__.py
│ │ │ │ ├── _utils.py
│ │ │ │ ├── get_pipeline_definition.py
│ │ │ │ ├── run_pipeline.py
│ │ │ │ └── training
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── pipeline.py
│ │ │ │ ├── notebooks
│ │ │ │ ├── README.md
│ │ │ │ └── sm_pipelines_runbook.ipynb
│ │ │ │ ├── setup.cfg
│ │ │ │ ├── setup.py
│ │ │ │ └── source_scripts
│ │ │ │ ├── inference
│ │ │ │ ├── __init__.py
│ │ │ │ ├── constants
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── constants.py
│ │ │ │ ├── inference.py
│ │ │ │ ├── requirements.txt
│ │ │ │ ├── script_requirements.txt
│ │ │ │ └── version
│ │ │ │ └── training
│ │ │ │ ├── __init__.py
│ │ │ │ ├── args.py
│ │ │ │ ├── class_images.py
│ │ │ │ ├── constants
│ │ │ │ ├── __init__.py
│ │ │ │ └── constants.py
│ │ │ │ ├── dataset.py
│ │ │ │ ├── evaluation.py
│ │ │ │ ├── model.py
│ │ │ │ ├── requirements.txt
│ │ │ │ └── transfer_learning.py
│ │ │ └── train_deploy_iot_product
│ │ │ ├── __init__.py
│ │ │ ├── project.py
│ │ │ └── seed_code
│ │ │ └── deploy_app
│ │ │ ├── .githooks
│ │ │ └── pre-commit
│ │ │ ├── .pre-commit-config.yaml
│ │ │ ├── README.md
│ │ │ ├── app
│ │ │ ├── app.py
│ │ │ ├── data.csv
│ │ │ ├── greengrass_mqtt_ipc.py
│ │ │ └── requirements.txt
│ │ │ ├── buildspec.build.yml
│ │ │ ├── buildspec.deploy.yml
│ │ │ ├── cdk_app
│ │ │ ├── README.md
│ │ │ ├── app.py
│ │ │ ├── buildspec.build.yml
│ │ │ ├── cdk.json
│ │ │ ├── config
│ │ │ │ ├── cfn_nag_ignore.yml
│ │ │ │ └── constants.py
│ │ │ ├── iot_infra
│ │ │ │ ├── __init__.py
│ │ │ │ ├── greengrass
│ │ │ │ │ └── install_ggv2.sh
│ │ │ │ ├── iot_infra_stack.py
│ │ │ │ └── utils.py
│ │ │ ├── requirements-dev.txt
│ │ │ ├── requirements.txt
│ │ │ ├── source.bat
│ │ │ └── tests
│ │ │ │ ├── __init__.py
│ │ │ │ └── unit
│ │ │ │ ├── __init__.py
│ │ │ │ └── test_infra_stack.py
│ │ │ ├── greengrass-config.yml
│ │ │ ├── helpers
│ │ │ ├── gdk-synth.py
│ │ │ ├── gg-build.sh
│ │ │ ├── gg-deploy.sh
│ │ │ └── gg-publish.sh
│ │ │ ├── model
│ │ │ └── compile
│ │ │ │ ├── custom-build.sh
│ │ │ │ └── onnx_converter.py
│ │ │ ├── python-dependencies
│ │ │ └── package
│ │ │ │ └── custom-build.sh
│ │ │ └── requirements.txt
│ ├── requirements-dev.txt
│ ├── requirements.txt
│ ├── source.bat
│ └── tests
│ │ ├── __init__.py
│ │ └── unit
│ │ ├── __init__.py
│ │ └── test_mlops_batch_v2_stack.py
└── scripts
│ ├── cdk-bootstrap-accounts.sh
│ ├── create-config-files.sh
│ ├── install-prerequisites-brew.sh
│ └── quick-start.sh
└── mlops-multi-account-tf
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── architecture
├── architecture.png
├── base-infra.png
├── project-list.png
├── template-repos.png
└── user-exp.png
├── base-infrastructure
├── .github
│ └── workflows
│ │ ├── deploy.yml
│ │ ├── destroy.yml
│ │ └── quality-check.yml
├── .gitignore
├── .pre-commit-config.yaml
├── Makefile
├── README.md
├── config.json
└── terraform
│ ├── .terraform-docs.yml
│ ├── README.md
│ ├── account_config
│ ├── dev
│ │ ├── data_scientist.yml
│ │ ├── lead_data_scientist.yml
│ │ └── terraform.tfvars
│ ├── preprod
│ │ └── terraform.tfvars
│ └── prod
│ │ └── terraform.tfvars
│ ├── create_documentation.bash
│ ├── dev
│ ├── README.md
│ ├── iam.tf
│ ├── iam_policy_documents.tf
│ ├── lambda.tf
│ ├── lambdas
│ │ ├── functions
│ │ │ ├── clone_repo_lambda
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cfnresponse.py
│ │ │ │ └── lambda_function.py
│ │ │ └── trigger_workflow_lambda
│ │ │ │ ├── __init__.py
│ │ │ │ └── lambda_function.py
│ │ └── layers
│ │ │ ├── build.sh
│ │ │ └── layers
│ │ │ └── python_github
│ │ │ └── requirements.txt
│ ├── locals.tf
│ ├── main.tf
│ ├── s3_policy_documents.tf
│ ├── sagemaker_templates
│ │ ├── sagemaker_project_llm_train.yaml
│ │ ├── sagemaker_project_train.yaml
│ │ ├── sagemaker_project_train_and_deploy.yaml
│ │ └── sagemaker_project_workflow.yaml
│ ├── ssm.tf
│ ├── variables.tf
│ └── versions.tf
│ ├── modules
│ ├── kms
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── ssm.tf
│ │ └── variables.tf
│ ├── lambda
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── networking
│ │ ├── README.md
│ │ ├── cloudwatch.tf
│ │ ├── endpoints.tf
│ │ ├── outputs.tf
│ │ ├── secure-networking.jpg
│ │ ├── ssm.tf
│ │ ├── variables.tf
│ │ └── vpc.tf
│ ├── s3
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── sagemaker
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── ssm.tf
│ │ └── variables.tf
│ ├── sagemaker_roles
│ │ ├── README.md
│ │ ├── data.tf
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── ssm.tf
│ │ └── variables.tf
│ └── service_catalog
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── vars.tf
│ ├── preprod
│ ├── README.md
│ ├── iam.tf
│ ├── iam_policy_documents.tf
│ ├── locals.tf
│ ├── main.tf
│ ├── s3.tf
│ ├── ssm.tf
│ ├── variables.tf
│ └── versions.tf
│ └── prod
│ ├── README.md
│ ├── iam.tf
│ ├── iam_policy_documents.tf
│ ├── locals.tf
│ ├── main.tf
│ ├── s3.tf
│ ├── ssm.tf
│ ├── variables.tf
│ └── versions.tf
├── bootstrap.sh
├── bootstrap.yaml
└── template-repos
├── README.md
├── container-build
├── .github
│ ├── actions
│ │ └── ecr-build-and-push
│ │ │ └── action.yml
│ └── workflows
│ │ ├── endpoint.yml
│ │ ├── processing.yml
│ │ └── training.yml
├── .gitignore
├── README.md
├── endpoint
│ ├── Dockerfile
│ ├── xgboost-0.90-1-cpu-py3.json
│ └── xgboost-1.0-1-cpu-py3.json
├── img
│ └── byoc_architecture.png
├── processing
│ ├── Dockerfile
│ ├── xgboost-0.90-1-cpu-py3.json
│ └── xgboost-1.0-1-cpu-py3.json
└── training
│ ├── Dockerfile
│ ├── xgboost-0.90-1-cpu-py3.json
│ └── xgboost-1.0-1-cpu-py3.json
├── llm-training
├── .github
│ └── workflows
│ │ └── train.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── datasets
│ ├── evaluation_dataset_trivia.jsonl
│ ├── other_datasets
│ │ ├── evaluation_dataset.jsonl
│ │ ├── train_dataset.jsonl
│ │ ├── train_dataset_trivia.jsonl
│ │ ├── validation_dataset.jsonl
│ │ └── validation_dataset_trivia.jsonl
│ ├── template.json
│ ├── train_dataset_trivia.jsonl
│ └── validation_dataset_trivia.jsonl
├── local-requirements.txt
├── notebooks
│ ├── run_evaluation_jumpstart_model.ipynb
│ └── sm_pipeline_basic_example
│ │ ├── .ipynb_checkpoints
│ │ ├── README-checkpoint.md
│ │ ├── config-checkpoint.yaml
│ │ ├── local-requirements-checkpoint.txt
│ │ ├── pipeline-checkpoint.py
│ │ ├── requirements-checkpoint.txt
│ │ └── runme-checkpoint.ipynb
│ │ ├── README.md
│ │ ├── config.yaml
│ │ ├── img
│ │ └── sm-pipeline-execution.png
│ │ ├── local-requirements.txt
│ │ ├── pipeline.py
│ │ ├── requirements.txt
│ │ ├── runme.ipynb
│ │ ├── sagemaker.tar.gz
│ │ └── steps
│ │ ├── __init__.py
│ │ ├── evaluation.py
│ │ ├── preprocess.py
│ │ ├── register.py
│ │ └── train.py
├── sm_pipelines
│ ├── config.yaml
│ ├── lib
│ │ └── utils.py
│ ├── local-requirements.txt
│ ├── pipeline.py
│ ├── pipeline_config.yaml
│ ├── pipeline_finetuning.py
│ ├── pipeline_finetuning_config.yaml
│ ├── pipeline_scale.py
│ ├── pipeline_scale_config.yaml
│ ├── pipeline_scale_hybrid_config.yaml
│ ├── requirements.txt
│ ├── runme.ipynb
│ └── steps
│ │ ├── cleanup.py
│ │ ├── deploy.py
│ │ ├── deploy_finetuned_model.py
│ │ ├── evaluation.py
│ │ ├── finetune.py
│ │ ├── preprocess.py
│ │ ├── register.py
│ │ ├── register_finetuned.py
│ │ └── selection.py
├── sm_pipelines_advanced
│ ├── config.yaml
│ ├── lib
│ │ ├── import_models.py
│ │ └── utils.py
│ ├── local-requirements.txt
│ ├── model_providers
│ │ ├── model_pipeline_steps.py
│ │ ├── model_pipeline_steps_jumpstart.py
│ │ └── steps
│ │ │ ├── evaluation.py
│ │ │ ├── preprocess.py
│ │ │ ├── register.py
│ │ │ └── selection.py
│ ├── pipeline_config.yaml
│ ├── pipeline_finetuning_config.yaml
│ ├── pipeline_scale_advanced.py
│ ├── pipeline_scale_config.yaml
│ ├── pipeline_scale_hybrid_config.yaml
│ ├── requirements.txt
│ └── runme.ipynb
└── upload_datasets.py
├── model-deployment-batch
├── .github
│ └── workflows
│ │ ├── deploy.yml
│ │ └── deploy_cfn.yml
├── Makefile
├── README.md
├── batch-config-template.tf
├── build.py
├── cloud_formation
│ ├── batch-config-template.yml
│ ├── pre-prod-config.json
│ └── prod-config.json
├── img
│ └── batch_architecture.png
├── pipelines
│ ├── README.md
│ ├── __init__.py
│ ├── __version__.py
│ ├── _utils.py
│ ├── batch_inference
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── pipeline.py
│ │ └── preprocess.py
│ ├── get_pipeline_definition.py
│ └── run_pipeline.py
├── pre-prod-config.tfvars.json
├── prod-config.tfvars.json
├── utils.py
├── variables.tf
└── version.tf
├── model-deployment-realtime
├── .github
│ └── workflows
│ │ ├── deploy.yml
│ │ └── deploy_cfn.yml
├── Makefile
├── README.md
├── build.py
├── cloud_formation
│ ├── endpoint-config-template.yml
│ ├── pre-prod-config.json
│ └── prod-config.json
├── endpoint-config.tf
├── pre-prod-config.tfvars.json
├── prod-config.tfvars.json
├── test
│ └── test.py
├── utils.py
├── variables.tf
└── versions.tf
├── model-training
├── .github
│ └── workflows
│ │ └── train.yml
├── CONTRIBUTING.md
├── README.md
├── img
│ └── pipeline-full.png
├── pipelines
│ ├── __init__.py
│ ├── __version__.py
│ ├── _utils.py
│ ├── abalone
│ │ ├── __init__.py
│ │ ├── evaluate.py
│ │ ├── pipeline.py
│ │ └── preprocess.py
│ ├── get_pipeline_definition.py
│ └── run_pipeline.py
├── setup.cfg
├── setup.py
├── tests
│ └── test_pipelines.py
└── tox.ini
└── pipeline-promotion
├── .github
└── workflows
│ ├── deploy.yml
│ └── deploy_cfn.yml
├── .gitignore
├── Makefile
├── README.md
├── __init__.py
├── deploy_target
├── batch-config-template.tf
├── build.py
├── cloud_formation
│ ├── batch-config-template.yml
│ ├── pre-prod-config.json
│ └── prod-config.json
├── pre-prod-config.tfvars.json
├── prod-config.tfvars.json
├── utils.py
├── variables.tf
└── versions.tf
├── img
├── architecture.png
├── pipeline-1.png
├── pipeline-2.png
├── pipeline-3.png
├── pipeline-4.png
├── pipeline-5.png
├── pipeline-6.png
├── pipeline-7.png
├── pipeline-8.png
└── pipeline-full.png
├── pipelines
├── README.md
├── __init__.py
├── __version__.py
├── _utils.py
├── batch_inference
│ ├── README.md
│ ├── __init__.py
│ ├── evaluate.py
│ ├── pipeline.py
│ └── preprocess.py
├── get_pipeline_definition.py
└── run_pipeline.py
├── sagemaker-pipelines-preprocess-train-evaluate-batch-transform.ipynb
├── setup.cfg
├── setup.py
├── tests
└── test_pipelines.py
└── tox.ini
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.zip
3 | outputs
4 | ipynb_checkpoints
5 | sm-pr.code-workspace
6 | *.idea*
7 | *bootstrap_conf.tmp
8 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/BatchInferencePipeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/BatchInferencePipeline.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/DAG.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/DAG.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/InitialPhase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/InitialPhase.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/MaturityLevel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/MaturityLevel.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/ReliablePhase1-Latest-Version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/ReliablePhase1-Latest-Version.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/ReliablePhase2-Latest-Version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/ReliablePhase2-Latest-Version.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/RepeatablePhase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/RepeatablePhase.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/ScalePhase-Latest-Version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/ScalePhase-Latest-Version.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/ScalePhase-Studio-Latest-Version.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/ScalePhase-Studio-Latest-Version.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/TrainingPipeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/TrainingPipeline.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/challenges.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/challenges.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/datastructure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/datastructure.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/deploymentcicd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/deploymentcicd.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/integrationwithdatalake.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/integrationwithdatalake.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/diagrams/modelbuildcicd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/diagrams/modelbuildcicd.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
3 | SPDX-License-Identifier: MIT-0
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | software and associated documentation files (the "Software"), to deal in the Software
7 | without restriction, including without limitation the rights to use, copy, modify,
8 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/add_comments_to_empty_files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Find all empty files in the current directory
4 | empty_files=$(find . -type f -empty)
5 |
6 | # Add comment to each empty file
7 | echo $empty_files
8 | for file in $empty_files; do
9 | echo "# Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012" >> "$file"
10 | done
11 |
12 | echo "Comments added to empty files."
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "python3 app.py",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "requirements*.txt",
11 | "source.bat",
12 | "**/__init__.py",
13 | "python/__pycache__",
14 | "tests"
15 | ]
16 | },
17 | "context": {
18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
19 | "@aws-cdk/core:stackRelativeExports": true,
20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
22 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
23 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
24 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
25 | "@aws-cdk/core:target-partitions": [
26 | "aws",
27 | "aws-cn"
28 | ]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/diagrams/CodeCommit_repositories_in_governance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-infra/diagrams/CodeCommit_repositories_in_governance.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/diagrams/CodePipelines_in_governance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-infra/diagrams/CodePipelines_in_governance.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-mlops infrastructure architecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-mlops infrastructure architecture.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-mlops secure networking.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-mlops secure networking.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-sagemaker studio stack.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-infra/diagrams/MLOPs Foundation Architecture-sagemaker studio stack.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/functions/sm_studio/enable_sm_projects/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.32.0
2 | urllib3<2
3 | cfnresponse
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/cdk_helper_scripts/zip-image/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM public.ecr.aws/docker/library/alpine:latest
2 |
3 | RUN apk --no-cache add zip make
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/config/accounts.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "SET_NAME": "first-example",
4 | "DEV_ACCOUNT": "",
5 | "PREPROD_ACCOUNT": "",
6 | "PROD_ACCOUNT": ""
7 | },
8 | {
9 | "SET_NAME": "second-example",
10 | "DEV_ACCOUNT": "",
11 | "PREPROD_ACCOUNT": "",
12 | "PROD_ACCOUNT": ""
13 | }
14 | ]
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/config/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | CODE_COMMIT_REPO_NAME = "mlops-infra"
19 | PIPELINE_BRANCH = "main"
20 |
21 | PIPELINE_ACCOUNT = "" # account to host the pipeline handling updates of this repository
22 |
23 | DEFAULT_DEPLOYMENT_REGION = "eu-west-1"
24 | APP_PREFIX = "mlops"
25 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/config/dev/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.0/16"
20 |
21 | APP_SUBNETS = ["subnet-", "subnet-", "subnet-"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/config/dev/data_scientists.yml:
--------------------------------------------------------------------------------
1 | prefix: "ds"
2 | users:
3 | - user_profile_name: "data-scientist"
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/mlops_infra/config/dev/lead_data_scientists.yml:
--------------------------------------------------------------------------------
1 | prefix: "lead-ds"
2 | users:
3 | - user_profile_name: "lead-data-scientist"
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest==6.2.5
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-infra/requirements.txt:
--------------------------------------------------------------------------------
1 | aws-cdk-lib>=2.12.0
2 | aws_cdk.aws_lambda_python_alpha
3 | constructs>=10.0.0,<11.0.0
4 | yamldataclassconfig
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/.gitignore:
--------------------------------------------------------------------------------
1 | *.ipynb_checkpoints/
2 | *.DS_Store
3 | *.swp
4 | package-lock.json
5 | __pycache__
6 | .pytest_cache
7 | .venv
8 | *.egg-info
9 |
10 | # CDK asset staging directory
11 | .cdk.staging
12 | cdk.out
13 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
3 | SPDX-License-Identifier: MIT-0
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | software and associated documentation files (the "Software"), to deal in the Software
7 | without restriction, including without limitation the rights to use, copy, modify,
8 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/add_comments_to_empty_files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Find all empty files in the current directory
4 | empty_files=$(find . -type f -empty)
5 |
6 | # Add comment to each empty file
7 | echo $empty_files
8 | for file in $empty_files; do
9 | echo "# Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012" >> "$file"
10 | done
11 |
12 | echo "Comments added to empty files."
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "python3 app.py",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "requirements*.txt",
11 | "source.bat",
12 | "**/__init__.py",
13 | "python/__pycache__",
14 | "tests"
15 | ]
16 | },
17 | "context": {
18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
19 | "@aws-cdk/core:stackRelativeExports": true,
20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
22 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
23 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
24 | "@aws-cdk/core:target-partitions": [
25 | "aws",
26 | "aws-cn"
27 | ]
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/MLOPs Foundation Architecture-mlops project cicd architecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/MLOPs Foundation Architecture-mlops project cicd architecture.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/MLOPs Foundation Architecture-sagemaker project architecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/MLOPs Foundation Architecture-sagemaker project architecture.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/SageMaker_organization_templates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/SageMaker_organization_templates.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/Service_catalog_portfolio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/Service_catalog_portfolio.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/building.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/building.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/deployment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/deployment.png
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/mlops-sm-project-general-architecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-cdk/mlops-sm-project-template/diagrams/mlops-sm-project-general-architecture.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/cdk_helper_scripts/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/cdk_helper_scripts/zip-image/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM public.ecr.aws/docker/library/alpine:latest
2 |
3 | RUN apk --no-cache add zip make
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/config/accounts.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "SET_NAME": "first-example",
4 | "DEV_ACCOUNT": "",
5 | "PREPROD_ACCOUNT": "",
6 | "PROD_ACCOUNT": "",
7 | "DEPLOYMENT_REGION":""
8 | },
9 | {
10 | "SET_NAME": "second-example",
11 | "DEV_ACCOUNT": "",
12 | "PREPROD_ACCOUNT": "",
13 | "PROD_ACCOUNT": "",
14 | "DEPLOYMENT_REGION":""
15 | }
16 | ]
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/config/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | CODE_COMMIT_REPO_NAME = "mlops-sm-project-template"
19 | PIPELINE_BRANCH = "main"
20 |
21 | PIPELINE_ACCOUNT = "" # account used to host the pipeline handling updates of this repository
22 |
23 | DEFAULT_DEPLOYMENT_REGION = "eu-west-1"
24 | APP_PREFIX = "mlops-cdk"
25 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.11
7 | commands:
8 | - pip install --upgrade --force-reinstall . "awscli>1.20.30"
9 |
10 | build:
11 | commands:
12 | - export PYTHONUNBUFFERED=TRUE
13 | - export SAGEMAKER_PROJECT_NAME_ID="${SAGEMAKER_PROJECT_NAME}-${SAGEMAKER_PROJECT_ID}"
14 | - |
15 | run-pipeline --module-name ml_pipelines.training.pipeline \
16 | --role-arn $SAGEMAKER_PIPELINE_ROLE_ARN \
17 | --tags "[{\"Key\":\"sagemaker:project-name\", \"Value\":\"${SAGEMAKER_PROJECT_NAME}\"}, {\"Key\":\"sagemaker:project-id\", \"Value\":\"${SAGEMAKER_PROJECT_ID}\"}]" \
18 | --kwargs "{\"region\":\"${AWS_REGION}\",\"role\":\"${SAGEMAKER_PIPELINE_ROLE_ARN}\",\"default_bucket\":\"${ARTIFACT_BUCKET}\",\"pipeline_name\":\"${SAGEMAKER_PROJECT_NAME_ID}\",\"model_package_group_name\":\"${MODEL_PACKAGE_GROUP_NAME}\",\"base_job_prefix\":\"${SAGEMAKER_PROJECT_NAME_ID}\", \"bucket_kms_id\":\"${ARTIFACT_BUCKET_KMS_ID}\"}"
19 | - echo "Create/Update of the SageMaker Pipeline and execution completed."
20 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/ml_pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a modul inside its own folder, for example here the "training" pipeline, contained inside `training/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/ml_pipelines/training/README.md:
--------------------------------------------------------------------------------
1 | # Training SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Prepare the Abalone dataset through a SageMaker Processing Job
5 | - Train an XGBoost algorithm on the train set
6 | - Evaluate the performance of the trained XGBoost algorithm on the validation set
7 | - If the performance reaches a specified threshold, send the model for Manual Approval to SageMaker Model Registry.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # Jupyter Notebooks
2 |
3 | This folder is intended to store your experiment notebooks.
4 | Typically the first step would be to store your Data Science notebooks, and start defining example SageMaker pipelines in here. Once satisfied with the first iteration of a SageMaker pipeline, the code should move as python scripts inside the respective `ml_pipelines/` and `source_scripts/` folders.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 | license_file = LICENSE
12 |
13 | [wheel]
14 | universal = 1
15 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/evaluate/evaluate_xgboost/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/evaluate/evaluate_xgboost/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/helpers/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/helpers/logger.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/helpers/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/helpers/s3_helper.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/helpers/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/preprocessing/prepare_abalone_data/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/preprocessing/prepare_abalone_data/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/training/xgboost/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/training/xgboost/__main__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/training/xgboost/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/abalone_build_app/source_scripts/training/xgboost/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | build:
5 | commands:
6 | - npm install -g aws-cdk
7 | - pip install -r requirements.txt
8 | - cdk synth --no-lookups
9 |
10 | artifacts:
11 | base-directory: "cdk.out"
12 | files: "**/*"
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "python3 app.py",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "requirements*.txt",
11 | "source.bat",
12 | "**/__init__.py",
13 | "python/__pycache__",
14 | "tests"
15 | ]
16 | },
17 | "context": {
18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
19 | "@aws-cdk/core:stackRelativeExports": true,
20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
22 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
23 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
24 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
25 | "@aws-cdk/core:target-partitions": [
26 | "aws",
27 | "aws-cn"
28 | ]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/cfn_nag_ignore.yml:
--------------------------------------------------------------------------------
1 | RulesToSuppress:
2 | - id: "W1200"
3 | reason: "W1200 is an warning raised due to using ec2 instance with nvme ssd"
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/dev/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/dev/endpoint-config.yml:
--------------------------------------------------------------------------------
1 | initial_instance_count: 1
2 | initial_variant_weight: 1
3 | instance_type: "ml.m5.large"
4 | variant_name: "AllTraffic"
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/prod/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/prod/endpoint-config.yml:
--------------------------------------------------------------------------------
1 | initial_instance_count: 1
2 | initial_variant_weight: 1
3 | instance_type: "ml.m5.large"
4 | variant_name: "AllTraffic"
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/staging/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/config/staging/endpoint-config.yml:
--------------------------------------------------------------------------------
1 | initial_instance_count: 1
2 | initial_variant_weight: 1
3 | instance_type: "ml.m5.large"
4 | variant_name: "AllTraffic"
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/deploy_endpoint/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest==6.2.5
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/requirements.txt:
--------------------------------------------------------------------------------
1 | aws-cdk-lib
2 | boto3
3 | constructs
4 | yamldataclassconfig
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/source.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | rem The sole purpose of this script is to make the command
4 | rem
5 | rem source .venv/bin/activate
6 | rem
7 | rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
8 | rem On Windows, this command just runs this batch file (the argument is ignored).
9 | rem
10 | rem Now we don't need to document a Windows command for activating a virtualenv.
11 |
12 | echo Executing .venv\Scripts\activate.bat for you
13 | .venv\Scripts\activate.bat
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/tests/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/tests/integration_tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/tests/integration_tests/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.8
7 | build:
8 | commands:
9 | # Call the test python code
10 | - python tests/integration_tests/endpoint_test.py --import-build-config $CODEBUILD_SRC_DIR_BuildArtifact/staging-config-export.json --export-test-results $EXPORT_TEST_RESULTS
11 | # Show the test results file
12 | - cat $EXPORT_TEST_RESULTS
13 |
14 | artifacts:
15 | files:
16 | - $EXPORT_TEST_RESULTS
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/common_seed_code/endpoint_deploy_app/tests/unittests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/constructs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/constructs/conf/cfn_nag_ignore.yml:
--------------------------------------------------------------------------------
1 | RulesToSuppress:
2 | - id: "W58"
3 | reason: "W58 is an warning raised due to Lambda functions require permission to write CloudWatch Logs, although the
4 | lambda role contains the policy that support these permissions cgn_nag continues to through this problem
5 | (https://github.com/stelligent/cfn_nag/issues/422)"
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/constructs/conf/default_deploy_buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 | env:
3 | shell: bash
4 | phases:
5 | install:
6 | runtime-versions:
7 | python: 3.11
8 | commands:
9 | - pip install --upgrade --force-reinstall "awscli>1.20.30"
10 | build:
11 | commands:
12 | - npm install -g aws-cdk
13 | - pip install -r requirements.txt
14 | - cdk synth --no-lookups
15 |
16 | artifacts:
17 | base-directory: cdk.out
18 | files: '**/*'
19 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.11
7 | commands:
8 | - pip install --upgrade --force-reinstall . "awscli>1.20.30"
9 |
10 | build:
11 | commands:
12 | - export PYTHONUNBUFFERED=TRUE
13 | - export SAGEMAKER_PROJECT_NAME_ID="${SAGEMAKER_PROJECT_NAME}-${SAGEMAKER_PROJECT_ID}"
14 | - |
15 | run-pipeline --module-name ml_pipelines.text2sql_finetune.pipeline \
16 | --role-arn $SAGEMAKER_PIPELINE_ROLE_ARN \
17 | --tags "[{\"Key\":\"sagemaker:project-name\", \"Value\":\"${SAGEMAKER_PROJECT_NAME}\"}, {\"Key\":\"sagemaker:project-id\", \"Value\":\"${SAGEMAKER_PROJECT_ID}\"}]" \
18 | --kwargs "{\"region\":\"${AWS_REGION}\",\"role\":\"${SAGEMAKER_PIPELINE_ROLE_ARN}\",\"default_bucket\":\"${ARTIFACT_BUCKET}\",\"pipeline_name\":\"${SAGEMAKER_PROJECT_NAME_ID}\",\"model_package_group_name\":\"${MODEL_PACKAGE_GROUP_NAME}\",\"base_job_prefix\":\"${SAGEMAKER_PROJECT_NAME_ID}\"}" #", \"bucket_kms_id\":\"${ARTIFACT_BUCKET_KMS_ID}\"}"
19 | - echo "Create/Update of the SageMaker Pipeline and execution completed."
20 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/ml_pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a modul inside its own folder, for example here the "training" pipeline, contained inside `training/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/ml_pipelines/text2sql_finetune/README.md:
--------------------------------------------------------------------------------
1 | ## CodeLLama Fine-tune ModelBuild Project Template
2 |
3 | This is a sample code repository that demonstrates how the LLM CodeLlama can be fine-tuned with Amazon SageMaker pipelines.
4 | The pipeline fine-tunes the model with the provided data. After training, the model will be evaluated and it the score exceeds a certain threshold, the model will be registered to SageMaker Model Registry.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # Jupyter Notebooks
2 |
3 | This folder is intended to store your experiment notebooks.
4 | Typically the first step would be to store your Data Science notebooks, and start defining example SageMaker pipelines in here. Once satisfied with the first iteration of a SageMaker pipeline, the code should move as python scripts inside the respective `ml_pipelines/` and `source_scripts/` folders.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 | license_file = LICENSE
12 |
13 | [wheel]
14 | universal = 1
15 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/finetune_deploy_llm_product/seed_code/build_app/source_scripts/requirements.txt:
--------------------------------------------------------------------------------
1 | transformers==4.33.0
2 | torch>=2.0.0
3 | peft==0.4.0
4 | accelerate==0.21.0
5 | bitsandbytes==0.40.2
6 | safetensors>=0.3.1
7 | tokenizers>=0.13.3
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_basic_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/ml_pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a modul inside its own folder, for example here the "training" pipeline, contained inside `training/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/ml_pipelines/inference/README.md:
--------------------------------------------------------------------------------
1 | # Inference SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Preprocess data parsed from the data repository, to extract text content from documents
5 | - Run a SageMaker Batch Transform job to generate example questions from the content of the document and extract the part of content used to generate each question
6 | - (Placeholder) Concatenate different text fields from the output document to be used to create embeddings (currently only using the generated questions from the previous step)
7 | - Run a SageMaker Batch Transform job to generate embeddings
8 | - Postprocess the output document
9 | - Create an OpenSearch index
10 | - Populate an OpenSearch index with the content and associated embeddings
11 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/ml_pipelines/training/README.md:
--------------------------------------------------------------------------------
1 | # Training SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Prepare the Abalone dataset through a SageMaker Processing Job
5 | - Train an XGBoost algorithm on the train set
6 | - Evaluate the performance of the trained XGBoost algorithm on the validation set
7 | - If the performance reaches a specified threshold, send the model for Manual Approval to SageMaker Model Registry.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # Jupyter Notebooks
2 |
3 | This folder is intended to store your experiment notebooks.
4 | Typically the first step would be to store your Data Science notebooks, and start defining example SageMaker pipelines in here. Once satisfied with the first iteration of a SageMaker pipeline, the code should move as python scripts inside the respective `ml_pipelines/` and `source_scripts/` folders.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/helpers/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/helpers/logger.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/helpers/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/helpers/s3_helper.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/helpers/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/training/xgboost/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/training/xgboost/__main__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/training/xgboost/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/build_app/source_scripts/training/xgboost/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.11
7 | build:
8 | commands:
9 | - npm install -g aws-cdk
10 | - pip install -r requirements.txt
11 | - cdk synth --no-lookups
12 |
13 | artifacts:
14 | base-directory: "cdk.out"
15 | files: "**/*"
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "python3 app.py",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "requirements*.txt",
11 | "source.bat",
12 | "**/__init__.py",
13 | "python/__pycache__",
14 | "tests"
15 | ]
16 | },
17 | "context": {
18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
19 | "@aws-cdk/core:stackRelativeExports": true,
20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
22 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
23 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
24 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
25 | "@aws-cdk/core:target-partitions": [
26 | "aws",
27 | "aws-cn"
28 | ]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/config/dev/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/config/preprod/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/config/prod/constants.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 | VPC_ID = "vpc-"
19 | VPC_CIDR = "10.0.0.1/21"
20 |
21 | APP_SUBNETS = ["subnet-1", "subnet-2", "subnet-3"]
22 |
23 | BASE_SECURITY_GROUP = "sg-"
24 |
25 | DEFAULT_TIMEOUT = 300
26 | DEFAULT_MEMORY_SIZE = 256
27 | INFERENCE_MEMORY_SIZE = 1024
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/deploy_sagemaker_pipeline/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest==6.2.5
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/requirements.txt:
--------------------------------------------------------------------------------
1 | boto3<1.33.2
2 | botocore<1.33.2
3 | s3transfer<0.8.1
4 | aws-cdk-lib==2.100.0
5 | dataclasses-json==0.6.1
6 | constructs>=10.0.0,<11.0.0
7 | yamldataclassconfig==1.5.0
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/source.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | rem The sole purpose of this script is to make the command
4 | rem
5 | rem source .venv/bin/activate
6 | rem
7 | rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
8 | rem On Windows, this command just runs this batch file (the argument is ignored).
9 | rem
10 | rem Now we don't need to document a Windows command for activating a virtualenv.
11 |
12 | echo Executing .venv\Scripts\activate.bat for you
13 | .venv\Scripts\activate.bat
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/tests/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/tests/integration_tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/tests/integration_tests/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.8
7 | build:
8 | commands:
9 | # Call the test python code
10 | - python tests/integration_tests/endpoint_test.py --import-build-config $CODEBUILD_SRC_DIR_BuildArtifact/staging-config-export.json --export-test-results $EXPORT_TEST_RESULTS
11 | # Show the test results file
12 | - cat $EXPORT_TEST_RESULTS
13 |
14 | artifacts:
15 | files:
16 | - $EXPORT_TEST_RESULTS
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_batch_inference_product/seed_code/deploy_app/tests/unittests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/ml_pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a modul inside its own folder, for example here the "training" pipeline, contained inside `training/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/ml_pipelines/training/README.md:
--------------------------------------------------------------------------------
1 | # Training SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Prepare the Abalone dataset through a SageMaker Processing Job
5 | - Train an XGBoost algorithm on the train set
6 | - Evaluate the performance of the trained XGBoost algorithm on the validation set
7 | - If the performance reaches a specified threshold, send the model for Manual Approval to SageMaker Model Registry.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # Jupyter Notebooks
2 |
3 | This folder is intended to store your experiment notebooks.
4 | Typically the first step would be to store your Data Science notebooks, and start defining example SageMaker pipelines in here. Once satisfied with the first iteration of a SageMaker pipeline, the code should move as python scripts inside the respective `ml_pipelines/` and `source_scripts/` folders.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 | license_file = LICENSE
12 |
13 | [wheel]
14 | universal = 1
15 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM public.ecr.aws/docker/library/r-base:4.1.2 as base
2 |
3 | # Install tidyverse
4 | RUN apt update && apt-get install -y --no-install-recommends \
5 | r-cran-tidyverse
6 |
7 | RUN R -e "install.packages(c('rjson'))"
8 |
9 |
10 | ### start of PROCESSING container
11 | FROM base as processing
12 | ENTRYPOINT ["Rscript"]
13 |
14 | ### start of TRAINING container
15 | FROM base as training
16 | RUN apt-get -y update && apt-get install -y --no-install-recommends \
17 | wget \
18 | apt-transport-https \
19 | ca-certificates \
20 | libcurl4-openssl-dev \
21 | libsodium-dev
22 |
23 | RUN apt-get update && apt-get install -y python3-dev python3-pip python3-boto3
24 | #RUN pip3 install boto3
25 | RUN R -e "install.packages('reticulate',dependencies=TRUE, repos='http://cran.rstudio.com/')"
26 | RUN R -e "install.packages(c('readr','plumber'))"
27 |
28 | ENV PATH="/opt/ml/code:${PATH}"
29 |
30 | WORKDIR /opt/ml/code
31 |
32 | COPY docker_helpers/run.sh /opt/ml/code/run.sh
33 | COPY docker_helpers/entrypoint.R /opt/ml/entrypoint.R
34 |
35 | RUN /bin/bash -c 'chmod +x /opt/ml/code/run.sh'
36 |
37 | ENTRYPOINT ["/bin/bash", "run.sh"]
38 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/docker-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | REPO_NAME=$1
4 |
5 | echo $REPO_NAME
6 |
7 | aws ecr describe-repositories --region $AWS_DEFAULT_REGION --repository-names $REPO_NAME | jq --raw-output '.repositories[0]' > repository-info.json;
8 |
9 | AWS_ACCOUNT_ID=$(jq -r .registryId repository-info.json);
10 | REPOSITORY_URI=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${REPO_NAME};
11 | # REPOSITORY_URI=local
12 |
13 | aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
14 |
15 | target_stages=("processing" "training")
16 |
17 | for stage in "${target_stages[@]}"
18 | do
19 |
20 | IMAGE_TAG=$stage-$CODEBUILD_RESOLVED_SOURCE_VERSION;
21 |
22 | echo $IMAGE_TAG
23 |
24 | docker build --target $stage -t $REPOSITORY_URI:$stage .
25 | docker tag $REPOSITORY_URI:$stage $REPOSITORY_URI:$IMAGE_TAG
26 |
27 | docker push $REPOSITORY_URI:$stage
28 | docker push $REPOSITORY_URI:$IMAGE_TAG
29 |
30 | done
31 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/docker_helpers/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "ready to execute"
3 | Rscript /opt/ml/entrypoint.R $1
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/evaluate/README.md:
--------------------------------------------------------------------------------
1 | Use this folder to add all code related to evaluate the performance of your model.
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/helpers/README.md:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/helpers/logger.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/helpers/requirements.txt:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/helpers/s3_helper.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/helpers/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/preprocessing/README.md:
--------------------------------------------------------------------------------
1 | Use this folder to add all code related to preprocessing your data.
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/training/README.md:
--------------------------------------------------------------------------------
1 | Use this folder to add all code related to training your model.
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_byoc_product/seed_code/build_app/source_scripts/training/test/test_a.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/buildspec.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | python: 3.11
7 | commands:
8 | - pip install --upgrade --force-reinstall . "awscli>1.20.30"
9 |
10 | build:
11 | commands:
12 | - export PYTHONUNBUFFERED=TRUE
13 | - export SAGEMAKER_PROJECT_NAME_ID="${SAGEMAKER_PROJECT_NAME}-${SAGEMAKER_PROJECT_ID}"
14 | - |
15 | run-pipeline --module-name ml_pipelines.training.pipeline \
16 | --role-arn $SAGEMAKER_PIPELINE_ROLE_ARN \
17 | --tags "[{\"Key\":\"sagemaker:project-name\", \"Value\":\"${SAGEMAKER_PROJECT_NAME}\"}, {\"Key\":\"sagemaker:project-id\", \"Value\":\"${SAGEMAKER_PROJECT_ID}\"}]" \
18 | --kwargs "{\"region\":\"${AWS_REGION}\",\"role\":\"${SAGEMAKER_PIPELINE_ROLE_ARN}\",\"default_bucket\":\"${ARTIFACT_BUCKET}\",\"pipeline_name\":\"${SAGEMAKER_PROJECT_NAME_ID}\",\"model_package_group_name\":\"${MODEL_PACKAGE_GROUP_NAME}\",\"base_job_prefix\":\"${SAGEMAKER_PROJECT_NAME_ID}\", \"bucket_kms_id\":\"${ARTIFACT_BUCKET_KMS_ID}\"}"
19 | - echo "Create/Update of the SageMaker Pipeline and execution completed."
20 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/ml_pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a modul inside its own folder, for example here the "training" pipeline, contained inside `training/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/ml_pipelines/training/README.md:
--------------------------------------------------------------------------------
1 | ## StableDiffusion ModelBuild Project Template
2 |
3 | This is a sample code repository that demonstrates how the text to image model StableDiffusion can be fine-tuned, using the DreamBooth approach with Amazon SageMaker pipelines.
4 | The pipeline fine-tunes the model with the provided data. During the training step, the model will be evaluated at different checkpoints and the best one will be returned. If the score exceeds a certain threshold, the model will be registered.
5 |
6 | The pipeline requires the following parameters:
7 | - `InputDataUrl`: A s3 path to the training images. They should be square and same sized. Usually 5 images are enough.
8 | - `ClassToken`: A token (or tokens) describing the "class" of the object shown in the training images (e.g. "backpack" or "running shoes")
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # Jupyter Notebooks
2 |
3 | This folder is intended to store your experiment notebooks.
4 | Typically the first step would be to store your Data Science notebooks, and start defining example SageMaker pipelines in here. Once satisfied with the first iteration of a SageMaker pipeline, the code should move as python scripts inside the respective `ml_pipelines/` and `source_scripts/` folders.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 | license_file = LICENSE
12 |
13 | [wheel]
14 | universal = 1
15 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/source_scripts/inference/constants/constants.py:
--------------------------------------------------------------------------------
1 | APPLICATION_X_TEXT = "application/x-text"
2 | APPLICATION_JSON = "application/json"
3 |
4 | STR_DECODE_CODE = "utf-8"
5 | CUDA = "cuda"
6 | GENERATED_IMAGE = "generated_image"
7 | GENERATED_IMAGES = "generated_images"
8 | PROMPT = "prompt"
9 | VERBOSE_EXTENSION = ";verbose"
10 | JPEG_ACCEPT_EXTENSION = ";jpeg"
11 | JPEG_FORMAT = "JPEG"
12 |
13 | HEIGHT = "height"
14 | WIDTH = "width"
15 | NUM_INFERENCE_STEPS = "num_inference_steps"
16 | GUIDANCE_SCALE = "guidance_scale"
17 | NEGATIVE_PROMPT = "negative_prompt"
18 | NUM_IMAGES_PER_PROMPT = "num_images_per_prompt"
19 | BATCH_SIZE = "batch_size"
20 | ETA = "eta"
21 | SEED = "seed"
22 |
23 | ALL_PARAM_NAMES = [
24 | PROMPT,
25 | HEIGHT,
26 | WIDTH,
27 | NUM_INFERENCE_STEPS,
28 | GUIDANCE_SCALE,
29 | NEGATIVE_PROMPT,
30 | NUM_IMAGES_PER_PROMPT,
31 | ETA,
32 | SEED,
33 | BATCH_SIZE,
34 | ]
35 |
36 | USE_SCHEDULER = "use_scheduler"
37 | MODEL_INFO_FILE_NAME = "__model_info__.json"
38 | SCHEDULER = "scheduler"
39 |
40 | DEFAULT_WIDTH_PIXELS = 512
41 | DEFAULT_HEIGHT_PIXELS = 512
42 | DEFAULT_GUIDANCE_SCALE = 7.5
43 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/source_scripts/inference/requirements.txt:
--------------------------------------------------------------------------------
1 | transformers==4.38.0
2 | accelerate==0.15.0
3 | scipy==1.9.3
4 | diffusers==0.11.1
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/source_scripts/inference/script_requirements.txt:
--------------------------------------------------------------------------------
1 | transformers==4.38.0 \
2 | --hash=sha256:a6d7ae9afcfcc0773d8b9ef20940344bd1cae54fe49175ddea61c7c8d11fb52a \
3 | --hash=sha256:aa98177980467cb0c73f34b19d70d0577ec021c7c00706fbaca46ac358fd083c
4 | accelerate==0.15.0 \
5 | --hash=sha256:014833307424cd0a22f89815802e00653756257c45dfdba2453e52d428931c65
6 | scipy==1.9.3 \
7 | --hash=sha256:cff3a5295234037e39500d35316a4c5794739433528310e117b8a9a0c76d20fc
8 | diffusers==0.11.1 \
9 | --hash=sha256:5b3f0d113d369cb675d292c3dffb35d0bac96af095727b5380ca3d48eb0e3e94
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/source_scripts/inference/version:
--------------------------------------------------------------------------------
1 | 1.2.3
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_genai_cv_product/seed_code/build_app/source_scripts/training/requirements.txt:
--------------------------------------------------------------------------------
1 | accelerate==0.15.0
2 | bitsandbytes==0.38.1
3 | datasets==2.8.0
4 | diffusers==0.11.1
5 | transformers==4.38.0
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/app/requirements.txt:
--------------------------------------------------------------------------------
1 | numpy
2 | pandas
3 | onnxruntime
4 | awsiotsdk
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/buildspec.build.yml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 | env:
3 | shell: bash
4 | phases:
5 | install:
6 | runtime-versions:
7 | python: 3.11
8 | commands:
9 | - pip install --upgrade --force-reinstall "awscli>1.20.30"
10 | build:
11 | commands:
12 | - set -e # ensure the script fails if one line fails
13 | - npm install -g aws-cdk
14 | - npm install -g cdk-assets@2
15 | - cd cdk_app
16 | - pip install -r requirements.txt
17 | - cdk synth # --no-lookups
18 | - for f in cdk.out/*.assets.json; do cdk-assets publish --path $f; done
19 |
20 | artifacts:
21 | base-directory: cdk_app/cdk.out
22 | files: '**/*'
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/config/cfn_nag_ignore.yml:
--------------------------------------------------------------------------------
1 | RulesToSuppress:
2 | - id: "W12"
3 | reason: "Needed by greengrass device for deployment of ML models"
4 | - id: "W13"
5 | reason: "Needed by greengrass device for deployment of ML models"
6 | - id: "W28"
7 | reason: "Needed by greengrass device for deployment of ML models"
8 | - id: "W38"
9 | reason: "Needed by greengrass device for deployment of ML models"
10 | - id: "W39"
11 | reason: "Needed by greengrass device for deployment of ML models"
12 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/iot_infra/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/iot_infra/utils.py:
--------------------------------------------------------------------------------
1 | import os
2 | import zipfile
3 |
4 | def _zipdir(path, ziph):
5 | # ziph is zipfile handle
6 | for root, _, files in os.walk(path):
7 | for file in files:
8 | ziph.write(
9 | os.path.join(root, file),
10 | os.path.relpath(os.path.join(root, file),
11 | os.path.join(path, '..'))
12 | )
13 |
14 | def compress(source, destination):
15 | with zipfile.ZipFile(destination, 'w', zipfile.ZIP_DEFLATED) as zipf:
16 | _zipdir(source, zipf)
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest==6.2.5
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/requirements.txt:
--------------------------------------------------------------------------------
1 | boto3
2 | aws-cdk-lib
3 | constructs>=10.0.0,<11.0.0
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/source.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | rem The sole purpose of this script is to make the command
4 | rem
5 | rem source .venv/bin/activate
6 | rem
7 | rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
8 | rem On Windows, this command just runs this batch file (the argument is ignored).
9 | rem
10 | rem Now we don't need to document a Windows command for activating a virtualenv.
11 |
12 | echo Executing .venv\Scripts\activate.bat for you
13 | .venv\Scripts\activate.bat
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/tests/unit/__init__.py:
--------------------------------------------------------------------------------
1 | # Adding a comment here - empty files create issues with zipping https://github.com/aws/aws-cdk/issues/19012
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/cdk_app/tests/unit/test_infra_stack.py:
--------------------------------------------------------------------------------
1 | import aws_cdk as core
2 | import aws_cdk.assertions as assertions
3 |
4 | from iot_infra.iot_infra_stack import DeployEC2AndIotRole
5 |
6 | # example tests. To run these tests, uncomment this file along with the example
7 | # resource in iot_infra.iot_infra_stack/iot_infra_stack.py
8 | def test_template():
9 | app = core.App()
10 | stack = DeployEC2AndIotRole(app, "edge-infra")
11 | template = assertions.Template.from_stack(stack)
12 |
13 | # template.has_resource_properties("AWS::SQS::Queue", {
14 | # "VisibilityTimeout": 300
15 | # })
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/helpers/gg-deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | DEPLOYMENT_FILE=$1
3 | GDK_ARTEFACTS_DIR=$2
4 | TARGET_ARN=$3
5 |
6 | echo "switching folder to $GDK_ARTEFACTS_DIR/ .."
7 | cd $GDK_ARTEFACTS_DIR
8 | echo "Specifying target Things Group ARN in $DEPLOYMENT_FILE:"
9 | jq '.targetArn = "'"$TARGET_ARN"'"' $DEPLOYMENT_FILE > tmp && mv tmp $DEPLOYMENT_FILE
10 |
11 | # DEPLOY
12 | echo "Creating deployment with the following specifications:"
13 | echo $(cat deployment.json)
14 | aws greengrassv2 create-deployment --cli-input-json file://$DEPLOYMENT_FILE
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/helpers/gg-publish.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | CONFIG_FILE=$1
3 | GDK_ARTEFACTS_DIR=$2
4 | ROOT=""
5 | NAME=""
6 |
7 | cd $GDK_ARTEFACTS_DIR
8 | unzip publish.zip
9 | echo "switching folder to $GDK_ARTEFACTS_DIR/publish .."
10 | cd publish
11 |
12 | WORKDIR=$(pwd)
13 |
14 | echo "Parsing components .."
15 | while read -r line; do
16 | if [[ $line == root:* ]]; then
17 | echo $line
18 | ROOT=$(echo $line | sed 's/root://' | sed 's/ //' | tr -d '\"')
19 | elif [[ $line == component-name:* ]]; then
20 | echo $line
21 | NAME=$(echo $line | sed 's/component-name://' | sed 's/ //' | tr -d '\"')
22 | fi
23 |
24 | if [[ ! -z "$ROOT" ]] && [[ ! -z "$NAME" ]]; then
25 |
26 | echo "switching folder to $ROOT .."
27 | cd $WORKDIR/$ROOT
28 |
29 | echo "Publishing $NAME component .."
30 | gdk component publish
31 | echo "Done."
32 |
33 | ROOT=""
34 | NAME=""
35 | fi
36 |
37 | done < $CONFIG_FILE
38 |
39 | cd $WORKDIR
40 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/model/compile/custom-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | COMPONENT_NAME=$1
3 |
4 | if [ $# -ne 1 ]; then
5 | echo 1>&2 "Usage: $0 COMPONENT-NAME"
6 | exit 3
7 | fi
8 |
9 | echo "Installing libraries for build"
10 | conda create -y -q \
11 | -n $COMPONENT_NAME \
12 | python=3.10
13 |
14 | conda run -n $COMPONENT_NAME \
15 | pip install --no-cache-dir \
16 | xgboost \
17 | onnx \
18 | onnxmltools \
19 | onnxconverter_common \
20 | protobuf \
21 | skl2onnx
22 |
23 | VERSION=$(jq -r '.component."'"$COMPONENT_NAME"'".version' gdk-config.json)
24 | echo "Building version $VERSION of $COMPONENT_NAME"
25 |
26 | rm -rf ./greengrass-build
27 | mkdir -p ./greengrass-build/recipes
28 | mkdir -p ./greengrass-build/artifacts
29 |
30 | # copy recipe to greengrass-build
31 | cp recipe.json ./greengrass-build/recipes
32 |
33 | # create custom build directory
34 | rm -rf ./custom-build
35 | mkdir -p ./custom-build/$COMPONENT_NAME
36 |
37 | conda run --name $COMPONENT_NAME \
38 | python ./compile/onnx_converter.py \
39 | --input . \
40 | --output ./custom-build/$COMPONENT_NAME
41 |
42 | # copy archive to greengrass-build
43 | mkdir -p ./greengrass-build/artifacts/$COMPONENT_NAME/$VERSION/
44 | cp ./custom-build/$COMPONENT_NAME/* ./greengrass-build/artifacts/$COMPONENT_NAME/$VERSION/
45 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/python-dependencies/package/custom-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | APP_DIR=$1
3 | COMPONENT_NAME=$2
4 |
5 | if [ $# -ne 2 ]; then
6 | echo 1>&2 "Usage: $0 APP_DIR COMPONENT_NAME"
7 | exit 3
8 | fi
9 |
10 | export PYTHON_VERSION="3.10"
11 | echo "Packaging Python dependencies for edge runtime"
12 | echo "Using Python version ${PYTHON_VERSION}"
13 | conda create -y -q \
14 | -n $COMPONENT_NAME \
15 | python=$PYTHON_VERSION
16 |
17 | # get component version
18 | VERSION=$(jq -r '.component."'"$COMPONENT_NAME"'".version' gdk-config.json)
19 | echo "Building version $VERSION of $COMPONENT_NAME"
20 |
21 | # create recipes and artifacts folders
22 | mkdir -p ./greengrass-build/recipes
23 | mkdir -p ./greengrass-build/artifacts
24 |
25 | # copy recipe to greengrass-build
26 | cp recipe.json ./greengrass-build/recipes
27 |
28 | # create custom build directory
29 | mkdir -p ./custom-build/python-dependencies
30 | conda run -n $COMPONENT_NAME pip download -r ../$APP_DIR/requirements.txt -d ./custom-build/python-dependencies
31 |
32 | cd custom-build/python-dependencies
33 | zip -rm -X ../python-dependencies.zip *
34 | cd ../..
35 |
36 | # copy archive to greengrass-build
37 | mkdir -p ./greengrass-build/artifacts/$COMPONENT_NAME/$VERSION/
38 | cp ./custom-build/python-dependencies.zip ./greengrass-build/artifacts/$COMPONENT_NAME/$VERSION/
39 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/mlops_sm_project_template/templates/train_deploy_iot_product/seed_code/deploy_app/requirements.txt:
--------------------------------------------------------------------------------
1 | sagemaker
2 | s3fs
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pytest==6.2.5
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/requirements.txt:
--------------------------------------------------------------------------------
1 | aws-cdk-lib
2 | awscli
3 | boto3
4 | constructs
5 |
6 | jupyter
7 | pre-commit
8 | yamldataclassconfig
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/source.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | rem The sole purpose of this script is to make the command
4 | rem
5 | rem source .venv/bin/activate
6 | rem
7 | rem (which activates a Python virtualenv on Linux or Mac OS X) work on Windows.
8 | rem On Windows, this command just runs this batch file (the argument is ignored).
9 | rem
10 | rem Now we don't need to document a Windows command for activating a virtualenv.
11 |
12 | echo Executing .venv\Scripts\activate.bat for you
13 | .venv\Scripts\activate.bat
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/mlops-sm-project-template/tests/unit/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | #
3 | # SPDX-License-Identifier: MIT-0
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | # software and associated documentation files (the "Software"), to deal in the Software
7 | # without restriction, including without limitation the rights to use, copy, modify,
8 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | # permit persons to whom the Software is furnished to do so.
10 | #
11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/scripts/cdk-bootstrap-accounts.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This script setups the aws accounts with the required permissions for CDK deployments, the accounts are bootstrapped
3 | # and configured to enable cross account access as per the architecture diagram
4 |
5 | SCRIPT=$(readlink -f "$0")
6 | SCRIPT_PATH=$(dirname "$SCRIPT")
7 |
8 | bootstrap_conf_file="$SCRIPT_PATH/bootstrap_conf.tmp"
9 |
10 | read -r -p 'Have you already created AWS profiles for all accounts that you would like to bootstrap (they should match the names found in bootstrap_conf.tmp - See README) [y/n]:' env_choice
11 |
12 | if [[ "$env_choice" != "y" ]];then
13 | echo "Please create AWS profiles first and rerun this command"
14 | exit
15 | fi
16 |
17 | while read -r line; do
18 |
19 | parts=(${line//#/ })
20 |
21 | account="${parts[0]}"
22 | region="${parts[1]}"
23 | profile="${parts[2]}"
24 | trust_accounts="${parts[3]}"
25 |
26 | if [[ "$trust_accounts" != "" ]];then
27 | echo "Executing command cdk bootstrap aws://$account/$region --trust $trust_accounts --profile $profile"
28 | cdk bootstrap aws://$account/$region --trust $trust_accounts --profile $profile
29 | else
30 | echo "Executing command cdk bootstrap aws://$account/$region --profile $profile"
31 | cdk bootstrap aws://$account/$region --profile $profile
32 | fi
33 |
34 | done < "$bootstrap_conf_file"
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/scripts/install-prerequisites-brew.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # this script uses Homebrew to do the installations for all prerequisites to deploy the solution described in this repository
3 |
4 | # install miniconda to manage python packages
5 | brew install --cask miniconda
6 |
7 | # install nodejs (required for aws cdk)
8 | brew install node
9 |
10 | # install docker (mainly to handle bundling CDK assets)
11 | brew install --cask docker
12 |
13 | # install aws cdk
14 | npm install -g aws-cdk
15 |
16 | # setup python environment
17 | conda create -n cdk-env python=3.11
18 | conda activate cdk-env
19 |
20 | # install aws cli in the python environment
21 | pip install awscli
22 |
23 | # now you should have all the necessary packages setup on your machines and should proceed with creating the aws profiles to start setting up the accounts and deploying the solution
24 |
--------------------------------------------------------------------------------
/mlops-multi-account-cdk/scripts/quick-start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # this script uses Homebrew to do the installations for all prerequisites to deploy the solution described in this repository
3 |
4 | SCRIPT=$(readlink -f "$0")
5 | SCRIPT_PATH=$(dirname "$SCRIPT")
6 |
7 | main() {
8 |
9 |
10 | cmd="$1"
11 |
12 | case $cmd in
13 | prerequisites)
14 | echo "Start installing prerequisites like environments and dependencies"
15 | "$SCRIPT_PATH"/install-prerequisites-brew.sh
16 | ;;
17 | config)
18 | echo "Start updating config files with user inputs"
19 | "$SCRIPT_PATH"/create-config-files.sh
20 | ;;
21 | bootstrap)
22 | echo "Start bootstrapping Aws accounts"
23 | "$SCRIPT_PATH"/cdk-bootstrap-accounts.sh
24 | ;;
25 | *) echo "Not supported command : $cmd!!!, Supported commands : [prerequisites, config, bootstrap]"
26 | esac
27 | }
28 |
29 | main "$@"
30 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/LICENSE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/architecture/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/architecture/architecture.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/architecture/base-infra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/architecture/base-infra.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/architecture/project-list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/architecture/project-list.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/architecture/template-repos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/architecture/template-repos.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/architecture/user-exp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/architecture/user-exp.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/.gitignore:
--------------------------------------------------------------------------------
1 | *.egg-info
2 | .cache
3 | .coverage
4 | .tox
5 | __pycache__
6 | .sagemaker-code-config
7 | .DS_Store
8 | .terraform
9 | .vscode
10 | *.tfstate
11 | *.tfstate.backup
12 | *terraform.tfstate*
13 | *.out
14 | .terraform.lock.hcl
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | default_stages: [commit]
2 | repos:
3 | - repo: https://github.com/pre-commit/pre-commit-hooks
4 | rev: v4.2.0
5 | hooks:
6 | - id: trailing-whitespace
7 | - id: check-merge-conflict
8 | - id: end-of-file-fixer
9 | - id: check-added-large-files
10 | - repo: https://github.com/psf/black
11 | rev: stable
12 | hooks:
13 | - id: black # pip install black
14 | language_version: python3.8
15 | args: ["-l", "100"]
16 | - repo: https://github.com/antonbabenko/pre-commit-terraform
17 | rev: v1.77.0
18 | hooks:
19 | - id: terraform_fmt
20 | - id: terraform_docs
21 | args:
22 | - --hook-config=--create-file-if-not-exist=true
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "business_unit_1": {
3 | "region": "eu-west-1",
4 | "dev_account_number": "111",
5 | "preprod_account_number": "222",
6 | "prod_account_number": "333"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/README.md:
--------------------------------------------------------------------------------
1 | # Terraform
2 |
3 | - `account_config`: Variables for environments accounts.
4 | - `modules`: Shared Terraform modules used for infrastructure deployment into dev, preprod, and prod.
5 | - `dev`, `preprod`, and `prod`: Terraform infrastructure deployed to each of the environments. Some modules are shared across the three.
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/account_config/dev/data_scientist.yml:
--------------------------------------------------------------------------------
1 | prefix: "ds"
2 | users:
3 | - user_profile_name: "data-scientist"
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/account_config/dev/lead_data_scientist.yml:
--------------------------------------------------------------------------------
1 | prefix: "lead-ds"
2 | users:
3 | - user_profile_name: "lead-data-scientist"
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/account_config/dev/terraform.tfvars:
--------------------------------------------------------------------------------
1 | environment = "dev"
2 | s3_bucket_prefix = "mlops"
3 | prefix = "mlops"
4 | github_organization = "sagemaker-mlops-terraform"
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/account_config/preprod/terraform.tfvars:
--------------------------------------------------------------------------------
1 | environment = "preprod"
2 | s3_bucket_prefix = "mlops"
3 | prefix = "mlops"
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/account_config/prod/terraform.tfvars:
--------------------------------------------------------------------------------
1 | environment = "prod"
2 | s3_bucket_prefix = "mlops"
3 | prefix = "mlops"
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/create_documentation.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | terraform-docs -c .terraform-docs.yml modules/kms
4 | terraform-docs -c .terraform-docs.yml modules/lambda
5 | terraform-docs -c .terraform-docs.yml modules/networking
6 | terraform-docs -c .terraform-docs.yml modules/s3
7 | terraform-docs -c .terraform-docs.yml modules/sagemaker
8 | terraform-docs -c .terraform-docs.yml modules/sagemaker_roles
9 | terraform-docs -c .terraform-docs.yml dev/
10 | terraform-docs -c .terraform-docs.yml preprod/
11 | terraform-docs -c .terraform-docs.yml prod/
12 |
13 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/lambdas/functions/clone_repo_lambda/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/lambdas/functions/trigger_workflow_lambda/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/lambdas/layers/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export PYTHON_VERSION="3.11"
3 |
4 | #Init Packages Directory
5 | mkdir -p packages/
6 |
7 | # For each folder in lambda-layers
8 | for layer in layers/*/ ; do
9 | echo "Processing: ${layer}"
10 | echo
11 |
12 | # Install requriements in a directory layer-name/pacakge/python/*
13 | docker run --rm -v "${PWD}":/var/task "public.ecr.aws/sam/build-python${PYTHON_VERSION}" \
14 | /bin/sh -c "pip install -r ${layer}requirements.txt -t ${layer}package/python/lib/python${PYTHON_VERSION}/site-packages/; exit"
15 |
16 | # Zip
17 | cd ${layer}package/
18 | ZIP_NAME=$(echo "${layer}" | awk -F "/" '{print $2}') # folder name
19 | zip -qr ../../../packages/${ZIP_NAME}.zip .
20 | cd ../../.. # clean up
21 | done
22 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/lambdas/layers/layers/python_github/requirements.txt:
--------------------------------------------------------------------------------
1 | PyGithub==2.1.1
2 | requests
3 | urllib3>=1.26.0,<2.0
4 | botocore
5 | charset-normalizer<4,>=2
6 | certifi>=2017.4.17
7 | idna
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/locals.tf:
--------------------------------------------------------------------------------
1 | data "aws_caller_identity" "current" {}
2 | data "aws_region" "current" {}
3 |
4 | locals {
5 | account_id = data.aws_caller_identity.current.account_id
6 | aws_region = data.aws_region.current.name
7 | }
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/variables.tf:
--------------------------------------------------------------------------------
1 | variable "environment" {
2 | description = "Environment"
3 | type = string
4 | }
5 | variable "region" {
6 | description = "AWS Region"
7 | type = string
8 | }
9 | variable "preprod_account_number" {
10 | description = "Prepod account number"
11 | type = string
12 | }
13 | variable "prod_account_number" {
14 | description = "Prod account number"
15 | type = string
16 | }
17 | variable "s3_bucket_prefix" {
18 | description = "S3 bucket where data are stored"
19 | type = string
20 | }
21 | variable "prefix" {
22 | description = "Lambda function name prefix for Lambda functions"
23 | }
24 |
25 | variable "pat_github" {
26 | description = "Github Personal access token"
27 | sensitive = true
28 | }
29 |
30 | variable "github_organization" {
31 | description = "Name Github Organization"
32 | type = string
33 | }
34 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/dev/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/kms/main.tf:
--------------------------------------------------------------------------------
1 | resource "aws_kms_key" "key" {
2 | description = var.description
3 | enable_key_rotation = true
4 | policy = data.aws_iam_policy_document.key_policy.json
5 | }
6 |
7 | data "aws_iam_policy_document" "key_policy" {
8 | # checkov:skip=CKV_AWS_109:Key needs to be manageable by the Account root
9 | # checkov:skip=CKV_AWS_111:Key policies are already scoped to the key
10 | statement {
11 | principals {
12 | type = "AWS"
13 | identifiers = var.trusted_accounts_for_decrypt_access
14 | }
15 |
16 | actions = [
17 | "kms:Decrypt",
18 | ]
19 |
20 | resources = [
21 | "*"
22 | ]
23 | }
24 | statement {
25 | principals {
26 | type = "AWS"
27 | identifiers = [var.account_id]
28 | }
29 |
30 | actions = [
31 | "kms:*",
32 | ]
33 |
34 | resources = [
35 | "*"
36 | ]
37 | }
38 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/kms/outputs.tf:
--------------------------------------------------------------------------------
1 | output "key_arn" {
2 | value = aws_kms_key.key.arn
3 | }
4 |
5 | output "key_id" {
6 | value = aws_kms_key.key.id
7 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/kms/ssm.tf:
--------------------------------------------------------------------------------
1 | resource "aws_ssm_parameter" "kms_key" {
2 | # checkov:skip=CKV2_AWS_34:SSM params should be encrypted
3 | name = "/kms/key_arn"
4 | type = "String"
5 | value = aws_kms_key.key.arn
6 | overwrite = true
7 | }
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/kms/variables.tf:
--------------------------------------------------------------------------------
1 | variable "description" {
2 | type = string
3 | description = "Description of KMS key"
4 | default = "KMS Key for Machine Learning workloads."
5 | }
6 |
7 | # Cross Account Read
8 | variable "trusted_accounts_for_decrypt_access" {
9 | description = "List of AWS account numbers that read ML artifacts from the bucket"
10 | type = list(string)
11 | default = []
12 | }
13 |
14 | variable "account_id" {
15 | description = "AWS account ID"
16 | type = string
17 | }
18 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/lambda/main.tf:
--------------------------------------------------------------------------------
1 | #################################
2 | # Creates Lambda function
3 | #################################
4 |
5 | resource "aws_lambda_function" "lambda" {
6 | filename = var.filename
7 | description = var.description
8 | function_name = var.function_name
9 | role = var.role
10 | handler = var.handler
11 | timeout = var.timeout
12 | runtime = var.runtime
13 | layers = var.layers
14 | reserved_concurrent_executions = var.reserved_concurrent_executions
15 | source_code_hash = var.source_code_hash
16 | tracing_config {
17 | mode = "Active"
18 | }
19 | environment {
20 | variables = var.variables
21 | }
22 | vpc_config {
23 | subnet_ids = var.subnets_ids
24 | security_group_ids = var.security_groups
25 | }
26 | }
27 |
28 | #################################
29 | # Create Cloudwatch group for the lambda
30 | #################################
31 | resource "aws_cloudwatch_log_group" "log_group" {
32 | name = "/aws/lambda/${var.function_name}"
33 | retention_in_days = 365
34 | }
35 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/lambda/outputs.tf:
--------------------------------------------------------------------------------
1 | output "lambda_arn" {
2 | description = "The arn of the Lambda function"
3 | value = aws_lambda_function.lambda.arn
4 | }
5 |
6 | output "lambda_name" {
7 | description = "The name of the Lambda function"
8 | value = aws_lambda_function.lambda.function_name
9 | }
10 |
11 | output "log_name" {
12 | description = "The Cloudwatch log group name"
13 | value = aws_cloudwatch_log_group.log_group.name
14 | }
15 |
16 | output "log_arn" {
17 | description = "The Cloudwatch log group arn"
18 | value = aws_cloudwatch_log_group.log_group.arn
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/lambda/variables.tf:
--------------------------------------------------------------------------------
1 | variable "role" {}
2 |
3 | variable "description" {}
4 |
5 | variable "subnets_ids" {}
6 |
7 | variable "security_groups" {}
8 |
9 | variable "variables" {}
10 |
11 | variable "timeout" {}
12 |
13 | variable "filename" {}
14 |
15 | variable "function_name" {}
16 |
17 | variable "handler" {}
18 |
19 | variable "runtime" {}
20 |
21 | variable "layers" {}
22 |
23 | variable "source_code_hash" {}
24 |
25 | variable "reserved_concurrent_executions" {}
26 |
27 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/cloudwatch.tf:
--------------------------------------------------------------------------------
1 | resource "aws_iam_role" "vpc_flow_logs_role" {
2 | name = "vpc-flow-logs-role"
3 |
4 | assume_role_policy = jsonencode({
5 | Version = "2012-10-17",
6 | Statement = [{
7 | Action = "sts:AssumeRole",
8 | Effect = "Allow",
9 | Principal = {
10 | Service = "vpc-flow-logs.amazonaws.com"
11 | }
12 | }]
13 | })
14 | }
15 |
16 | resource "aws_iam_policy" "vpc_flow_logs_policy" {
17 | name = "vpc-flow-logs-policy"
18 |
19 | policy = jsonencode({
20 | Version = "2012-10-17",
21 | Statement = [{
22 | Action = [
23 | "logs:CreateLogGroup",
24 | "logs:CreateLogStream",
25 | "logs:PutLogEvents",
26 | "logs:DescribeLogGroups",
27 | "logs:DescribeLogStreams"
28 | ],
29 | Effect = "Allow",
30 | Resource = "*"
31 | }]
32 | })
33 | }
34 |
35 | resource "aws_iam_role_policy_attachment" "vpc_flow_logs_policy_attachment" {
36 | policy_arn = aws_iam_policy.vpc_flow_logs_policy.arn
37 | role = aws_iam_role.vpc_flow_logs_role.name
38 | }
39 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/outputs.tf:
--------------------------------------------------------------------------------
1 | output "sg_id" {
2 | value = aws_security_group.main.id
3 | }
4 | output "vpc_id" {
5 | value = aws_vpc.main.id
6 | }
7 | output "private_subnet_id" {
8 | value = aws_subnet.private.id
9 | }
10 |
11 | output "private_subnet_2_id" {
12 | value = aws_subnet.private_2.id
13 | }
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/secure-networking.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/secure-networking.jpg
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/ssm.tf:
--------------------------------------------------------------------------------
1 | resource "aws_ssm_parameter" "private_subnet_id" {
2 | name = "private-subnets-ids"
3 | type = "StringList"
4 | value = join(",", [aws_subnet.private.id, aws_subnet.private_2.id])
5 | }
6 |
7 | resource "aws_ssm_parameter" "sg_id" {
8 | name = "sagemaker-domain-sg"
9 | type = "String"
10 | value = aws_security_group.main.id
11 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/networking/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | description = "Region"
3 | type = string
4 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/s3/outputs.tf:
--------------------------------------------------------------------------------
1 | output "bucket_id" {
2 | description = "The name of the bucket."
3 | value = aws_s3_bucket.bucket.id
4 | }
5 |
6 | output "bucket_arn" {
7 | description = "The ARN of the bucket. Will be of format arn:aws:s3:::bucketname."
8 | value = aws_s3_bucket.bucket.arn
9 | }
10 |
11 | output "s3_bucket_region" {
12 | description = "The AWS region this bucket resides in."
13 | value = aws_s3_bucket.bucket.region
14 | }
15 |
16 | output "s3_bucket_domain_name" {
17 | description = "The AWS region this bucket resides in."
18 | value = aws_s3_bucket.bucket.bucket_domain_name
19 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker/outputs.tf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker/outputs.tf
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker/ssm.tf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker/ssm.tf
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker/variables.tf:
--------------------------------------------------------------------------------
1 | variable "studio_domain_name" {
2 | type = string
3 | description = "Name to assign to the SageMaker Studio domain"
4 | default = "studio-domain"
5 | }
6 |
7 | variable "vpc_id" {
8 | type = string
9 | description = "VPC ID where to deploy SageMaker Studio"
10 | }
11 |
12 | variable "private_subnet_id" {
13 | type = string
14 | description = "Private subnet id"
15 | }
16 |
17 | variable "private_subnet_id_2" {
18 | type = string
19 | description = "Private subnet id"
20 | }
21 |
22 |
23 | variable "sg_id" {
24 | type = string
25 | description = "Security group id"
26 | }
27 |
28 | variable "sm_studio_role_arn" {
29 | type = string
30 | description = "SageMaker Studio ARN"
31 | }
32 |
33 | variable "data_scientist_execution_role_arn" {
34 | type = string
35 | description = "Data Scientist role ARN"
36 | }
37 |
38 | variable "lead_data_scientist_execution_role_arn" {
39 | type = string
40 | description = "Lead Data Scientist role ARN"
41 | }
42 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker_roles/data.tf:
--------------------------------------------------------------------------------
1 | data "aws_iam_policy" "AmazonSSMReadOnlyAccess" {
2 | arn = "arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess"
3 | }
4 | data "aws_iam_policy" "AWSLambda_ReadOnlyAccess" {
5 | arn = "arn:aws:iam::aws:policy/AWSLambda_ReadOnlyAccess"
6 | }
7 | data "aws_iam_policy" "AWSCodeCommitReadOnly" {
8 | arn = "arn:aws:iam::aws:policy/AWSCodeCommitReadOnly"
9 | }
10 | data "aws_iam_policy" "AmazonEC2ContainerRegistryReadOnly" {
11 | arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
12 | }
13 | data "aws_iam_policy" "AmazonSageMakerFullAccess" {
14 | arn = "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
15 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker_roles/outputs.tf:
--------------------------------------------------------------------------------
1 | output "data_scientist_role_arn" {
2 | value = aws_iam_role.data_scientist_role.arn
3 | }
4 | output "lead_data_scientist_role_arn" {
5 | value = aws_iam_role.lead_data_scientist_role.arn
6 | }
7 | output "sagemaker_studio_role_arn" {
8 | value = aws_iam_role.sagemaker_studio_role.arn
9 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker_roles/ssm.tf:
--------------------------------------------------------------------------------
1 | resource "aws_ssm_parameter" "ssm_sg_ds_role" {
2 | name = "/mlops/role/ds"
3 | type = "String"
4 | value = aws_iam_role.data_scientist_role.arn
5 | }
6 | resource "aws_ssm_parameter" "ssm_sg_lead_role" {
7 | name = "/mlops/role/lead"
8 | type = "String"
9 | value = aws_iam_role.lead_data_scientist_role.arn
10 | }
11 | resource "aws_ssm_parameter" "ssm_sg_execution_role" {
12 | name = "/mlops/role/execution"
13 | type = "String"
14 | value = aws_iam_role.sagemaker_studio_role.arn
15 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/sagemaker_roles/variables.tf:
--------------------------------------------------------------------------------
1 | variable "s3_bucket_prefix" {
2 | type = string
3 | description = "S3 bucket where data are stored"
4 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/service_catalog/outputs.tf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/base-infrastructure/terraform/modules/service_catalog/outputs.tf
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/modules/service_catalog/vars.tf:
--------------------------------------------------------------------------------
1 | variable "environment" {
2 | type = string
3 | description = "Environment"
4 | }
5 | variable "bucket_id" {
6 | type = string
7 | description = "Bucket ID with Sagemaker Templates"
8 | }
9 | variable "bucket_domain_name" {
10 | type = string
11 | description = "The AWS region this bucket resides in"
12 | }
13 | variable "lead_data_scientist_execution_role_arn" {
14 | type = string
15 | description = "Lead Data Scientist role ARN"
16 | }
17 | variable "launch_role" {
18 | type = string
19 | description = "Launch Role ARN"
20 | }
21 | variable "templates" {
22 | type = map(object({
23 | name = string
24 | file = string
25 | description = string
26 | }))
27 | description = "List of template files"
28 | }
29 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/locals.tf:
--------------------------------------------------------------------------------
1 | data "aws_caller_identity" "current" {}
2 | data "aws_region" "current" {}
3 |
4 | locals {
5 | account_id = data.aws_caller_identity.current.account_id
6 | aws_region = data.aws_region.current.name
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/main.tf:
--------------------------------------------------------------------------------
1 | module "sagemaker_projects_bucket" {
2 | source = "../modules/s3"
3 | s3_bucket_name = "ml-artifacts-${local.aws_region}-${local.account_id}"
4 | s3_bucket_force_destroy = "false"
5 | versioning = "Enabled"
6 | s3_bucket_policy = data.aws_iam_policy_document.s3_projects_bucket_policy.json
7 | }
8 |
9 |
10 | module "kms" {
11 | source = "../modules/kms"
12 | trusted_accounts_for_decrypt_access = [var.preprod_account_number, var.prod_account_number]
13 | account_id = local.account_id
14 | }
15 |
16 | # Networking resources (VPC, endpoints)
17 | module "networking" {
18 | source = "../modules/networking"
19 | region = var.region
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/s3.tf:
--------------------------------------------------------------------------------
1 | # Creates policy document s3 projects buckets
2 | data "aws_iam_policy_document" "s3_projects_bucket_policy" {
3 | statement {
4 | sid = "DenyUnEncryptedObjectTransfers"
5 | effect = "Deny"
6 | resources = ["arn:aws:s3:::${module.sagemaker_projects_bucket.bucket_id}/*"]
7 | actions = ["s3:*"]
8 | condition {
9 | test = "Bool"
10 | variable = "aws:SecureTransport"
11 | values = ["false"]
12 | }
13 |
14 | principals {
15 | type = "*"
16 | identifiers = ["*"]
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/ssm.tf:
--------------------------------------------------------------------------------
1 | #S3 bucket for storing ML models
2 | resource "aws_ssm_parameter" "s3_artifacts_buckets" {
3 | name = "/${var.environment}/sagemaker_ml_artifacts_s3_bucket"
4 | description = "S3 ml artifacts"
5 | type = "String"
6 | overwrite = true
7 | value = module.sagemaker_projects_bucket.bucket_id
8 | }
9 |
10 | #Role for executing Sagemaker deployment
11 | resource "aws_ssm_parameter" "sagemaker_role_arn" {
12 | name = "/${var.environment}/sagemaker_role_arn"
13 | description = "Role for SM deployments"
14 | type = "String"
15 | overwrite = true
16 | value = aws_iam_role.sagemaker_execution_role.arn
17 | }
18 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/variables.tf:
--------------------------------------------------------------------------------
1 | variable "environment" {
2 | description = "Environment"
3 | type = string
4 | }
5 | variable "region" {
6 | description = "AWS Region"
7 | type = string
8 | }
9 | variable "preprod_account_number" {
10 | description = "Prepod account number"
11 | type = string
12 | }
13 | variable "prod_account_number" {
14 | description = "Prod account number"
15 | type = string
16 | }
17 | variable "s3_bucket_prefix" {
18 | description = "S3 bucket where data are stored"
19 | type = string
20 | }
21 | variable "prefix" {
22 | description = "Lambda function name prefix for Lambda functions"
23 | }
24 | variable "pat_github" {
25 | description = "Github Personal access token"
26 | sensitive = true
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/preprod/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/locals.tf:
--------------------------------------------------------------------------------
1 | data "aws_caller_identity" "current" {}
2 | data "aws_region" "current" {}
3 |
4 | locals {
5 | account_id = data.aws_caller_identity.current.account_id
6 | aws_region = data.aws_region.current.name
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/main.tf:
--------------------------------------------------------------------------------
1 | module "sagemaker_projects_bucket" {
2 | source = "../modules/s3"
3 | s3_bucket_name = "ml-artifacts-${local.aws_region}-${local.account_id}"
4 | s3_bucket_force_destroy = "false"
5 | versioning = "Enabled"
6 | s3_bucket_policy = data.aws_iam_policy_document.s3_projects_bucket_policy.json
7 | }
8 |
9 |
10 | module "kms" {
11 | source = "../modules/kms"
12 | trusted_accounts_for_decrypt_access = [var.preprod_account_number, var.prod_account_number]
13 | account_id = local.account_id
14 | }
15 |
16 | # Networking ressources (VPC, endpoints)
17 | module "networking" {
18 | source = "../modules/networking"
19 | region = var.region
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/s3.tf:
--------------------------------------------------------------------------------
1 | # Creates policy document s3 projects buckets
2 | data "aws_iam_policy_document" "s3_projects_bucket_policy" {
3 | statement {
4 | sid = "DenyUnEncryptedObjectTransfers"
5 | effect = "Deny"
6 | resources = ["arn:aws:s3:::${module.sagemaker_projects_bucket.bucket_id}/*"]
7 | actions = ["s3:*"]
8 | condition {
9 | test = "Bool"
10 | variable = "aws:SecureTransport"
11 | values = ["false"]
12 | }
13 |
14 | principals {
15 | type = "*"
16 | identifiers = ["*"]
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/ssm.tf:
--------------------------------------------------------------------------------
1 | #S3 bucket for storing ML models
2 | resource "aws_ssm_parameter" "s3_artifacts_buckets" {
3 | name = "/${var.environment}/sagemaker_ml_artifacts_s3_bucket"
4 | description = "S3 ml artifacts"
5 | type = "String"
6 | overwrite = true
7 | value = module.sagemaker_projects_bucket.bucket_id
8 | }
9 |
10 | #Role for executing Sagemaker deployment
11 | resource "aws_ssm_parameter" "sagemaker_role_arn" {
12 | name = "/${var.environment}/sagemaker_role_arn"
13 | description = "Role for SM deployments"
14 | type = "String"
15 | overwrite = true
16 | value = aws_iam_role.sagemaker_execution_role.arn
17 | }
18 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/variables.tf:
--------------------------------------------------------------------------------
1 | variable "environment" {
2 | description = "Environment"
3 | type = string
4 | }
5 | variable "region" {
6 | description = "AWS Region"
7 | type = string
8 | }
9 | variable "preprod_account_number" {
10 | description = "Prepod account number"
11 | type = string
12 | }
13 | variable "prod_account_number" {
14 | description = "Prod account number"
15 | type = string
16 | }
17 | variable "s3_bucket_prefix" {
18 | description = "S3 bucket where data are stored"
19 | type = string
20 | }
21 | variable "prefix" {
22 | description = "Lambda function name prefix for Lambda functions"
23 | }
24 | variable "pat_github" {
25 | description = "Github Personal access token"
26 | sensitive = true
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/base-infrastructure/terraform/prod/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/README.md:
--------------------------------------------------------------------------------
1 | # Template Repos
2 |
3 | The seed code for GitHub template repositories. Make sure you have a template for each of the 5 repos here in your GitHub Organization.
4 |
5 |
6 |
7 | Templates:
8 |
9 | 1. [model-training](./model-training/):
10 | 2. [model-deployment-realtime](./model-deployment-realtime/)
11 | 3. [model-deployment-batch](./model-deployment-batch/)
12 | 4. [container-build](./container-build/)
13 | 5. [pipeline-promotion](./pipeline-promotion/)
14 | 6. [llm-training](./llm-training/)
15 |
16 | > **_Note:_** Make sure to mark these repositories as a template on GitHub in the repository settings.
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/.gitignore:
--------------------------------------------------------------------------------
1 | # Local .terraform directories
2 | **/.terraform/*
3 |
4 | # .tfstate files
5 | *.tfstate
6 | *.tfstate.*
7 |
8 | # Crash log files
9 | crash.log
10 |
11 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12 | # .tfvars files are managed as part of configuration and so should be included in
13 | # version control.
14 | #
15 | # example.tfvars
16 |
17 | # Ignore override files as they are usually used to override resources locally and so
18 | # are not checked in
19 | override.tf
20 | override.tf.json
21 | *_override.tf
22 | *_override.tf.json
23 |
24 | # Include override files you do wish to add to version control using negated pattern
25 | #
26 | # !example_override.tf
27 |
28 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
29 | # example: *tfplan*
30 |
31 | .idea
32 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/endpoint/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG ECR_ENDPOINT
2 | ARG XGBOOST_LATEST_VERSION
3 | FROM $ECR_ENDPOINT/sagemaker-xgboost:$XGBOOST_LATEST_VERSION
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/endpoint/xgboost-0.90-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "eu-west-2": "764974769150.dkr.ecr.eu-west-2.amazonaws.com",
4 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
5 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/endpoint/xgboost-1.0-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
4 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/img/byoc_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/container-build/img/byoc_architecture.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/processing/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG ECR_ENDPOINT
2 | ARG XGBOOST_LATEST_VERSION
3 | FROM $ECR_ENDPOINT/sagemaker-xgboost:$XGBOOST_LATEST_VERSION
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/processing/xgboost-0.90-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "eu-west-2": "764974769150.dkr.ecr.eu-west-2.amazonaws.com",
4 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
5 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/processing/xgboost-1.0-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
4 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/training/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG ECR_ENDPOINT
2 | ARG XGBOOST_LATEST_VERSION
3 | FROM $ECR_ENDPOINT/sagemaker-xgboost:$XGBOOST_LATEST_VERSION
4 | COPY . .
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/training/xgboost-0.90-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "eu-west-2": "764974769150.dkr.ecr.eu-west-2.amazonaws.com",
4 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
5 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/container-build/training/xgboost-1.0-1-cpu-py3.json:
--------------------------------------------------------------------------------
1 | {
2 | "eu-west-1": "141502667606.dkr.ecr.eu-west-1.amazonaws.com",
3 | "us-east-1": "683313688378.dkr.ecr.us-east-1.amazonaws.com"
4 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | .DS_Store
3 | .conda
4 | .vnv
5 | .idea
6 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/LICENSE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/datasets/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "prompt": "{question}",
3 | "completion": "{answer}"
4 | }
5 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/local-requirements.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker
5 | pandas
6 | gevent
7 | geventhttpclient
8 | Markdown
9 | fmeval
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/.ipynb_checkpoints/README-checkpoint.md:
--------------------------------------------------------------------------------
1 | This example shows how to structure a Python workspace in modular way for building a SageMaker Pipeline with
2 | data preprocessing, training, evaluation, registry steps.
3 |
4 | Notes:
5 | - This example can only run on either Python 3.8 or Python 3.10.
6 | Otherwise, you will get an error message prompting you to provide an image_uri when defining a step.
7 | - Please update your configurations, e.g. RoleArn, in the `config.yaml` if needed.
8 |
9 | ## Run the example
10 | Run all the cells of runme.ipynb
11 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/.ipynb_checkpoints/config-checkpoint.yaml:
--------------------------------------------------------------------------------
1 | SchemaVersion: '1.0'
2 | SageMaker:
3 | PythonSDK:
4 | Modules:
5 | RemoteFunction:
6 | # role arn is not required if in SageMaker Notebook instance or SageMaker Studio
7 | # Uncomment the following line and replace with the right execution role if in a local IDE
8 | # RoleArn: arn:aws:iam::<...>:role/service-role/AmazonSageMaker-ExecutionRole-<...> # replace it with your role
9 | InstanceType: ml.m5.xlarge
10 | Dependencies: ./requirements.txt
11 | IncludeLocalWorkDir: true
12 | CustomFileFilter:
13 | IgnoreNamePatterns: # files or directories to ignore
14 | - "*.ipynb" # all notebook files
15 | - "__pycache__"
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/.ipynb_checkpoints/local-requirements-checkpoint.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker.tar.gz
5 | pandas
6 | gevent
7 | geventhttpclient
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/.ipynb_checkpoints/requirements-checkpoint.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker_remote_function_workspace/sagemaker.tar.gz
5 | pandas
6 | gevent
7 | geventhttpclient
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/README.md:
--------------------------------------------------------------------------------
1 | This example shows how to structure a Python workspace in modular way for building a SageMaker Pipeline with
2 | data preprocessing, training, evaluation, registry steps.
3 |
4 | Notes:
5 | - This example can only run on either Python 3.8 or Python 3.10.
6 | Otherwise, you will get an error message prompting you to provide an image_uri when defining a step.
7 | - Please update your configurations, e.g. RoleArn, in the `config.yaml` if needed.
8 |
9 | ## Run the example
10 | Run all the cells of runme.ipynb
11 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/config.yaml:
--------------------------------------------------------------------------------
1 | SchemaVersion: '1.0'
2 | SageMaker:
3 | PythonSDK:
4 | Modules:
5 | RemoteFunction:
6 | # role arn is not required if in SageMaker Notebook instance or SageMaker Studio
7 | # Uncomment the following line and replace with the right execution role if in a local IDE
8 | # RoleArn: arn:aws:iam::<...>:role/service-role/AmazonSageMaker-ExecutionRole-<...> # replace it with your role
9 | InstanceType: ml.m5.xlarge
10 | Dependencies: ./requirements.txt
11 | IncludeLocalWorkDir: true
12 | CustomFileFilter:
13 | IgnoreNamePatterns: # files or directories to ignore
14 | - "*.ipynb" # all notebook files
15 | - "__pycache__"
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/img/sm-pipeline-execution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/img/sm-pipeline-execution.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/local-requirements.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker.tar.gz
5 | pandas
6 | gevent
7 | geventhttpclient
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/requirements.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker_remote_function_workspace/sagemaker.tar.gz
5 | pandas
6 | gevent
7 | geventhttpclient
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/sagemaker.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/sagemaker.tar.gz
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/steps/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/steps/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/notebooks/sm_pipeline_basic_example/steps/evaluation.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import xgboost
3 |
4 | from sklearn.metrics import mean_squared_error
5 |
6 |
7 | def evaluate(model, test_df):
8 | y_test = test_df.iloc[:, 0].to_numpy()
9 | test_df.drop(test_df.columns[0], axis=1, inplace=True)
10 | x_test = test_df.to_numpy()
11 |
12 | predictions = model.predict(xgboost.DMatrix(x_test))
13 |
14 | mse = mean_squared_error(y_test, predictions)
15 | std = np.std(y_test - predictions)
16 | report_dict = {
17 | "regression_metrics": {
18 | "mse": {"value": mse, "standard_deviation": std},
19 | },
20 | }
21 | print(f"evaluation report: {report_dict}")
22 | return report_dict
23 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/config.yaml:
--------------------------------------------------------------------------------
1 | SchemaVersion: '1.0'
2 | SageMaker:
3 | PythonSDK:
4 | Modules:
5 | RemoteFunction:
6 | # role arn is not required if in SageMaker Notebook instance or SageMaker Studio
7 | # Uncomment the following line and replace with the right execution role if in a local IDE
8 | RoleArn: arn:aws:iam::<...>:role/service-role/AmazonSageMaker-ExecutionRole-<...>
9 | InstanceType: ml.m5.xlarge
10 | Dependencies: ./requirements.txt
11 | IncludeLocalWorkDir: true
12 | CustomFileFilter:
13 | IgnoreNamePatterns: # files or directories to ignore
14 | - "*.ipynb" # all notebook files
15 | - "__pycache__"
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/local-requirements.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | pandas
5 | gevent
6 | geventhttpclient
7 | Markdown
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/pipeline_config.yaml:
--------------------------------------------------------------------------------
1 | pipeline:
2 | name: "llm-evaluation-single-model"
3 |
4 | dataset:
5 | dataset_name: "trivia_qa_sampled"
6 | input_data_location: "evaluation_dataset_trivia.jsonl" #"s3://llmevaluation-smpipelines/tiny_dataset.jsonl"
7 | dataset_mime_type: "jsonlines"
8 | model_input_key: "question"
9 | target_output_key: "answer"
10 |
11 | models:
12 | - name: "llama2-7b"
13 | model_id: "meta-textgeneration-llama-2-7b"
14 | model_version: "3.0.0"
15 | endpoint_name: "llm-eval-meta-textgeneration-llama-2-7b"
16 | deployment_config:
17 | instance_type: "ml.g5.2xlarge"
18 | num_instances: 1
19 | evaluation_config:
20 | output: '[0].generated_text'
21 | content_template: "PROMPT_PLACEHOLDER"
22 | inference_parameters:
23 | max_new_tokens: 100
24 | top_p: 0.9
25 | temperature: 0.6
26 | custom_attributes:
27 | accept_eula: True
28 | prompt_template: "$feature"
29 | cleanup_endpoint: True
30 |
31 | algorithms:
32 | - algorithm: "FactualKnowledge"
33 | module: "fmeval.eval_algorithms.factual_knowledge"
34 | config: "FactualKnowledgeConfig"
35 | target_output_delimiter: ""
36 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/requirements.txt:
--------------------------------------------------------------------------------
1 | pandas
2 | ipywidgets
3 | sagemaker
4 | fmeval
5 | markdown
6 | s3fs
7 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/steps/cleanup.py:
--------------------------------------------------------------------------------
1 | import boto3
2 |
3 |
4 | def cleanup(model_id, endpoint_name):
5 | client = boto3.client("sagemaker")
6 | client.delete_endpoint(EndpointName=endpoint_name)
7 | client.delete_endpoint_config(EndpointConfigName=endpoint_name)
8 | return model_id
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/steps/deploy.py:
--------------------------------------------------------------------------------
1 | import sagemaker
2 | from sagemaker.jumpstart.model import JumpStartModel
3 | from lib.utils import endpoint_exists
4 | import boto3
5 |
6 |
7 | def deploy(
8 | model_id,
9 | model_version,
10 | endpoint_name,
11 | instance_type="ml.g5.2xlarge",
12 | initial_instance_count=1,
13 | ):
14 | endpoint_exist = endpoint_exists(endpoint_name)
15 |
16 | if endpoint_exist:
17 | print("Endpoint already exists")
18 | else:
19 | my_model = JumpStartModel(model_id=model_id, model_version=model_version)
20 | predictor = my_model.deploy(
21 | initial_instance_count=initial_instance_count,
22 | instance_type=instance_type,
23 | serializer=sagemaker.serializers.JSONSerializer(),
24 | deserializer=sagemaker.deserializers.JSONDeserializer(),
25 | endpoint_name=endpoint_name,
26 | accept_eula=True,
27 | )
28 | # endpoint_name = predictor.endpoint_name
29 |
30 | return endpoint_name
31 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/steps/deploy_finetuned_model.py:
--------------------------------------------------------------------------------
1 | import sagemaker
2 | from sagemaker.jumpstart.estimator import JumpStartEstimator
3 | from lib.utils import endpoint_exists
4 |
5 |
6 | def deploy_finetuned_model(
7 | training_job_name,
8 | model_id,
9 | endpoint_name,
10 | instance_type="ml.g5.2xlarge",
11 | initial_instance_count=1,
12 | ):
13 | endpoint_exist = endpoint_exists(endpoint_name)
14 |
15 | if endpoint_exist:
16 | print("Endpoint already exists")
17 | else:
18 | estimator = JumpStartEstimator.attach(training_job_name, model_id=model_id)
19 | estimator.logs()
20 | predictor = estimator.deploy(
21 | initial_instance_count=initial_instance_count,
22 | instance_type=instance_type,
23 | serializer=sagemaker.serializers.JSONSerializer(),
24 | deserializer=sagemaker.deserializers.JSONDeserializer(),
25 | endpoint_name=endpoint_name,
26 | accept_eula=True,
27 | )
28 |
29 | return endpoint_name
30 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/steps/preprocess.py:
--------------------------------------------------------------------------------
1 | import boto3
2 | from sagemaker.s3_utils import parse_s3_url
3 |
4 |
5 | def preprocess(data_s3_path, output_s3_folder):
6 | s3 = boto3.client("s3")
7 |
8 | bucket, object_key = parse_s3_url(data_s3_path)
9 | s3.download_file(bucket, object_key, "dataset.jsonl")
10 |
11 | # Some preprocessing
12 | output_s3_path = output_s3_folder + "/processed-dataset.jsonl"
13 | s3.upload_file("dataset.jsonl", *parse_s3_url(output_s3_path))
14 |
15 | return output_s3_path
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines/steps/selection.py:
--------------------------------------------------------------------------------
1 | def selection(*args):
2 | max_score = -1
3 | best_model = None
4 | best_model_evaluation = None
5 |
6 | for arg in args:
7 | print(arg)
8 | model_config = arg["model_config"]
9 | eval_result = arg["eval_output"]
10 | print(eval_result)
11 |
12 | eval_output = eval_result[0][0]
13 | print(eval_output)
14 |
15 | eval_score = eval_output.dataset_scores[0].value
16 |
17 | print(eval_score)
18 | if eval_score > max_score:
19 | max_score = eval_score
20 | best_model = model_config
21 | best_model_evaluation = eval_result
22 |
23 | # get the model name with highest score
24 |
25 | print(best_model)
26 |
27 | return {"model_config": best_model, "eval_output": best_model_evaluation}
28 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/config.yaml:
--------------------------------------------------------------------------------
1 | SchemaVersion: '1.0'
2 | SageMaker:
3 | PythonSDK:
4 | Modules:
5 | RemoteFunction:
6 | # role arn is not required if in SageMaker Notebook instance or SageMaker Studio
7 | # Uncomment the following line and replace with the right execution role if in a local IDE
8 | #RoleArn: arn:aws:iam::<...>:role/service-role/AmazonSageMaker-ExecutionRole-<...>
9 | InstanceType: ml.m5.xlarge
10 | Dependencies: ./requirements.txt
11 | IncludeLocalWorkDir: true
12 | CustomFileFilter:
13 | IgnoreNamePatterns: # files or directories to ignore
14 | - "*.ipynb" # all notebook files
15 | - "__pycache__"
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/lib/import_models.py:
--------------------------------------------------------------------------------
1 | from model_providers.model_pipeline_steps_jumpstart import ModelPipelineStepsJumpStart
2 |
3 |
4 | def import_models(config):
5 | models = []
6 |
7 | # Import models
8 | for model_config in config["models"]:
9 | model_provider = model_config["model_provider"]
10 |
11 | if model_provider == "jumpstart":
12 | model = ModelPipelineStepsJumpStart(model_config)
13 | models.append(model)
14 | # You can implement other model providers by extending the class ModelPipelineSteps.py and add them here
15 |
16 | return models
17 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/local-requirements.txt:
--------------------------------------------------------------------------------
1 | scikit-learn
2 | xgboost==1.7.1
3 | s3fs==0.4.2
4 | sagemaker.tar.gz
5 | pandas
6 | gevent
7 | geventhttpclient
8 | fmeval
9 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/model_providers/model_pipeline_steps.py:
--------------------------------------------------------------------------------
1 | from abc import ABC, abstractmethod
2 | import boto3
3 | from datetime import datetime
4 |
5 |
6 | class ModelPipelineSteps(ABC):
7 | def __init__(self, config):
8 | self.config = config
9 |
10 | @staticmethod
11 | @abstractmethod
12 | def deploy_step(model, *args):
13 | pass
14 |
15 | @staticmethod
16 | @abstractmethod
17 | def finetune_step(model, *args):
18 | pass
19 |
20 | @staticmethod
21 | @abstractmethod
22 | def deploy_finetuned_step(model, finetune_step_ret, *args):
23 | pass
24 |
25 | @staticmethod
26 | @abstractmethod
27 | def register(model, model_registry_config, eval_output):
28 | pass
29 |
30 | @staticmethod
31 | @abstractmethod
32 | def cleanup_step(model, *args):
33 | pass
34 |
35 | @staticmethod
36 | @abstractmethod
37 | def get_model_runner(model, content_template, *args):
38 | pass
39 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/model_providers/steps/preprocess.py:
--------------------------------------------------------------------------------
1 | import boto3
2 | from sagemaker.s3_utils import parse_s3_url
3 |
4 |
5 | def preprocess(data_s3_path, output_s3_folder):
6 | s3 = boto3.client("s3")
7 |
8 | bucket, object_key = parse_s3_url(data_s3_path)
9 | s3.download_file(bucket, object_key, "dataset.jsonl")
10 |
11 | # Some preprocessing
12 | output_s3_path = output_s3_folder + "/processed-dataset.jsonl"
13 | s3.upload_file("dataset.jsonl", *parse_s3_url(output_s3_path))
14 |
15 | return {"output_s3_path": output_s3_path}
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/model_providers/steps/register.py:
--------------------------------------------------------------------------------
1 | from lib.utils import find_model_by_name
2 |
3 |
4 | def register(model_list, model_registry_config, selection_step_ret=None, *args):
5 | # Search model:
6 | if selection_step_ret is None:
7 | best_model_name = model_list[0].config["name"]
8 | model = model_list[0]
9 | else:
10 | best_model_name = selection_step_ret["best_model_name"]
11 | model = find_model_by_name(model_list, best_model_name)
12 |
13 | eval_output = None
14 | for results in args:
15 | if results["model_name"] == best_model_name:
16 | eval_output = results["evaluation_output"]
17 | break
18 |
19 | model_registry_ret = model.register(model, model_registry_config, eval_output)
20 |
21 | return model_registry_ret
22 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/model_providers/steps/selection.py:
--------------------------------------------------------------------------------
1 | def selection(*args):
2 | max_score = -1
3 | best_model = None
4 | best_model_evaluation = None
5 |
6 | for arg in args:
7 | print(arg)
8 | model_name = arg["model_name"]
9 |
10 | eval_result = arg["evaluation_output"]
11 | eval_output = eval_result[0][0]
12 | eval_score = eval_output.dataset_scores[0].value
13 | print(eval_score)
14 |
15 | if eval_score > max_score:
16 | max_score = eval_score
17 | best_model_name = model_name
18 | best_model_evaluation = eval_result
19 |
20 | print(best_model_name)
21 | print(max_score)
22 |
23 | return {"best_model_name": best_model_name}
24 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/pipeline_config.yaml:
--------------------------------------------------------------------------------
1 | pipeline:
2 | name: "llm-evaluation-advanced-single-model"
3 |
4 | dataset:
5 | dataset_name: "trivia_qa_sampled"
6 | input_data_location: "evaluation_dataset_trivia.jsonl" #"s3://llmevaluation-smpipelines/tiny_dataset.jsonl"
7 | dataset_mime_type: "jsonlines"
8 | model_input_key: "question"
9 | target_output_key: "answer"
10 |
11 | models:
12 | - name: "llama2-7b"
13 | model_provider: "jumpstart"
14 | model_id: "meta-textgeneration-llama-2-7b"
15 | model_version: "3.0.0"
16 | endpoint_name: "llm-eval-adv-meta-textgeneration-llama-2-7b"
17 | deployment_config:
18 | instance_type: "ml.g5.2xlarge"
19 | num_instances: 1
20 | evaluation_config:
21 | output: '[0].generated_text'
22 | content_template: "PROMPT_PLACEHOLDER"
23 | inference_parameters:
24 | max_new_tokens: 100
25 | top_p: 0.9
26 | temperature: 0.6
27 | custom_attributes:
28 | accept_eula: True
29 | prompt_template: "$feature"
30 | cleanup_endpoint: True
31 |
32 | model_registry:
33 | model_package_group_name: "LLMEvaluationPipeline"
34 | model_package_group_description: "LLM Evaluation Pipeline"
35 |
36 | algorithms:
37 | - algorithm: "FactualKnowledge"
38 | module: "fmeval.eval_algorithms.factual_knowledge"
39 | config: "FactualKnowledgeConfig"
40 | target_output_delimiter: ""
41 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/llm-training/sm_pipelines_advanced/requirements.txt:
--------------------------------------------------------------------------------
1 | sagemaker==2.218.0
2 | s3fs
3 | fmeval
4 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/Makefile:
--------------------------------------------------------------------------------
1 | SHELL := /usr/bin/env bash
2 |
3 | .PHONY: tf-plan
4 | tf-plan:
5 | terraform init \
6 | -backend-config="bucket=${bucket}" \
7 | -backend-config="region=${region}" \
8 | -backend-config="key=${key}" \
9 | -backend-config="dynamodb_table=${table}" \
10 | -backend-config="encrypt=true" \
11 | -reconfigure && \
12 | terraform validate && \
13 | terraform plan \
14 | -var region=${region} \
15 | -var-file ${var_file}
16 | .PHONY: tf-apply
17 | tf-apply:
18 | terraform init \
19 | -backend-config="bucket=${bucket}" \
20 | -backend-config="region=${region}" \
21 | -backend-config="key=${key}" \
22 | -backend-config="dynamodb_table=${table}" \
23 | -backend-config="encrypt=true" \
24 | -reconfigure && \
25 | terraform validate && \
26 | terraform apply \
27 | -var region=${region} \
28 | -var-file ${var_file} -auto-approve
29 | .PHONY: tf-destroy
30 | tf-destroy:
31 | terraform init \
32 | -backend-config="bucket=${bucket}" \
33 | -backend-config="region=${region}" \
34 | -backend-config="key=${key}" \
35 | -backend-config="dynamodb_table=${table}" \
36 | -backend-config="encrypt=true" \
37 | -reconfigure && \
38 | terraform destroy \
39 | -var region=${region} \
40 | -var-file ${var_file} \
41 | -auto-approve
42 |
43 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/cloud_formation/pre-prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "ProcessingInstanceCount": "1",
4 | "ProcessingInstanceType": "ml.m5.large",
5 | "InferenceInstanceCount": "1",
6 | "InferenceInstanceType": "ml.m5.large",
7 | "ScheduleExpressionforPipeline": "1 day"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/cloud_formation/prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "ProcessingInstanceCount": "1",
4 | "ProcessingInstanceType": "ml.m5.large",
5 | "InferenceInstanceCount": "1",
6 | "InferenceInstanceType": "ml.m5.large",
7 | "ScheduleExpressionforPipeline": "1 day"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/img/batch_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-deployment-batch/img/batch_architecture.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a module inside its own folder, for example here the "batch_inference" pipeline, contained inside `batch_inference/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/__version__.py:
--------------------------------------------------------------------------------
1 | """Metadata for the pipelines package."""
2 |
3 | __title__ = "pipelines"
4 | __description__ = "pipelines - template package"
5 | __version__ = "0.0.1"
6 | __author__ = ""
7 | __author_email__ = ""
8 | __license__ = "Apache 2.0"
9 | __url__ = ""
10 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/batch_inference/README.md:
--------------------------------------------------------------------------------
1 | # Inference SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Prepare the inference dataset through a SageMaker Processing Job
5 | - Run the inference with a Batch transform job
6 |
7 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/batch_inference/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-deployment-batch/pipelines/batch_inference/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/pre-prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProcessingInstanceCount": "1",
3 | "ProcessingInstanceType": "ml.m5.large",
4 | "InferenceInstanceCount": "1",
5 | "InferenceInstanceType": "ml.m5.large",
6 | "ScheduleExpressionforPipeline": "1 day"
7 | }
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProcessingInstanceCount": "1",
3 | "ProcessingInstanceType": "ml.m5.large",
4 | "InferenceInstanceCount": "1",
5 | "InferenceInstanceType": "ml.m5.large",
6 | "ScheduleExpressionforPipeline": "1 day"
7 | }
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-batch/version.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.Environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/Makefile:
--------------------------------------------------------------------------------
1 | SHELL := /usr/bin/env bash
2 |
3 | .PHONY: tf-plan
4 | tf-plan:
5 | terraform init \
6 | -backend-config="bucket=${bucket}" \
7 | -backend-config="region=${region}" \
8 | -backend-config="key=${key}" \
9 | -backend-config="dynamodb_table=${table}" \
10 | -backend-config="encrypt=true" \
11 | -reconfigure && \
12 | terraform validate && \
13 | terraform plan \
14 | -var region=${region} \
15 | -var-file ${var_file}
16 | .PHONY: tf-apply
17 | tf-apply:
18 | terraform init \
19 | -backend-config="bucket=${bucket}" \
20 | -backend-config="region=${region}" \
21 | -backend-config="key=${key}" \
22 | -backend-config="dynamodb_table=${table}" \
23 | -backend-config="encrypt=true" \
24 | -reconfigure && \
25 | terraform validate && \
26 | terraform apply \
27 | -var region=${region} \
28 | -var-file ${var_file} -auto-approve
29 | .PHONY: tf-destroy
30 | tf-destroy:
31 | terraform init \
32 | -backend-config="bucket=${bucket}" \
33 | -backend-config="region=${region}" \
34 | -backend-config="key=${key}" \
35 | -backend-config="dynamodb_table=${table}" \
36 | -backend-config="encrypt=true" \
37 | -reconfigure && \
38 | terraform destroy \
39 | -var region=${region} \
40 | -var-file ${var_file} \
41 | -auto-approve
42 |
43 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/cloud_formation/pre-prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "StageName": "staging",
4 | "EndpointInstanceCount": "1",
5 | "EndpointInstanceType": "ml.m5.large",
6 | "SamplingPercentage": "100",
7 | "EnableDataCapture": "true"
8 | }
9 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/cloud_formation/prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "StageName": "prod",
4 | "EndpointInstanceCount": "1",
5 | "EndpointInstanceType": "ml.m5.large",
6 | "SamplingPercentage": "80",
7 | "EnableDataCapture": "true"
8 | }
9 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/pre-prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 | "StageName": "staging",
3 | "EndpointInstanceCount": "1",
4 | "EndpointInstanceType": "ml.m5.large",
5 | "SamplingPercentage": "100",
6 | "EnableDataCapture": "true"
7 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | "StageName": "prod",
4 | "EndpointInstanceCount": "1",
5 | "EndpointInstanceType": "ml.m5.large",
6 | "SamplingPercentage": "80"
7 |
8 | }
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-deployment-realtime/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.Environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/img/pipeline-full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-training/img/pipeline-full.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/pipelines/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-training/pipelines/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/pipelines/__version__.py:
--------------------------------------------------------------------------------
1 | """Metadata for the pipelines package."""
2 |
3 | __title__ = "pipelines"
4 | __description__ = "pipelines - template package"
5 | __version__ = "0.0.1"
6 | __author__ = ""
7 | __author_email__ = ""
8 | __license__ = "Apache 2.0"
9 | __url__ = ""
10 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/pipelines/abalone/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/model-training/pipelines/abalone/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 |
12 | [wheel]
13 | universal = 1
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/model-training/tests/test_pipelines.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 |
4 | @pytest.mark.xfail
5 | def test_that_you_wrote_tests():
6 | assert False, "No tests written"
7 |
8 |
9 | def test_pipelines_importable():
10 | import pipelines # noqa: F401
11 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .terraform*
3 | terraform*
4 | .DS_Store
5 | workshop.tar
6 | .vscode
7 | *.zip
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/Makefile:
--------------------------------------------------------------------------------
1 | SHELL := /usr/bin/env bash
2 |
3 | .PHONY: tf-plan
4 | tf-plan:
5 | cd deploy_target && \
6 | terraform init \
7 | -backend-config="bucket=${bucket}" \
8 | -backend-config="region=${region}" \
9 | -backend-config="key=${key}" \
10 | -backend-config="dynamodb_table=${table}" \
11 | -backend-config="encrypt=true" \
12 | -reconfigure && \
13 | terraform validate && \
14 | terraform plan \
15 | -var region=${region} \
16 | -var-file ${var_file}
17 | .PHONY: tf-apply
18 | tf-apply:
19 | cd deploy_target && \
20 | terraform init \
21 | -backend-config="bucket=${bucket}" \
22 | -backend-config="region=${region}" \
23 | -backend-config="key=${key}" \
24 | -backend-config="dynamodb_table=${table}" \
25 | -backend-config="encrypt=true" \
26 | -reconfigure && \
27 | terraform validate && \
28 | terraform apply \
29 | -var region=${region} \
30 | -var-file ${var_file} -auto-approve
31 | .PHONY: tf-destroy
32 | tf-destroy:
33 | cd deploy_target && \
34 | terraform init \
35 | -backend-config="bucket=${bucket}" \
36 | -backend-config="region=${region}" \
37 | -backend-config="key=${key}" \
38 | -backend-config="dynamodb_table=${table}" \
39 | -backend-config="encrypt=true" \
40 | -reconfigure && \
41 | terraform destroy \
42 | -var region=${region} \
43 | -var-file ${var_file} \
44 | -auto-approve
45 |
46 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/deploy_target/cloud_formation/pre-prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "StageName": "staging",
4 | "ProcessingInstanceCount": "1",
5 | "ProcessingInstanceType": "ml.m5.large",
6 | "InferenceInstanceCount": "1",
7 | "InferenceInstanceType": "ml.m5.large",
8 | "TrainingInstanceCount": "1",
9 | "MseThreshold": "8.0",
10 | "InputDataUrl":"s3: //sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset.csv",
11 | "BatchDataUrl":"sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset-batch",
12 | "ScheduleExpressionforPipeline": "1 day",
13 | "TriggerState": "DISABLED"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/deploy_target/cloud_formation/prod-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "StageName": "prod",
4 | "ProcessingInstanceCount": "1",
5 | "ProcessingInstanceType": "ml.m5.large",
6 | "InferenceInstanceCount": "1",
7 | "InferenceInstanceType": "ml.m5.large",
8 | "MseThreshold": "8.0",
9 | "TrainingInstanceCount": "1",
10 | "InputDataUrl": "s3: //sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset.csv",
11 | "BatchDataUrl": "sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset-batch",
12 | "ScheduleExpressionforPipeline": "1 day",
13 | "TriggerState": "DISABLED"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/deploy_target/pre-prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProcessingInstanceCount": "1",
3 | "ProcessingInstanceType": "ml.m5.large",
4 | "InferenceInstanceCount": "1",
5 | "InferenceInstanceType": "ml.m5.large",
6 | "TrainingInstanceCount": "1",
7 | "MseThreshold": "8.0",
8 | "InputDataUrl":"s3: //sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset.csv",
9 | "BatchDataUrl":"sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset-batch",
10 | "ScheduleExpressionforPipeline": "1 day"
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/deploy_target/prod-config.tfvars.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProcessingInstanceCount": "1",
3 | "ProcessingInstanceType": "ml.m5.large",
4 | "InferenceInstanceCount": "1",
5 | "InferenceInstanceType": "ml.m5.large",
6 | "MseThreshold": "8.0",
7 | "TrainingInstanceCount": "1",
8 | "InputDataUrl": "s3: //sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset.csv",
9 | "BatchDataUrl": "sagemaker-servicecatalog-seedcode-us-east-1/dataset/abalone-dataset-batch",
10 | "ScheduleExpressionforPipeline": "1 day"
11 | }
12 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/deploy_target/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = "1.5.2"
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 5.15.0"
7 | }
8 | }
9 | backend "s3" {}
10 | }
11 |
12 | provider "aws" {
13 | region = var.region
14 | default_tags {
15 | tags = {
16 | Environment = var.Environment
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/architecture.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-1.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-2.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-3.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-4.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-5.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-6.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-7.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-8.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/img/pipeline-full.png
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/README.md:
--------------------------------------------------------------------------------
1 | # SageMaker Pipelines
2 |
3 | This folder contains SageMaker Pipeline definitions and helper scripts to either simply "get" a SageMaker Pipeline definition (JSON dictionnary) with `get_pipeline_definition.py`, or "run" a SageMaker Pipeline from a SageMaker pipeline definition with `run_pipeline.py`.
4 |
5 | Those files are generic and can be reused to call any SageMaker Pipeline.
6 |
7 | Each SageMaker Pipeline definition should be be treated as a module inside its own folder, for example here the "inference" pipeline, contained inside `inference/`.
8 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/__version__.py:
--------------------------------------------------------------------------------
1 | """Metadata for the pipelines package."""
2 |
3 | __title__ = "pipelines"
4 | __description__ = "pipelines - template package"
5 | __version__ = "0.0.1"
6 | __author__ = ""
7 | __author_email__ = ""
8 | __license__ = "Apache 2.0"
9 | __url__ = ""
10 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/batch_inference/README.md:
--------------------------------------------------------------------------------
1 | # Inference SageMaker Pipeline
2 |
3 | This SageMaker Pipeline definition creates a workflow that will:
4 | - Prepare the dataset through a SageMaker Processing Job
5 | - Train a model
6 | - Evaluate the model
7 | - Create the model
8 | - Register the model
9 | - Batch inference
10 |
11 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/batch_inference/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-enterprise-mlops-framework/b3eefc2158446eb3cad65236b0b24ff079042581/mlops-multi-account-tf/template-repos/pipeline-promotion/pipelines/batch_inference/__init__.py
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/setup.cfg:
--------------------------------------------------------------------------------
1 | [tool:pytest]
2 | addopts =
3 | -vv
4 | testpaths = tests
5 |
6 | [aliases]
7 | test=pytest
8 |
9 | [metadata]
10 | description-file = README.md
11 |
12 | [wheel]
13 | universal = 1
14 |
--------------------------------------------------------------------------------
/mlops-multi-account-tf/template-repos/pipeline-promotion/tests/test_pipelines.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 |
4 | @pytest.mark.xfail
5 | def test_that_you_wrote_tests():
6 | assert False, "No tests written"
7 |
8 |
9 | def test_pipelines_importable():
10 | import pipelines # noqa: F401
11 |
--------------------------------------------------------------------------------