Skip to content

Instantly share code, notes, and snippets.

View sofianhamiti's full-sized avatar

Sofian Hamiti sofianhamiti

View GitHub Profile
{
"length": -0.158164,
"diameter": -0.280982,
"height": -0.227545,
"whole_weight": -0.352298,
"shucked_weight": -0.596421,
"viscera_weight": -0.019102,
"shell_weight": -0.135293,
"sex_M": 0.0,
"sex_F": 0.0,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import boto3
import joblib
import pandas as pd
# download model file from S3 into /tmp folder
s3 = boto3.client('s3')
bucket = os.environ['BUCKET']
key = os.environ['KEY']
s3.download_file(bucket, key, '/tmp/model.pkl')
FROM public.ecr.aws/lambda/python:3.8
# Install dependencies
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt --no-cache
# Copy inference code
COPY predict.py ${LAMBDA_TASK_ROOT}/
CMD [ "predict.handler" ]
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)
{
"CRIM": 0.0063,
"ZN": 18,
"INDUS": 2.31,
"CHAS": 0,
"NOX": 0.538,
"RM": 6.575,
"AGE": 65.2,
"DIS": 4.09,
"RAD": 1,
AWSTemplateFormatVersion: 2010-09-09
Description: Deploys a scheduled Lambda function to shutdown Studio kernels automatically
Resources:
#================================================================================
# LAMBDA
#================================================================================
StudioShutdownFunction:
Type: AWS::Lambda::Function
Properties:
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)
{
"crim": 0.0063,
"zn": 18,
"indus": 2.31,
"chas": 0,
"nox": 0.538,
"rm": 6.575,
"age": 65.2,
"dis": 4.09,
"rad": 1,
@sofianhamiti
sofianhamiti / app.py
Last active February 12, 2021 21:41
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: