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 airflow.models import DAG | |
from airflow.operators.s3_file_transform_operator import S3FileTransformOperator | |
from datetime import datetime | |
with DAG(dag_id='simple_s3_copy', | |
schedule_interval=None, | |
start_date=datetime(2019, 6, 7)) as dag: | |
copy_file_over = S3FileTransformOperator( | |
task_id='copy_file_over', |
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
export AIRFLOW_CONN_AWS_DEFAULT="s3://$AWS_CLIENT_ID:$AWS_CLIENT_SECRET@my-bucket?region_name=$AWS_REGION" |
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
class XComEnabledAWSAthenaOperator(AWSAthenaOperator): | |
def execute(self, context): | |
super(XComEnabledAWSAthenaOperator, self).execute(context) | |
# just so that this gets `xcom_push`(ed) | |
return self.query_execution_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
from airflow.models import DAG | |
from airflow.contrib.operators.aws_athena_operator import AWSAthenaOperator | |
from airflow.operators.s3_file_transform_operator import S3FileTransformOperator | |
from datetime import datetime | |
class XComEnabledAWSAthenaOperator(AWSAthenaOperator): | |
def execute(self, context): | |
super(XComEnabledAWSAthenaOperator, self).execute(context) | |
# just so that this gets `xcom_push`(ed) | |
return self.query_execution_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
#!/usr/bin/env python3 | |
import pandas as pd | |
import sys | |
pd.read_csv(sys.argv[1]).to_parquet(sys.argv[2]) |
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
import os | |
import site | |
from setuptools.command import easy_install | |
install_path = os.environ['GLUE_INSTALLATION'] | |
easy_install.main( ["--install-dir", install_path, "torch"] ) | |
reload(site) | |
import torch | |
print(torch.__version__) |
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
import logging | |
import os | |
import json | |
import urllib3 | |
import datetime | |
AIRFLOW_URL = os.environ['AIRFLOW_URL'] | |
DAG_ID = 'my_helpful_dag' | |
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'info').upper() |
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
import xlsxwriter | |
workbook = xlsxwriter.Workbook('rich_strings.xlsx') | |
bold = workbook.add_format({'bold': True}) | |
italic = workbook.add_format({'italic': True}) | |
worksheet.write_rich_string('A1', | |
'This is ', | |
bold, 'bold', |
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
import pandas as pd | |
df = pd.DataFrame([ | |
{ | |
'original': "Can you tell us a bit more abt how scalable your solution is?", | |
'edited': "Can you tell us a bit more about how scalable your solution is?", | |
}, | |
{ | |
'original': "What will our priorities be for the next quarter?", | |
'edited': "What will our priorities be for the next year?", | |
}, |
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
sheet_name = 'to_review' | |
excel_writer = pd.ExcelWriter("edited_questions.xlsx", engine='xlsxwriter') | |
df.to_excel(excel_writer, sheet_name=sheet_name, index=False) | |
workbook = excel_writer.book | |
worksheet = excel_writer.sheets[sheet_name] | |
green = workbook.add_format({'color': 'green'}) | |
red = workbook.add_format({'color': 'red'}) | |
b_green = workbook.add_format({'color': 'green', 'bold': True}) |