Skip to content

Instantly share code, notes, and snippets.

@jpbarto
jpbarto / fashionmnist-mxnet.py
Last active May 8, 2020 19:40
Sample MXNet code for Fashion MNIST
"""
This script is a simple FashionMNIST training script which uses MXNet's.
It has been orchestrated with SageMaker Debugger hook to allow saving tensors during training.
Here, the hook has been created using its constructor to allow running this locally for your experimentation.
When you want to run this script in SageMaker, it is recommended to create the hook from json file.
Please see scripts in either /examples/tensorflow/sagemaker_byoc or /examples/tensorflow/sagemaker_official_container
folder based on your use case.
"""
# Standard Library
import argparse
@jpbarto
jpbarto / aws_iam_role_action_report.sh
Last active June 11, 2020 10:16
Shell script to query AWS CloudTrail and list all actions taken by an AWS Role
#!/bin/bash
###
#
# The following script queries AWS CloudTrail for any events matching $USERNAME which occurred with the permissions
# associated with $ROLE_ARN. All events that have occcurred as of $START_TIME (Unix timestamp in seconds) will
# be retrieved and the IAM actions of those events printed to STDOUT in a sorted and de-duplicated list.
#
# Sample Output:
#
@jpbarto
jpbarto / jpbarto-sagemaker-lifecycle.sh
Last active June 10, 2020 15:40
Default lifecycle configuration for SageMaker notebooks
#!/bin/bash
#
# This script takes about 5 minutes to run and will delay the availability of
# your SageMaker notebook.
# v1.3, release 05may2020
#
# THIS SCRIPT INSTALLS:
# - THEIA IDE w/ Jupyter Server proxy
# - UPGRADES JUPYTERLAB
# - INSTALL VOILA (https://github.com/voila-dashboards/voila)
@jpbarto
jpbarto / ide-lifecycle.sh
Last active May 15, 2020 20:03
Lifecycle script for SageMaker notebook startup which installs Theia-IDE
#!/bin/bash
set -e
sudo -u ec2-user -i <<'EOP'
## INSTALL THEIA IDE FROM SOURCE
EC2_HOME=/home/ec2-user
mkdir ${EC2_HOME}/theia && cd ${EC2_HOME}/theia
### begin by installing NVM, NodeJS v10, and Yarn
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
@jpbarto
jpbarto / private-eks-workers.yaml
Created August 18, 2019 06:44
Private EKS Workers CloudFormation with User Data
AWSTemplateFormatVersion: 2010-09-09
Description: Amazon EKS - Node Group
Parameters:
KeyName:
Description: The EC2 Key Pair to allow SSH access to the instances
Type: 'AWS::EC2::KeyPair::KeyName'
NodeImageId:
Description: AMI id for the node instances.
Type: 'AWS::EC2::Image::Id'
NodeInstanceType:
@jpbarto
jpbarto / private-eks-nodes.yaml
Created July 29, 2019 06:44
Private EKS Worker Nodes - CloudFormation
###
#
# CloudFormation Template to create EKS Worker Nodes without access to an IGW
#
# The following CloudFormation template is based upon the AWS-provided CloudFormation template for creating
# EKS worker nodes in your VPC. It differs in that it has user-data modified to configure a node to operate
# within a VPC that has no IGW.
#
# To use this template you will need a VPC with an EKS cluster already deployed and private access enabled.
# You will also need a web proxy configured to allow the worker nodes access to the AWS EKS service API. This
@jpbarto
jpbarto / sagemaker_training_job.json
Created June 20, 2019 11:19
Sample Script Container Invoke
{
"TrainingJobName": "cli-t-job",
"HyperParameters": {
"sagemaker_submit_directory": "s3://sagemaker-eu-west-2-776347453069/sagemaker-scikit-learn-2019-06-19-13-21-02-471/source/sourcedir.tar.gz",
"sagemaker_program": "sklearn_abalone_featurizer.py",
"sagemaker_enable_cloudwatch_metrics": "false",
"sagemaker_container_log_level": "20",
"sagemaker_job_name": "sagemaker-scikit-learn-2019-06-19-13-21-02-471",
"sagemaker_region": "eu-west-2"
},
@jpbarto
jpbarto / simple_sklearn_transformer.py
Created June 20, 2019 08:05
Simple SKLearn script to transform some inputs using the SKLearn Estimator on Amazon SageMaker
import pandas as pd
import numpy as np
import argparse
from sklearn import preprocessing
import pickle
import os
from io import StringIO
from sagemaker_containers.beta.framework import (
content_types, encoders, env, modules, transformer, worker)
@jpbarto
jpbarto / video-game-sales.ipynb
Created March 26, 2019 16:17
Sample Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpbarto
jpbarto / websocket-nlb-test.tf
Created March 16, 2019 21:57
A Terraform template to create an AWS autoscaling group tied to a network load balancer, to test the ability to create a Socket.IO server that has no route to the Internet
##
## AMI created using
## curl -sL https://rpm.nodesource.com/setup_11.x | bash -
## yum install -y git nodejs
## git clone https://github.com/socketio/socket.io.git
##
## cd socket.io
## npm install
## cd examples/chat
## npm install