o
    ” sj×  ã                   @   sR  d Z ddlZddlmZ zddlmZ W n ey!   dd„ ZY nw eeƒ ¡ j	j	d Z
ee
ƒ dd	„ Zeƒ Ze d
d¡e dd¡ee dd¡ƒe dd¡e dd¡e dd¡ee dd¡ƒdœZe dd¡Ze dd¡Ze dd¡Ze dd¡Zeeƒ ¡ j	d  Zejd!d"� ee d#d$¡ƒZg d%¢Zg d&¢ZeZd'Zd(Zd)ed*efd+d,„ZdS )-zj
Configuration for the churn prediction ML pipeline.
Reads database credentials from Laravel's .env file.
é    N)ÚPath)Úload_dotenvc                  O   s   dS )NF© )Ú_argsÚ_kwargsr   r   úml/config.pyr      s   r   z.envc                  C   s‚   t  d¡} | r#ddlm} || ƒ}|j|jpd|j d¡|j|j	dœS t  dd¡t
t  d	d¡ƒt  d
d¡t  dd¡t  dd¡dœS )z?Parse DATABASE_URL if available, otherwise use individual vars.ÚDATABASE_URLr   )Úurlparsei8  ú/)ÚhostÚportÚdbnameÚuserÚpasswordÚDB_HOSTz	127.0.0.1ÚDB_PORTÚDB_DATABASEÚ	sms_adminÚDB_USERNAMEÚpostgresÚDB_PASSWORDÚ )ÚosÚgetenvÚurllib.parser	   Úhostnamer   ÚpathÚlstripÚusernamer   Úint)Úurlr	   Úparsedr   r   r   Ú_parse_db_url   s    

û
	


ûr"   ÚCLICKHOUSE_SCHEMEÚhttpÚCLICKHOUSE_HOSTr   ÚCLICKHOUSE_PORTi»  ÚCLICKHOUSE_DATABASEÚ
clickhouseÚCLICKHOUSE_USERNAMEÚdefaultÚCLICKHOUSE_PASSWORDÚCLICKHOUSE_TIMEOUT_SECONDSéx   )Úschemer   r   Údatabaser   r   Útimeout_secondsÚAI_CHURN_FEATURE_STORE_TABLEÚchurn_feature_storeÚAI_CHURN_MODEL_REGISTRY_TABLEÚchurn_model_registryÚAI_CHURN_PREDICTIONS_TABLEÚchurn_predictionsÚAI_CHURN_TRAINING_LABELS_TABLEÚchurn_training_labelsÚmodelsT)Úexist_okÚCHURN_APP_IDÚ0)Úcustomer_tenure_daysÚdays_since_last_loginÚtotal_subscriptionsÚactive_subscription_countÚdays_until_expiryÚauto_renew_enabledÚsubscription_priceÚfailed_payment_count_30dÚfailed_payment_count_90dÚpayment_failure_rateÚsubscription_gap_daysÚhas_downgradedÚtotal_revenueÚavg_order_valueÚrevenue_trendÚcoupon_userÚrenewal_rateÚhas_ever_churnedÚchurns_count)Úwatch_count_7dÚwatch_count_30dÚwatch_count_90dÚtotal_watch_duration_30dÚavg_watch_durationÚdays_since_last_watchÚwatch_count_decline_pctÚduration_decline_pctÚunique_categories_30dÚbinge_sessions_30dÚis_currently_watchingÚcontent_type_diversityéÈ   zlgbm_global.pklÚapp_idÚreturnc                 C   s   d| › d�S )z5Return the pickle filename for an app-specific model.Úlgbm_model_app_z.pklr   )r]   r   r   r   Úapp_model_filename{   s   r`   )Ú__doc__r   Úpathlibr   Údotenvr   ÚModuleNotFoundErrorÚ__file__ÚresolveÚparentÚ	_env_pathr"   Ú	DB_CONFIGr   r   ÚCLICKHOUSE_CONFIGÚCHURN_FEATURE_STORE_TABLEÚCHURN_MODEL_REGISTRY_TABLEÚCHURN_PREDICTIONS_TABLEÚCHURN_TRAINING_LABELS_TABLEÚ	MODEL_DIRÚmkdirÚDEFAULT_APP_IDÚPHASE1_FEATURE_COLUMNSÚPHASE2_FEATURE_COLUMNSÚFEATURE_COLUMNSÚMIN_TRAINING_SAMPLESÚGLOBAL_MODEL_FILENAMEÚstrr`   r   r   r   r   Ú<module>   sB    þ




ù
