This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set -e | |
| sudo -u ec2-user -i <<'EOP' | |
| ##################################### | |
| ## INSTALL THEIA IDE | |
| ##################################### | |
| cd ${HOME} | |
| git clone https://github.com/SofianHamiti/amazon-sagemaker-notebook-instance-lifecycle-config-theia.git lifecycle-config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(randomForest) | |
| library(MASS) | |
| set.seed(42) | |
| # Prepare dataset | |
| cutoff = sample(1:nrow(Boston), nrow(Boston) * 0.7) # 70/30 split between test and train | |
| train_set <- Boston[cutoff,] | |
| test_set <- Boston[-cutoff,] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(randomForest) | |
| library(jsonlite) | |
| # download model file from S3 into /tmp folder | |
| system("aws s3 cp ${S3_MODEL_URI} /tmp/model.rds") | |
| handler <- function(body, ...) { | |
| data <- fromJSON(txt = body) | |
| # load model | |
| model <- readRDS("/tmp/model.rds") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM public.ecr.aws/lambda/provided | |
| ENV R_VERSION=4.0.3 | |
| ENV PATH="${PATH}:/opt/R/${R_VERSION}/bin/" | |
| # install R | |
| RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ | |
| && yum -y install https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \ | |
| openssl-devel \ | |
| libxml2-devel \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from aws_cdk import ( | |
| aws_lambda, | |
| aws_iam, | |
| aws_apigatewayv2, | |
| core | |
| ) | |
| class InferenceStack(core.Stack): | |
| def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "crim": 0.0063, | |
| "zn": 18, | |
| "indus": 2.31, | |
| "chas": 0, | |
| "nox": 0.538, | |
| "rm": 6.575, | |
| "age": 65.2, | |
| "dis": 4.09, | |
| "rad": 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import boto3 | |
| import logging | |
| from botocore.config import Config | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.INFO) | |
| config = Config(retries = {'max_attempts': 10,'mode': 'standard'}) | |
| sagemaker = boto3.client('sagemaker', config=config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: Deploys a scheduled Lambda function to shutdown Studio kernels automatically | |
| Resources: | |
| #================================================================================ | |
| # LAMBDA | |
| #================================================================================ | |
| StudioShutdownFunction: | |
| Type: AWS::Lambda::Function | |
| Properties: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "CRIM": 0.0063, | |
| "ZN": 18, | |
| "INDUS": 2.31, | |
| "CHAS": 0, | |
| "NOX": 0.538, | |
| "RM": 6.575, | |
| "AGE": 65.2, | |
| "DIS": 4.09, | |
| "RAD": 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from aws_cdk import core | |
| from stacks.api_stack import ApiStack | |
| from stacks.lambda_stack import LambdaStack | |
| from stacks.state_machine_stack import StateMachineStack | |
| class InferenceStack(core.Stack): | |
| def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: | |
| super().__init__(scope, id, **kwargs) |
OlderNewer