import os import numpy as np # garcon basics env = os.getenv('Environment', 'dev') version = '1.0' flow_name = 'ingest_training' # s3 paths if env == 'dev': s3_bucket = 's3://{env}-cucumbers/YouTubeDelivery'.format(env=env) s3_drop_path = '{bucket}/filedrop'.format(bucket=s3_bucket) else: s3_bucket = 's3://{env}-datalytics/etl/videoservices/delivery_review'.format(env=env) s3_drop_path = 's3://{env}-datalytics/filedrop/store/videoservices/delivery_review'.format(env=env) s3_archive_path = ('{bucket}/archive/{{year}}/{{month}}/' '{{run_date}}'.format(bucket=s3_bucket)) s3_processed_path = ('{bucket}/processed/{{year}}/{{month}}/' '{{run_date}}'.format(bucket=s3_bucket)) s3_model = '{bucket}/models/latest/'.format(bucket=s3_bucket) latest_model = s3_model + 'forest_*.pkl' next_model = s3_model + 'forest_{run_date}.pkl' s3_predictions = ('{bucket}/catalog_predictions/{{year}}/{{month}}/' '{{run_date}}_predictions.tsv.gz'.format(bucket=s3_bucket)) s3_machine_v_human = ('{bucket}/model_performance/{{year}}/{{month}}/' '{{run_date}}_perf.tsv.gz'.format(bucket=s3_bucket)) # snowflake things sf_db_config = { 'user': os.environ.get('SNOWFLAKE_USER'), 'password': os.environ.get('SNOWFLAKE_PASSWORD'), 'account': os.environ.get('SNOWFLAKE_ACCOUNT'), 'role': os.environ.get('SNOWFLAKE_ROLE'), 'warehouse': os.environ.get('SNOWFLAKE_WAREHOUSE'), 'db': os.environ.get('SNOWFLAKE_DATABASE'), 'schema': os.environ.get('SNOWFLAKE_SCHEMA') } sf_wh = 'SCIENCE' sf_fmt = 'LY_DEV.TEST.TSV_HEAD' sf_db = 'prod' sf_sch = 'delivery_review' sf_status_table = '.'.join([sf_db, sf_sch, 'youtube_delivery_status']) sf_results_delivered = '.'.join([sf_db, sf_sch,'youtube_delivery_history']) sf_predictions = '.'.join([sf_db, sf_sch,'youtube_ml_catalog_review']) sf_machine_v_human = '.'.join([sf_db, sf_sch,'machine_v_human']) sf_meta = '.'.join([sf_db, sf_sch,'youtube_delivery_metadata']) sf_results_stg = sf_results_delivered + '_stg' # sf_results_cat_stg = sf_results_stg + '_stg' # Google Sheets stuff sheetname = 'Review' sheet_id = '13JiMEkmbOQx3_LW9p4OBEKKD_nJGowQXsJxYL8o4w0g' sheet_range = 'A1:B' gdoc_col = 'Search in Artist or Release name?' rep_col = {'DELIVER TO YOUTUBE?': 'APPROVED'} tabs_to_exclude = ['Blacklisted Label', 'Various Artists', 'Suspected Non-exclusive'] # Regular constants for preprocessing target_dictionary = {'Yes' : 1, 'No' : 0, 'No ' : 0, 'NO' : 0, 'Yes ': 1, 'yes' : 1} float_cols = ['RELEASES_PER_ARTIST', 'HIDES_PER_ARTIST', 'UNITS_STREAMING_LABEL', 'RELEASES_PER_LABEL', 'ISRC_PER_RELEASE', 'AVERAGE_TRACK_DURATION', 'YEARS_SINCE_RELEASE'] bool_cols = ['IS_DELETED', 'IS_COMPILATION_X', 'IS_BLACKLISTED', 'IS_VARIOUS_ARTIST'] floats = {col: np.float for col in float_cols} bools = {col: bool for col in bool_cols} dtypes = {**floats, **bools} # what are we trying to optimize our model on? target = 'APPROVED' # what is model output? prob = 'MODEL_YES_PROB' # columns not used in to fit the model. cols_to_drop = ['ARTISTID', 'RELEASENAME', 'ARTISTNAME', 'DATE_ADDED', 'NOTE', 'UPC', 'LABELID', 'RELEASE_DATE', 'DATE_ADDED', 'IS_DELETED', 'GENREID_9', 'GENREID_25', 'GENREID_4', 'GENREID_5', 'GENREID_24', 'GENREID_17', 'PROCESS_DATE', # 'NOT_FOR_DISTROBUTION', #V2 GET THIS INTO SNOWFLAKE FIRST # 'AUDIO_OR_VIDEO' #V2 GET THIS INTO SNOWFLAKE FIRST ] cols_to_drop += [target, prob] # columns that can be null for a training set. null_cols = ['NOTE', 'PROCESS_DATE'] null_cols += [target, prob] genre_ids = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '24', '25', '27'] email_recipients = ['dataanalyticsdepartment@theorchard.com', 'ytprojects@theorchard.com'] email_header = 'New Deliveries Ingested' email_body = ('Model performance against hand-labeled reviews here: {}\n' 'Model performance over time here: {}\n' 'Latest catalog assessment here: {}\n')