Skip to content

Commit

Permalink
code base
Browse files Browse the repository at this point in the history
Signed-off-by: Neha Vadnere <[email protected]>
  • Loading branch information
nehavadnere committed Jun 21, 2022
0 parents commit 5315805
Show file tree
Hide file tree
Showing 116 changed files with 315 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Define global args
# ARG FUNCTION_DIR="/tmp/"
# ARG FUNCTION_DIR=${LAMBDA_TASK_ROOT}
ARG FUNCTION_DIR="/home/app/"
ARG RUNTIME_VERSION="3.8"
ARG DISTRO_VERSION="3.12"

# Stage 1 - bundle base image + runtime
# Grab a fresh copy of the image and install GCC
FROM python:${RUNTIME_VERSION} AS python-alpine
# Install GCC (Alpine uses musl but we compile and link dependencies with GCC)
#RUN apk add --no-cache \
# libstdc++

RUN apt-get update \
&& apt-get install -y cmake ca-certificates libgl1-mesa-glx
RUN python${RUNTIME_VERSION} -m pip install --upgrade pip

# Stage 2 - build function and dependencies
FROM python-alpine AS build-image
# Install aws-lambda-cpp build dependencies
#RUN apk add --no-cache \
# build-base \
# libtool \
# autoconf \
# automake \
# libexecinfo-dev \
# make \
# cmake \
# libcurl
# Include global args in this stage of the build
ARG FUNCTION_DIR
ARG RUNTIME_VERSION
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}

# Optional – Install the function's dependencies
# RUN python${RUNTIME_VERSION} -m pip install -r requirements.txt --target ${FUNCTION_DIR}
# Install Lambda Runtime Interface Client for Python
RUN python${RUNTIME_VERSION} -m pip install awslambdaric --target ${FUNCTION_DIR}

# Stage 3 - final runtime image
# Grab a fresh copy of the Python image
FROM python-alpine
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# Copy in the built dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
# (Optional) Add Lambda Runtime Interface Emulator and use a script in the ENTRYPOINT for simpler local runs
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/bin/aws-lambda-rie
RUN chmod 755 /usr/bin/aws-lambda-rie

# Install ffmpeg
RUN apt-get install -y ffmpeg

# Copy handler function
COPY requirements.txt ${FUNCTION_DIR}
RUN python${RUNTIME_VERSION} -m pip install -r requirements.txt --target ${FUNCTION_DIR}
COPY entry.sh /

# Copy function code
COPY handler.py ${FUNCTION_DIR}
RUN chmod 777 /entry.sh

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
# CMD [ "handler.handler" ]
ENTRYPOINT [ "/entry.sh" ]
CMD [ "handler.face_recognition_handler" ]
Binary file added encoding
Binary file not shown.
6 changes: 6 additions & 0 deletions entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
exec /usr/bin/aws-lambda-rie /usr/local/bin/python -m awslambdaric $1
else
exec /usr/local/bin/python -m awslambdaric $1
fi
16 changes: 16 additions & 0 deletions handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from boto3 import client as boto3_client
import face_recognition
import pickle

input_bucket = "546proj2"
output_bucket = "546proj2output"

# Function to read the 'encoding' file
def open_encoding(filename):
file = open(filename, "rb")
data = pickle.load(file)
file.close()
return data

