diff --git a/RDS-postgres/SOUNDDRIP/.ebextensions/SounddripDev-env.config b/RDS-postgres/SOUNDDRIP/.ebextensions/SounddripDev-env.config new file mode 100644 index 0000000..9cb51c0 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/.ebextensions/SounddripDev-env.config @@ -0,0 +1,9 @@ +option_settings: + "aws:elasticbeanstalk:container:python": + WSGIPath: application.py +files: + "/etc/httpd/conf.d/wsgi_custom.conf": + mode: "000644" + owner: root + group: root + content: WSGIApplicationGroup %{GLOBAL} \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/.ebignore b/RDS-postgres/SOUNDDRIP/.ebignore new file mode 100644 index 0000000..795c120 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/.ebignore @@ -0,0 +1 @@ +sounddrip diff --git a/RDS-postgres/SOUNDDRIP/application.py b/RDS-postgres/SOUNDDRIP/application.py new file mode 100644 index 0000000..f1e598b --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/application.py @@ -0,0 +1,33 @@ +# import spotipy +# import spotipy.util as util +from flask import (Flask, render_template, request, + make_response, + jsonify) + +from models.predict import predictfunc, get_id, get_features, instantiate_sp + + +# Create Flask app. Should use "application" as variable name for AWS +application = Flask(__name__) + + + +# Main Default page +@application.route("/request", methods=['GET', 'POST']) +def prediction(): + ''''request flask route takes token passed in from FE POST and outputs the 20 most similar songs''' + content = request.get_json(silent=True) + token = content["token"] + sp = instantiate_sp(token) + id = get_id(sp) + features = get_features(id, sp) + return jsonify(predictfunc(features), print('yay')) + + +@application.route("/") +def root(): + return """Hello, I am working right now. send your request to {/request}""" + + +if __name__ == "__main__": + application.run() diff --git a/RDS-postgres/SOUNDDRIP/data/song_id_list2.joblib b/RDS-postgres/SOUNDDRIP/data/song_id_list2.joblib new file mode 100644 index 0000000..c93a7e2 Binary files /dev/null and b/RDS-postgres/SOUNDDRIP/data/song_id_list2.joblib differ diff --git a/RDS-postgres/SOUNDDRIP/data/song_id_list2.pkl b/RDS-postgres/SOUNDDRIP/data/song_id_list2.pkl new file mode 100644 index 0000000..46d471f Binary files /dev/null and b/RDS-postgres/SOUNDDRIP/data/song_id_list2.pkl differ diff --git a/RDS-postgres/SOUNDDRIP/misc/robots.txt b/RDS-postgres/SOUNDDRIP/misc/robots.txt new file mode 100644 index 0000000..14267e9 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/misc/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Allow: / \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/models/model2.joblib b/RDS-postgres/SOUNDDRIP/models/model2.joblib new file mode 100644 index 0000000..92aa842 Binary files /dev/null and b/RDS-postgres/SOUNDDRIP/models/model2.joblib differ diff --git a/RDS-postgres/SOUNDDRIP/models/original_model.py b/RDS-postgres/SOUNDDRIP/models/original_model.py new file mode 100644 index 0000000..99cbad8 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/models/original_model.py @@ -0,0 +1,37 @@ + """Ihis file contains def for spotify api""" +"""Data engnering, cosine_similarity, and all_similarities""" + +import spotipy +from spotipy.oauth2 import SpotifyClientCredentials +import pandas as pd +import numpy as np + +"""This def Grants access to spotify API""" +def cred_init(cli_id, cli_secret): + client_credentials_manager = SpotifyClientCredentials( + client_id=cli_id, + client_secret=cli_secret) + client_credentials_manager = client_credentials_manager + sp = spotipy.Spotify(client_credentials_manager= + client_credentials_manager) +return sp + +"""This def organizes pandas dataframe from a csv""" +def original_data_engnering(csv1, csv2): + df = pd.read_csv(csv1) + df_other = pd.read_csv(csv2) + df = df.drop('popularity', 1) + df = df.drop('duration_ms', 1) + df = df.dropna() + df_other = df_other.drop('popularity', 1) + df_other = df_other.drop('duration_ms', 1) + df_other = df_other.dropna() + df = pd.concat([df,df_other]). + drop_duplicates(). + reset_index(drop=True) + dfy = df[['artist_name','track_id', 'track_name']] + df2 = df.drop('artist_name', 1) + df2 = df2.drop('track_id', 1) + df2 = df2.drop('track_name', 1) + array = df2.values +return dfy, array \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/models/predict.py b/RDS-postgres/SOUNDDRIP/models/predict.py new file mode 100644 index 0000000..de740b7 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/models/predict.py @@ -0,0 +1,74 @@ +import spotipy +import spotipy.util as util +from sklearn.neighbors import NearestNeighbors +from sklearn.preprocessing import StandardScaler, MinMaxScaler +from flask import request +import pandas as pd +from pandas.io.json import json_normalize +from flask import jsonify +from joblib import load +import pickle + + +def instantiate_sp(token): + sp = spotipy.Spotify(auth=token) + return sp + + +def get_id(sp): + results = sp.current_user_saved_tracks() + song_id = results['items'][0]['track']['id'] + return song_id + + +def get_features(song_id,sp): + results_dict = sp.audio_features(song_id)[0] + audio_features = { + "audio_features": { + key: results_dict[key] for key in results_dict.keys() & { + 'danceability', + 'energy', + 'key', + 'loudness', + 'mode', + 'speechiness', + 'acousticness', + 'instrumentalness', + 'liveness', + 'valence', + 'tempo', + 'time_signature'}}} + + return audio_features + + +def predictfunc(content): + similar_songs = [] + print('Loading dataframe...') + dataframe = pd.DataFrame.from_dict( + json_normalize(content['audio_features']), + orient='columns') + print('Dataframe Object Created') + print('Loading pickled scaler...') + scaler = load('./models/scalar2.joblib') + print('Pickled scaler loaded') + print('Scaling dataframe object...') + dataframe_scaled = scaler.transform(dataframe) + print('Dataframe scaled') + print('Loading pickled model...') + model = load('./models/model2.joblib') + print('Model loaded') + results = model.kneighbors([dataframe_scaled][0])[1] + print('Prediction executed') + print('song_id_list loading...') + #song_id_list = load('./data/song_id_list2.joblib') + # (added 3.4 sec to run time) + song_id_list = pickle.load(open('./data/song_id_list2.pkl', 'rb')) + print('song_id_list loaded') + + print('beginning for loop...') + for song_row in results[0][1:]: + song_id = song_id_list[song_row] + similar_songs.append({'similarity': [.99], 'values': song_id}) + json_dict = {"songs": similar_songs} + return json_dict diff --git a/RDS-postgres/SOUNDDRIP/models/scalar2.joblib b/RDS-postgres/SOUNDDRIP/models/scalar2.joblib new file mode 100644 index 0000000..e1ea1c1 Binary files /dev/null and b/RDS-postgres/SOUNDDRIP/models/scalar2.joblib differ diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate new file mode 100644 index 0000000..6e6055c --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate @@ -0,0 +1,84 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + + +if [ "${BASH_SOURCE-}" = "$0" ]; then + echo "You must source this script: \$ source $0" >&2 + exit 33 +fi + +deactivate () { + unset -f pydoc >/dev/null 2>&1 + + # reset old environment variables + # ! [ -z ${VAR+_} ] returns true if VAR is declared at all + if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then + PATH="$_OLD_VIRTUAL_PATH" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then + PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null + fi + + if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then + PS1="$_OLD_VIRTUAL_PS1" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "${1-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +if ! [ -z "${PYTHONHOME+_}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1-}" + if [ "x" != x ] ; then + PS1="${PS1-}" + else + PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}" + fi + export PS1 +fi + +# Make sure to unalias pydoc if it's already there +alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true + +pydoc () { + python -m pydoc "$@" +} + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null +fi diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.csh b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.csh new file mode 100644 index 0000000..184267f --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.csh @@ -0,0 +1,55 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . + +set newline='\ +' + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres" + +set _OLD_VIRTUAL_PATH="$PATH:q" +setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q" + + + +if ("" != "") then + set env_name = "" +else + set env_name = '('"$VIRTUAL_ENV:t:q"') ' +endif + +if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then + if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then + set do_prompt = "1" + else + set do_prompt = "0" + endif +else + set do_prompt = "1" +endif + +if ( $do_prompt == "1" ) then + # Could be in a non-interactive environment, + # in which case, $prompt is undefined and we wouldn't + # care about the prompt anyway. + if ( $?prompt ) then + set _OLD_VIRTUAL_PROMPT="$prompt:q" + if ( "$prompt:q" =~ *"$newline:q"* ) then + : + else + set prompt = "$env_name:q$prompt:q" + endif + endif +endif + +unset env_name +unset do_prompt + +alias pydoc python -m pydoc + +rehash diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.fish b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.fish new file mode 100644 index 0000000..d67fbeb --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.fish @@ -0,0 +1,102 @@ +# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*. +# Do not run it directly. + +function _bashify_path -d "Converts a fish path to something bash can recognize" + set fishy_path $argv + set bashy_path $fishy_path[1] + for path_part in $fishy_path[2..-1] + set bashy_path "$bashy_path:$path_part" + end + echo $bashy_path +end + +function _fishify_path -d "Converts a bash path to something fish can recognize" + echo $argv | tr ':' '\n' +end + +function deactivate -d 'Exit virtualenv mode and return to the normal environment.' + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling + if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3 + set -gx PATH (_fishify_path $_OLD_VIRTUAL_PATH) + else + set -gx PATH $_OLD_VIRTUAL_PATH + end + set -e _OLD_VIRTUAL_PATH + end + + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + and functions -q _old_fish_prompt + # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`. + set -l fish_function_path + + # Erase virtualenv's `fish_prompt` and restore the original. + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + set -e _OLD_FISH_PROMPT_OVERRIDE + end + + set -e VIRTUAL_ENV + + if test "$argv[1]" != 'nondestructive' + # Self-destruct! + functions -e pydoc + functions -e deactivate + functions -e _bashify_path + functions -e _fishify_path + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres" + +# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling +if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3 + set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH) +else + set -gx _OLD_VIRTUAL_PATH $PATH +end +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset `$PYTHONHOME` if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +function pydoc + python -m pydoc $argv +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # Copy the current `fish_prompt` function as `_old_fish_prompt`. + functions -c fish_prompt _old_fish_prompt + + function fish_prompt + # Save the current $status, for fish_prompts that display it. + set -l old_status $status + + # Prompt override provided? + # If not, just prepend the environment name. + if test -n "" + printf '%s%s' "" (set_color normal) + else + printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV") + end + + # Restore the original $status + echo "exit $old_status" | source + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" +end diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.ps1 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.ps1 new file mode 100644 index 0000000..95504d3 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.ps1 @@ -0,0 +1,60 @@ +$script:THIS_PATH = $myinvocation.mycommand.path +$script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent + +function global:deactivate([switch] $NonDestructive) { + if (Test-Path variable:_OLD_VIRTUAL_PATH) { + $env:PATH = $variable:_OLD_VIRTUAL_PATH + Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global + } + + if (Test-Path function:_old_virtual_prompt) { + $function:prompt = $function:_old_virtual_prompt + Remove-Item function:\_old_virtual_prompt + } + + if ($env:VIRTUAL_ENV) { + Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue + } + + if (!$NonDestructive) { + # Self destruct! + Remove-Item function:deactivate + Remove-Item function:pydoc + } +} + +function global:pydoc { + python -m pydoc $args +} + +# unset irrelevant variables +deactivate -nondestructive + +$VIRTUAL_ENV = $BASE_DIR +$env:VIRTUAL_ENV = $VIRTUAL_ENV + +New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH + +$env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH +if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) { + function global:_old_virtual_prompt { + "" + } + $function:_old_virtual_prompt = $function:prompt + + if ("" -ne "") { + function global:prompt { + # Add the custom prefix to the existing prompt + $previous_prompt_value = & $function:_old_virtual_prompt + ("" + $previous_prompt_value) + } + } + else { + function global:prompt { + # Add a prefix to the current prompt, but don't discard it. + $previous_prompt_value = & $function:_old_virtual_prompt + $new_prompt_value = "($( Split-Path $env:VIRTUAL_ENV -Leaf )) " + ($new_prompt_value + $previous_prompt_value) + } + } +} diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.xsh b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.xsh new file mode 100644 index 0000000..7452e43 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate.xsh @@ -0,0 +1,46 @@ +"""Xonsh activate script for virtualenv""" +from xonsh.tools import get_sep as _get_sep + +def _deactivate(args): + if "pydoc" in aliases: + del aliases["pydoc"] + + if ${...}.get("_OLD_VIRTUAL_PATH", ""): + $PATH = $_OLD_VIRTUAL_PATH + del $_OLD_VIRTUAL_PATH + + if ${...}.get("_OLD_VIRTUAL_PYTHONHOME", ""): + $PYTHONHOME = $_OLD_VIRTUAL_PYTHONHOME + del $_OLD_VIRTUAL_PYTHONHOME + + if "VIRTUAL_ENV" in ${...}: + del $VIRTUAL_ENV + + if "VIRTUAL_ENV_PROMPT" in ${...}: + del $VIRTUAL_ENV_PROMPT + + if "nondestructive" not in args: + # Self destruct! + del aliases["deactivate"] + + +# unset irrelevant variables +_deactivate(["nondestructive"]) +aliases["deactivate"] = _deactivate + +$VIRTUAL_ENV = r"/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres" + +$_OLD_VIRTUAL_PATH = $PATH +$PATH = $PATH[:] +$PATH.add($VIRTUAL_ENV + _get_sep() + "bin", front=True, replace=True) + +if ${...}.get("PYTHONHOME", ""): + # unset PYTHONHOME if set + $_OLD_VIRTUAL_PYTHONHOME = $PYTHONHOME + del $PYTHONHOME + +$VIRTUAL_ENV_PROMPT = "" +if not $VIRTUAL_ENV_PROMPT: + del $VIRTUAL_ENV_PROMPT + +aliases["pydoc"] = ["python", "-m", "pydoc"] diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate_this.py b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate_this.py new file mode 100644 index 0000000..aa96457 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/activate_this.py @@ -0,0 +1,46 @@ +"""Activate virtualenv for current interpreter: + +Use exec(open(this_file).read(), {'__file__': this_file}). + +This can be used when you must use an existing Python interpreter, not the virtualenv bin/python. +""" +import os +import site +import sys + +try: + __file__ +except NameError: + raise AssertionError("You must use exec(open(this_file).read(), {'__file__': this_file}))") + +# prepend bin to PATH (this file is inside the bin directory) +bin_dir = os.path.dirname(os.path.abspath(__file__)) +os.environ["PATH"] = os.pathsep.join([bin_dir] + os.environ.get("PATH", "").split(os.pathsep)) + +base = os.path.dirname(bin_dir) + +# virtual env is right above bin directory +os.environ["VIRTUAL_ENV"] = base + +# add the virtual environments site-package to the host python import mechanism +IS_PYPY = hasattr(sys, "pypy_version_info") +IS_JYTHON = sys.platform.startswith("java") +if IS_JYTHON: + site_packages = os.path.join(base, "Lib", "site-packages") +elif IS_PYPY: + site_packages = os.path.join(base, "site-packages") +else: + IS_WIN = sys.platform == "win32" + if IS_WIN: + site_packages = os.path.join(base, "Lib", "site-packages") + else: + site_packages = os.path.join(base, "lib", "python{}.{}".format(*sys.version_info), "site-packages") + +prev = set(sys.path) +site.addsitedir(site_packages) +sys.real_prefix = sys.prefix +sys.prefix = base + +# Move the added items to the front of the path, in place +new = list(sys.path) +sys.path[:] = [i for i in new if i not in prev] + [i for i in new if i in prev] diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/chardetect b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/chardetect new file mode 100755 index 0000000..d685e4e --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/chardetect @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from chardet.cli.chardetect import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install new file mode 100755 index 0000000..302e078 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install-3.7 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install-3.7 new file mode 100755 index 0000000..302e078 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/easy_install-3.7 @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py new file mode 100755 index 0000000..fba380e --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3 new file mode 100755 index 0000000..fba380e --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3 @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3.7 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3.7 new file mode 100755 index 0000000..fba380e --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/f2py3.7 @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/flask b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/flask new file mode 100755 index 0000000..a972056 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/flask @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from flask.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/gunicorn b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/gunicorn new file mode 100755 index 0000000..aaff859 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/gunicorn @@ -0,0 +1,8 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from gunicorn.app.wsgiapp import run +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(run()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip new file mode 100755 index 0000000..9e28745 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from pip._internal.cli.main import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3 new file mode 100755 index 0000000..9e28745 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3 @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from pip._internal.cli.main import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3.7 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3.7 new file mode 100755 index 0000000..9e28745 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/pip3.7 @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from pip._internal.cli.main import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python new file mode 100755 index 0000000..5fefe8b Binary files /dev/null and b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python differ diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python-config b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python-config new file mode 100755 index 0000000..245f561 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python-config @@ -0,0 +1,78 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python + +import sys +import getopt +import sysconfig + +valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', + 'ldflags', 'help'] + +if sys.version_info >= (3, 2): + valid_opts.insert(-1, 'extension-suffix') + valid_opts.append('abiflags') +if sys.version_info >= (3, 3): + valid_opts.append('configdir') + + +def exit_with_usage(code=1): + sys.stderr.write("Usage: {0} [{1}]\n".format( + sys.argv[0], '|'.join('--'+opt for opt in valid_opts))) + sys.exit(code) + +try: + opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) +except getopt.error: + exit_with_usage() + +if not opts: + exit_with_usage() + +pyver = sysconfig.get_config_var('VERSION') +getvar = sysconfig.get_config_var + +opt_flags = [flag for (flag, val) in opts] + +if '--help' in opt_flags: + exit_with_usage(code=0) + +for opt in opt_flags: + if opt == '--prefix': + print(sysconfig.get_config_var('prefix')) + + elif opt == '--exec-prefix': + print(sysconfig.get_config_var('exec_prefix')) + + elif opt in ('--includes', '--cflags'): + flags = ['-I' + sysconfig.get_path('include'), + '-I' + sysconfig.get_path('platinclude')] + if opt == '--cflags': + flags.extend(getvar('CFLAGS').split()) + print(' '.join(flags)) + + elif opt in ('--libs', '--ldflags'): + abiflags = getattr(sys, 'abiflags', '') + libs = ['-lpython' + pyver + abiflags] + libs += getvar('LIBS').split() + libs += getvar('SYSLIBS').split() + # add the prefix/lib/pythonX.Y/config dir, but only if there is no + # shared library in prefix/lib/. + if opt == '--ldflags': + if not getvar('Py_ENABLE_SHARED'): + libs.insert(0, '-L' + getvar('LIBPL')) + if not getvar('PYTHONFRAMEWORK'): + libs.extend(getvar('LINKFORSHARED').split()) + print(' '.join(libs)) + + elif opt == '--extension-suffix': + ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') + if ext_suffix is None: + ext_suffix = sysconfig.get_config_var('SO') + print(ext_suffix) + + elif opt == '--abiflags': + if not getattr(sys, 'abiflags', None): + exit_with_usage() + print(sys.abiflags) + + elif opt == '--configdir': + print(sysconfig.get_config_var('LIBPL')) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3 new file mode 120000 index 0000000..d8654aa --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3.7 b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3.7 new file mode 120000 index 0000000..d8654aa --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/python3.7 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/bin/wheel b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/wheel new file mode 100755 index 0000000..4eeb148 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/bin/wheel @@ -0,0 +1,10 @@ +#!/Users/alexanderbennett/Desktop/repos/Music-Meteorologist-ds/RDS-postrges/SOUNDDRIP/RDS-postgres/bin/python +# -*- coding: utf-8 -*- +import re +import sys + +from wheel.cli import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/RDS-postgres/SOUNDDRIP/rds-postgres/include/python3.7m b/RDS-postgres/SOUNDDRIP/rds-postgres/include/python3.7m new file mode 120000 index 0000000..0dd104b --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/rds-postgres/include/python3.7m @@ -0,0 +1 @@ +/anaconda3/include/python3.7m \ No newline at end of file diff --git a/RDS-postgres/SOUNDDRIP/requirements.txt b/RDS-postgres/SOUNDDRIP/requirements.txt new file mode 100644 index 0000000..7dc3af7 --- /dev/null +++ b/RDS-postgres/SOUNDDRIP/requirements.txt @@ -0,0 +1,27 @@ +astroid==2.2.0 +certifi==2019.11.28 +chardet==3.0.4 +click==6.7 +Flask==1.1.1 +gunicorn==20.0.4 +idna==2.8 +itsdangerous==0.24 +Jinja2==2.10.1 +joblib==0.14.1 +lazy-object-proxy==1.4.3 +MarkupSafe==1.0 +numpy==1.18.1 +pandas==0.25.3 +psycopg2-binary==2.8.4 +python-dateutil==2.8.1 +pytz==2019.3 +requests==2.22.0 +scikit-learn==0.22.1 +scipy==1.4.1 +six==1.14.0 +sklearn==0.0 +spotipy==2.7.1 +typed-ast==1.4.1 +urllib3==1.25.8 +Werkzeug==0.15.0 +wrapt==1.11.2 diff --git a/model_notebooks/Postgres.ipynb b/model_notebooks/Postgres.ipynb new file mode 100644 index 0000000..db304f0 --- /dev/null +++ b/model_notebooks/Postgres.ipynb @@ -0,0 +1,335 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Connect to DB" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import psycopg2 as ps\n", + "\n", + "# define credentials \n", + "credentials = {'POSTGRES_ADDRESS' : 'test-1.cuxogj7vdjwn.us-east-1.rds.amazonaws.com', # change to your endpoint\n", + " 'POSTGRES_PORT' : '', # change to your port\n", + " 'POSTGRES_USERNAME' : 'postgres', # change to your username\n", + " 'POSTGRES_PASSWORD' : 'mypassword1!', # change to your password\n", + " 'POSTGRES_DBNAME' : 'postgres'} # change to your db name\n", + "\n", + "\n", + "# create connection and cursor \n", + "conn = ps.connect(host=credentials['POSTGRES_ADDRESS'],\n", + " database=credentials['POSTGRES_DBNAME'],\n", + " user=credentials['POSTGRES_USERNAME'],\n", + " password=credentials['POSTGRES_PASSWORD'],\n", + " port=credentials['POSTGRES_PORT'])\n", + "\n", + "cur = conn.cursor()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"SELECT * FROM pg_catalog.pg_tables\n", + " WHERE schemaname != 'pg_catalog'\n", + " AND schemaname != 'information_schema';\"\"\"\n", + "\n", + "cur.execute(query)\n", + "cur.fetchall()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create a table" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Table created successfully!\n" + ] + } + ], + "source": [ + "cur.execute(\"\"\"CREATE TABLE table_1\n", + " (column_1 int,\n", + " column_2 float,\n", + " column_3 varchar(50),\n", + " column_4 boolean);\"\"\")\n", + "\n", + "# Commit table creation\n", + "conn.commit()\n", + "\n", + "print(\"Table created successfully!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('public', 'table_1', 'postgres', None, False, False, False, False)]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"SELECT * FROM pg_catalog.pg_tables\n", + " WHERE schemaname != 'pg_catalog'\n", + " AND schemaname != 'information_schema';\"\"\"\n", + "\n", + "cur.execute(query)\n", + "cur.fetchall()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create many tables" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tables created successfully!\n" + ] + } + ], + "source": [ + "table_list = ['table_2', 'table_3', 'table_4', 'table_5']\n", + "for table_name in table_list:\n", + " cur.execute(\"\"\"CREATE TABLE {table_name}\n", + " (column_1 float,\n", + " column_2 float,\n", + " column_3 float,\n", + " column_4 float,\n", + " column_5 float);\"\"\".format(table_name=table_name))\n", + "\n", + "# Commit and close. Verify that tables were created successfully.\n", + "conn.commit()\n", + "\n", + "print(\"Tables created successfully!\")\n", + "# conn.close()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('public', 'table_1', 'postgres', None, False, False, False, False),\n", + " ('public', 'table_2', 'postgres', None, False, False, False, False),\n", + " ('public', 'table_3', 'postgres', None, False, False, False, False),\n", + " ('public', 'table_4', 'postgres', None, False, False, False, False),\n", + " ('public', 'table_5', 'postgres', None, False, False, False, False)]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"SELECT * FROM pg_catalog.pg_tables\n", + " WHERE schemaname != 'pg_catalog'\n", + " AND schemaname != 'information_schema';\"\"\"\n", + "\n", + "cur.execute(query)\n", + "cur.fetchall()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Insert one data entry" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "data = [1, 2.2, 'three', True]\n", + "insert_query = \"\"\"INSERT INTO table_1\n", + " (column_1, column_2, column_3, column_4)\n", + " VALUES (%s, %s, %s, %s);\"\"\"\n", + "\n", + "# execute insert\n", + "cur.execute(insert_query, data)\n", + " \n", + "# commit data insert\n", + "conn.commit()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(1, 2.2, 'three', True)]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cur.execute(\"\"\"SELECT * FROM table_1;\"\"\")\n", + "cur.fetchall()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Insert multiple entries" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "data = [[5, 5.5, 'five', True], [5, 5.5, 'five', True], [5, 5.5, 'five', True]]\n", + "insert_query = \"\"\"INSERT INTO table_1\n", + " (column_1, column_2, column_3, column_4)\n", + " VALUES (%s, %s, %s, %s);\"\"\"\n", + "\n", + "# execute multiple inserts\n", + "cur.executemany(insert_query, data)\n", + " \n", + "# commit data insert\n", + "conn.commit()" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(1, 2.2, 'three', True),\n", + " (5, 5.5, 'five', True),\n", + " (5, 5.5, 'five', True),\n", + " (5, 5.5, 'five', True)]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cur.execute(\"\"\"SELECT * FROM table_1;\"\"\")\n", + "cur.fetchall()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Drop Tables" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "cur.execute(\"\"\"DROP TABLE table_1\"\"\")\n", + "conn.commit()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "conn.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "sounddrip", + "language": "python", + "name": "sounddrip" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/model_notebooks/Untitled.ipynb b/model_notebooks/Untitled.ipynb deleted file mode 100644 index 2fd6442..0000000 --- a/model_notebooks/Untitled.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/model_notebooks/XGBoost_model_v1.ipynb b/model_notebooks/XGBoost_model_v1.ipynb deleted file mode 100644 index 5970fc5..0000000 --- a/model_notebooks/XGBoost_model_v1.ipynb +++ /dev/null @@ -1,67 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# importing all necessary libraries\n", - "\n", - "%matplotlib inline\n", - "import pandas as pd\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "\n", - "from sklearn.linear_model import LogisticRegression\n", - "from sklearn.model_selection import train_test_split\n", - "from sklearn.neighbors import KNeighborsClassifier\n", - "from sklearn.model_selection import cross_val_score\n", - "import xgboost as xgb\n", - "from xgboost.sklearn import XGBRegressor\n", - "from xgboost.sklearn import XGBClassifier" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# reading in pickled data\n", - "song_list = pd.read_pickle(\"./data/###.pkl\")\n", - "\n", - "# testing if successful read\n", - "song_list.head()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "NLPEnv (Python3)", - "language": "python", - "name": "nlpenv" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.0" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}