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
# sm = boto3.Session().client('sagemaker') | |
response = sm.search( | |
Resource='ExperimentTrialComponent', | |
SearchExpression={ | |
'Filters': [ | |
{ | |
'Name': 'Parents.ExperimentName', | |
'Operator': 'NotExists', | |
} |
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
{ | |
"Version": "2008-10-17", | |
"Id": "CrossAccountAccessExample", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::123456789123:user/admin" | |
}, | |
"Action": [ |
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 datetime | |
import luigi | |
import hashlib | |
from collections import defaultdict | |
import json | |
from os.path import join | |
# luigi --module tasks ReportStep --local-scheduler | |
# clean up: rm data/output_* |
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
gdoc = gdocrevisions.GoogleDoc(...) | |
slices = [] # save things here | |
gdoc.content.reset() # reset document | |
for i, revision in enumerate(gdoc.revisions): | |
gdoc.content.apply(revision) # apply revision | |
if i%100==1: # every 100th revision | |
slices.append(gdoc.content.render()) # save document state to slices | |
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 google.oauth2 import service_account | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
def get_oauth2_credentials(client_secrets_file, port=5555, scopes=SCOPES): | |
""" | |
Get google credentials via oauth flow | |
Opens up a browser for user to sign in | |
Requires client secrets file (select application type = 'other' when creating client in google console) | |
Sets default local web server port to 5555, since 8080 not usually available locally, but port can be specified as |
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 google.oauth2 import service_account | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
SCOPE = ['https://www.googleapis.com/auth/drive'] # example scope | |
def get_google_credentials_oauth2(client_secrets_file, port=5555): | |
""" | |
get credentials via oauth flow |
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 ECS django settings | |
""" | |
import requests | |
from .settings import * # may look different for your project | |
def get_ecs_task_ips(): | |
""" |
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
# 99_delete_awslogs_agent_state.sh: deletes awslogs agent state file so that | |
# agent starts monitoring logs for the most recently created container | |
files: | |
/opt/elasticbeanstalk/hooks/appdeploy/post/99_delete_awslogs_agent_state.sh: | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash |
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
# stick this file inside a folder whose contents you want to git ignore | |
[^.]* |
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 | |
from sqlalchemy import create_engine | |
from datetime import date | |
from s3fs import S3FileSystem | |
def create_db_engine(database=None,user=None,password=None,host=None,port=5432): | |
""" | |
Create sqlalchemy postgres engine from settings | |
""" |
NewerOlder