Skip to content

Instantly share code, notes, and snippets.

View sofianhamiti's full-sized avatar

Sofian Hamiti sofianhamiti

View GitHub Profile
"""Example workflow pipeline script for abalone pipeline.
. -RegisterModel
.
Process-> Train -> Evaluate -> Condition .
.
. -(stop)
Implements a get_pipeline(**kwargs) method.
"""
step_train = TrainingStep(
name="TrainAbaloneModel",
estimator=xgb_train,
inputs={...},
retry_policies=[
step_retry_policy,
job_retry_policy
]
)
from sagemaker.workflow.retry import (
StepRetryPolicy,
StepExceptionTypeEnum,
SageMakerJobStepRetryPolicy,
SageMakerJobExceptionTypeEnum
)
step_retry_policy = StepRetryPolicy(
exception_types=[
StepExceptionTypeEnum.SERVICE_FAULT,
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VPCDeployment",
"Effect": "Deny",
"Action": [
"sagemaker:CreateAutoMLJob",
"sagemaker:CreateDataQualityJobDefinition",
"sagemaker:CreateDomain",
{
"Action": [
"sagemaker:CreateApp"
],
"Resource": [
"*"
],
"Effect": "Deny",
"Sid": "BlockSagemakerOtherThanT3",
"Condition": {
#!/bin/bash
## GET MODELS FROM S3 INTO THE /TMP FOLDER
aws s3 sync ${MODEL_REPOSITORY} /tmp/model_repository
# RUN TRITON
/opt/tritonserver/bin/tritonserver --model-repository=/tmp/model_repository
from aws_cdk import core
from stacks.iam_stack import IamStack
from stacks.vpc_stack import VpcStack
from stacks.ecs_stack import EcsStack
class InferenceStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
FROM nvcr.io/nvidia/tritonserver:21.05-py3
# INSTALL AWS CLI
RUN apt-get update && apt-get install -y \
unzip \
&& rm -rf /var/lib/apt/lists/*
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
{
"DomainId": "<domain-id>",
"DefaultUserSettings": {
"KernelGatewayAppSettings": {
"CustomImages": [
{
"ImageName": "tf25",
"AppImageConfigName": "tf25-config"
}
]
version: 0.2
phases:
pre_build:
commands:
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-8)
- sh build_and_push.sh ${IMAGE_NAME} ${IMAGE_TAG}
- echo "IMAGE PUSHED TO ECR"
build: