This file contains 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
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
This file contains 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
apiVersion: v1 | |
clusters: | |
- cluster: | |
certificate-authority-data: <certificateAuthority.data from describe-cluster> | |
server: <endpoint from describe-cluster> | |
name: <cluster-name> | |
contexts: | |
- context: | |
cluster: <cluster-name> | |
user: aws |
This file contains 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
""" | |
Utils to interact with DB using pg8000 library | |
Note: assumes py3.5+ | |
[Example usage] | |
# OPTIONALLY retrieve DB password from AWS SSM | |
import boto3 |
This file contains 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
""" | |
Utilities common to all tests using spark | |
""" | |
import pytest | |
from pyspark.sql import SparkSession | |
from pyspark import SparkContext, SparkConf | |
import logging |
This file contains 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 tests.test_utils.test_spark import spark_session | |
from pyspark.sql import DataFrame, Row, SparkSession | |
from pyspark.sql.functions import col | |
from src.job import amount_spent_udf | |
def test_amount_spent_udf(spark_session: SparkSession) -> None: | |
input_df = spark_session.createDataFrame([ | |
Row(customer_name="Geoffrey", date="2016-04-22", category="Foo", product_name="Bar", quantity=1, price=2.00), |
This file contains 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
# create the general function | |
def _amount_spent(quantity: int, price: float) -> float: | |
""" | |
Calculates the product between two variables | |
:param quantity: (float/int) | |
:param price: (float/int) | |
:return: | |
(float/int) | |
""" | |
return quantity * price |
This file contains 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
my_string = """ | |
your string \n seperated \n by \n new \n lines. | |
""" | |
account_id = '12345678910' | |
region = 'eu-west-1' | |
parameter_name = 'some-secret-name' | |
key_id = 'your-key-id' |
This file contains 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
# Redshift - check currently running queries; useful for misbehaving queries; | |
SELECT | |
userid | |
, query | |
, pid | |
, starttime | |
, left(text, 100) as query | |
FROM stv_inflight; |
This file contains 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
################################################################################ | |
# AWS Lambda IAM Policy document definitions | |
################################################################################ | |
data "aws_iam_policy_document" "this" { | |
statement { | |
effect = "Allow" | |
actions = [ | |
"s3:GetBucketLocation", |
This file contains 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
################################################################################ | |
# Locals used for different Lambdas Environmental Variables | |
################################################################################ | |
locals { | |
redshift_loader_lambda_env_vars = { | |
ENVIRONMENT = "${var.environment}" | |
REGION = "${var.aws_region}" | |
IAM_ROLE = "${var.redshift_data_loader_lambda_iam_role}" |