def face_recognition_handler(event, context):
print("Hello")
100 changes: 100 additions & 0 deletions mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
test_5.mp4:computer_science,sophomore
test_13.mp4:computer_science,sophomore
test_21.mp4:computer_science,sophomore
test_29.mp4:computer_science,sophomore
test_37.mp4:computer_science,sophomore
test_45.mp4:computer_science,sophomore
test_53.mp4:computer_science,sophomore
test_61.mp4:computer_science,sophomore
test_69.mp4:computer_science,sophomore
test_77.mp4:computer_science,sophomore
test_85.mp4:computer_science,sophomore
test_93.mp4:computer_science,sophomore
test_8.mp4:electrical_engineering,senior
test_16.mp4:electrical_engineering,senior
test_24.mp4:electrical_engineering,senior
test_32.mp4:electrical_engineering,senior
test_40.mp4:electrical_engineering,senior
test_48.mp4:electrical_engineering,senior
test_56.mp4:electrical_engineering,senior
test_64.mp4:electrical_engineering,senior
test_72.mp4:electrical_engineering,senior
test_80.mp4:electrical_engineering,senior
test_88.mp4:electrical_engineering,senior
test_96.mp4:electrical_engineering,senior
test_0.mp4:physics,junior
test_9.mp4:physics,junior
test_17.mp4:physics,junior
test_25.mp4:physics,junior
test_33.mp4:physics,junior
test_41.mp4:physics,junior
test_49.mp4:physics,junior
test_57.mp4:physics,junior
test_65.mp4:physics,junior
test_73.mp4:physics,junior
test_81.mp4:physics,junior
test_89.mp4:physics,junior
test_97.mp4:physics,junior
test_7.mp4:math,senior
test_15.mp4:math,senior
test_23.mp4:math,senior
test_31.mp4:math,senior
test_39.mp4:math,senior
test_47.mp4:math,senior
test_55.mp4:math,senior
test_63.mp4:math,senior
test_71.mp4:math,senior
test_79.mp4:math,senior
test_87.mp4:math,senior
test_95.mp4:math,senior
test_1.mp4:history,sophomore
test_10.mp4:history,sophomore
test_18.mp4:history,sophomore
test_26.mp4:history,sophomore
test_34.mp4:history,sophomore
test_42.mp4:history,sophomore
test_50.mp4:history,sophomore
test_58.mp4:history,sophomore
test_66.mp4:history,sophomore
test_74.mp4:history,sophomore
test_82.mp4:history,sophomore
test_90.mp4:history,sophomore
test_98.mp4:history,sophomore
test_4.mp4:computer_science,senior
test_12.mp4:computer_science,senior
test_20.mp4:computer_science,senior
test_28.mp4:computer_science,senior
test_36.mp4:computer_science,senior
test_44.mp4:computer_science,senior
test_52.mp4:computer_science,senior
test_60.mp4:computer_science,senior
test_68.mp4:computer_science,senior
test_76.mp4:computer_science,senior
test_84.mp4:computer_science,senior
test_92.mp4:computer_science,senior
test_6.mp4:history,junior
test_14.mp4:history,junior
test_22.mp4:history,junior
test_30.mp4:history,junior
test_38.mp4:history,junior
test_46.mp4:history,junior
test_54.mp4:history,junior
test_62.mp4:history,junior
test_70.mp4:history,junior
test_78.mp4:history,junior
test_86.mp4:history,junior
test_94.mp4:history,junior
test_2.mp4:lawyer,freshman
test_11.mp4:lawyer,freshman
test_19.mp4:lawyer,freshman
test_27.mp4:lawyer,freshman
test_35.mp4:lawyer,freshman
test_43.mp4:lawyer,freshman
test_51.mp4:lawyer,freshman
test_59.mp4:lawyer,freshman
test_67.mp4:lawyer,freshman
test_75.mp4:lawyer,freshman
test_83.mp4:lawyer,freshman
test_91.mp4:lawyer,freshman
test_99.mp4:lawyer,freshman
test_100.mp4:lawyer,freshman
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
boto3
dlib
numpy
face_recognition
opencv-python
ffmpeg
50 changes: 50 additions & 0 deletions student_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"id": 1,
"name": "mr_bean",
"major": "lawyer",
"year": "freshmen"
},
{
"id": 2,
"name": "president_biden",
"major": "history",
"year": "sophomore"
},
{
"id": 3,
"name": "vin_diesel",
"major": "computer_science",
"year": "sophomore"
},
{
"id": 4,
"name": "floki",
"major": "history",
"year": "junior"
},
{
"id": 5,
"name": "president_trump",
"major": "physics",
"year": "junior"
},
{
"id": 6,
"name": "morgan_freeman",
"major": "math",
"year": "senior"
},
{
"id": 7,
"name": "president_obama",
"major": "electrical_engineering",
"year": "senior"
},
{
"id": 8,
"name": "johnny_dep",
"major": "computer_science",
"year": "senior"
}
]
Binary file added test_cases/test_case_1/test_0.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_1.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_2.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_4.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_5.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_6.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_7.mp4
Binary file not shown.
Binary file added test_cases/test_case_1/test_8.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_0.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_1.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_10.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_100.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_11.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_12.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_13.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_14.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_15.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_16.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_17.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_18.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_19.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_2.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_20.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_21.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_22.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_23.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_24.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_25.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_26.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_27.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_28.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_29.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_30.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_31.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_32.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_33.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_34.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_35.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_36.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_37.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_38.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_39.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_4.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_40.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_41.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_42.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_43.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_44.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_45.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_46.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_47.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_48.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_49.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_5.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_50.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_51.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_52.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_53.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_54.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_55.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_56.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_57.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_58.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_59.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_6.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_60.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_61.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_62.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_63.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_64.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_65.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_66.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_67.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_68.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_69.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_7.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_70.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_71.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_72.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_73.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_74.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_75.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_76.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_77.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_78.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_79.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_8.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_80.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_81.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_82.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_83.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_84.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_85.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_86.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_87.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_88.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_89.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_9.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_90.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_91.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_92.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_93.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_94.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_95.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_96.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_97.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_98.mp4
Binary file not shown.
Binary file added test_cases/test_case_2/test_99.mp4
Binary file not shown.
67 changes: 67 additions & 0 deletions workload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from boto3 import client as boto3_client
import os

input_bucket = "546proj2"
output_bucket = "546proj2output"
test_cases = "test_cases/"

def clear_input_bucket():
global input_bucket
s3 = boto3_client('s3')
list_obj = s3.list_objects_v2(Bucket=input_bucket)
try:
for item in list_obj["Contents"]:
key = item["Key"]
s3.delete_object(Bucket=input_bucket, Key=key)
except:
print("Nothing to clear in input bucket")

def clear_output_bucket():
global output_bucket
s3 = boto3_client('s3')
list_obj = s3.list_objects_v2(Bucket=output_bucket)
try:
for item in list_obj["Contents"]:
key = item["Key"]
s3.delete_object(Bucket=output_bucket, Key=key)
except:
print("Nothing to clear in output bucket")

def upload_to_input_bucket_s3(path, name):
global input_bucket
s3 = boto3_client('s3')
s3.upload_file(path + name, input_bucket, name)


def upload_files(test_case):
global input_bucket
global output_bucket
global test_cases


# Directory of test case
test_dir = test_cases + test_case + "/"

# Iterate over each video
# Upload to S3 input bucket
for filename in os.listdir(test_dir):
if filename.endswith(".mp4") or filename.endswith(".MP4"):
print("Uploading to input bucket.. name: " + str(filename))
upload_to_input_bucket_s3(test_dir, filename)


def workload_generator():

print("Running Test Case 1")
upload_files("test_case_1")

print("Running Test Case 2")
upload_files("test_case_2")


# clear_input_bucket()
clear_output_bucket()
workload_generator()



0 comments on commit 5315805

Please sign in to comment.