Ë
    Ìi=  ã                   ó  — d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlm Z  ddl!m"Z" dZ#dZ$de%dee%ef   fd„Z& ed¬«       G d„ de
«      «       Z'y)é    N)Ú	dataclass)ÚAnyÚDictÚOptionalÚTuple)ÚCredentialsÚHasCredentials)Úload_yaml_text)ÚProfileConfig)ÚMissingProfileTarget)ÚCompilationErrorÚDbtProfileErrorÚDbtProjectErrorÚDbtRuntimeErrorÚProfileConfigError)Ú	get_flags)Úload_file_contents)ÚValidationError)Ú
fire_event)ÚDbtValidationErroré   )ÚProfileRendererzW
dbt encountered an error while trying to read your profiles.yml file.

{error_string}
Úprofiles_dirÚreturnc                 ór  — t         j                  j                  | d«      }d }t         j                  j                  |«      rB	 t	        |d¬«      }t        |«      }|s%d|› d�}t        t        j                  |¬«      «      ‚|S i S # t        $ r'}t        j                  |¬«      }t        |«      |‚d }~ww xY w)Núprofiles.ymlF)ÚstripzThe profiles.yml file at z	 is empty©Úerror_string)
ÚosÚpathÚjoinÚisfiler   r
   r   ÚINVALID_PROFILE_MESSAGEÚformatr   )r   r!   ÚcontentsÚyaml_contentÚmsgÚes         úS/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/dbt/config/profile.pyÚread_profiler+   !   s±   € Ü�7‰7�<‰<˜ nÓ5€Dà€HÜ	‡w�w‡~�~�dÔð		1Ü)¨$°eÔ<ˆHÜ)¨(Ó3ˆLÙØ1°$°°yÐA�Ü%Ô&=×&DÑ&DÐRUÐ&DÓ&VÓWÐWØÐð
 €Iøô	 "ò 	1Ü)×0Ñ0¸aÐ0Ó@ˆCÜ$ SÓ)¨qÐ0ûð	1ús   ÁA B Â	B6Â"B1Â1B6F)Úinitc                   óŽ  — e Zd ZU eed<   eed<   eed<   eed<   eeef   ed<   e	ed<   dededededdf
d	„Z
d!d
e	deeef   fd„Zdeeef   fd„Zdede	fd„Zd„ Zedeeef   dededefd„«       Ze	 d"dee   dee   defd„«       Zedeeef   dededeeef   fd„«       Zedededededd f
d„«       Zedeeef   dedee   dedeeeeef   f   f
d„«       Ze	 	 d#deeef   dededee   dee   dd fd„«       Ze	 	 d#deeef   dededee   dee   dd fd„«       Ze	 	 	 d$dedee   dee   dee   dee   dd fd „«       Zy)%ÚProfileÚprofile_nameÚtarget_nameÚthreadsÚcredentialsÚprofile_env_varsÚlog_cache_eventsr   Nc                 ó|   — || _         || _        || _        || _        i | _        t        «       j                  | _        y)zÊ
        TODO: Is this no longer needed now that 3.9 is no longer supported?
        Explicitly defining `__init__` to work around bug in Python 3.9.7
        https://bugs.python.org/issue45081
        N)r/   r0   r1   r2   r3   r   ÚLOG_CACHE_EVENTSr4   )Úselfr/   r0   r1   r2   s        r*   Ú__init__zProfile.__init__@   s>   € ð )ˆÔØ&ˆÔØˆŒØ&ˆÔØ "ˆÔä‹K×(Ñ(ð 	Õó    Úserialize_credentialsc                 ó¦   — | j                   | j                  | j                  | j                  dœ}|r| j                  j	                  d¬«      |d<   |S )am  Unlike to_project_config, this dict is not a mirror of any existing
        on-disk data structure. It's used when creating a new profile from an
        existing one.

        :param serialize_credentials bool: If True, serialize the credentials.
            Otherwise, the Credentials object will be copied.
        :returns dict: The serialized profile.
        ©r/   r0   r1   r2   T©Ú	omit_noner2   )r/   r0   r1   r2   Úto_dict)r7   r:   Úresults      r*   Úto_profile_infozProfile.to_profile_infoU   sU   € ð !×-Ñ-Ø×+Ñ+Ø—|‘|Ø×+Ñ+ñ	
ˆñ !Ø$(×$4Ñ$4×$<Ñ$<ÀtÐ$<Ó$LˆF�=Ñ!Øˆr9   c                 óö   — t        | j                  j                  d¬«      «      }|j                  | j                  j                  | j
                  | j                  | j                  | j                  dœ«       |S )NT)Úwith_aliases)Útyper1   Únamer0   r/   )Údictr2   Úconnection_infoÚupdaterD   r1   r0   r/   )r7   Útargets     r*   Úto_target_dictzProfile.to_target_dicth   si   € Ü�d×&Ñ&×6Ñ6ÀDÐ6ÓIÓJˆØ�‰à×(Ñ(×-Ñ-ØŸ<™<Ø×(Ñ(Ø#×/Ñ/Ø $× 1Ñ 1ñô	
ð ˆr9   Úotherc                 ó¨   — t        || j                  «      rt        | |j                  «      st        S | j                  «       |j                  «       k(  S ©N)Ú
isinstanceÚ	__class__ÚNotImplementedrA   )r7   rK   s     r*   Ú__eq__zProfile.__eq__u   s@   € Ü˜5 $§.¡.Ô1´jÀÀuÇÁÔ6WÜ!Ð!Ø×#Ñ#Ó%¨×)>Ñ)>Ó)@Ñ@Ð@r9   c                 ó  — 	 | j                   r7| j                   j                  d¬«      }| j                   j                  |«       | j                  d¬«      }t	        j                  |«       y # t
        $ r}t        |«      |‚d }~ww xY w)NTr=   )r:   )r2   r?   ÚvalidaterA   r   r   r   )r7   ÚdctÚexcs      r*   rS   zProfile.validatez   s{   € ð	3Ø×ÒØ×&Ñ&×.Ñ.¸Ð.Ó>�Ø× Ñ ×)Ñ)¨#Ô.Ø×&Ñ&¸TÐ&ÓBˆCÜ×"Ñ" 3Õ'øÜò 	3Ü$ SÓ)¨sÐ2ûð	3ús   ‚A*A- Á-	BÁ6BÂBÚprofilec                 ó   — ddl m} d| vrt        dj                  ||«      «      ‚| j	                  d«      }	  ||«      }|j                  | «      }|j                  |«       |j                  |«      }|S # t        t        f$ rI}t        |t        «      rt        |«      n|j                  }	t        dj                  |||	«      «      |‚d }~ww xY w)Nr   )Úload_pluginrD   z;required field "type" not found in profile {} and target {}z4Credentials in profile "{}", target "{}" invalid: {})Údbt.adapters.factoryrX   r   r%   ÚpopÚtranslate_aliasesrS   Ú	from_dictr   r   rN   ÚstrÚmessage)
rV   r/   r0   rX   ÚtypenameÚclsÚdatar2   r)   r(   s
             r*   Ú_credentials_from_profilez!Profile._credentials_from_profile„   sØ   € õ
 	5ð ˜Ñ Ü!ØM×TÑTØ  +óóð ð —;‘;˜vÓ&ˆð	Ù˜hÓ'ˆCØ×(Ñ(¨Ó1ˆDØ�L‰L˜ÔØŸ-™-¨Ó-ˆKð Ðøô  ¤Ð1ò 	Ü& q¬/Ô:”#�a”&ÀÇ	Á	ˆCÜ!ØF×MÑMØ  +¨sóóð ð	ûð	ús   ¸;A5 Á5CÂACÃCÚargs_profile_nameÚproject_profile_namec                 ó`   — d„ }|}| �| }|€"dj                   |«       ¬«      }t        |«      ‚|S )Nc                  ó–   — ddl m}  | j                  «       dz  j                  «       r| j                  «       S | j	                  «       dz  S )Nr   ©ÚPathr   z.dbt)Úpathlibrh   ÚcwdÚexistsÚhomerg   s    r*   Údefault_profiles_dirz7Profile.pick_profile_name.<locals>.default_profiles_dir­   s8   € Ý$à"&§(¡(£*¨~Ñ"=×!EÑ!EÔ!G�4—8‘8“:ÐaÈTÏYÉYË[Ð[aÑMaÐar9   a[  dbt cannot run because no profile was specified for this dbt project.
To specify a profile for this project, add a line like the this to
your dbt_project.yml file:

profile: [profile name]

Here, [profile name] should be replaced with a profile name
defined in your profiles.yml file. You can find profiles.yml here:

{profiles_file}/profiles.yml
)Úprofiles_file)r%   r   )rc   rd   rm   r/   ÚNO_SUPPLIED_PROFILE_ERRORs        r*   Úpick_profile_namezProfile.pick_profile_name¤   sU   € ò	bð
 ,ˆØÐ(Ø,ˆLØÐð)÷ �FÙ2Ó4ð ó ð &ô "Ð";Ó<Ð<ØÐr9   c                 ó  — d| vrt        dj                  |«      «      ‚| d   }||vr8dj                  d„ |D «       «      }dj                  |||«      }t        |d¬«      ‚||   }t        |t        «      sd|› d	|› d
�}t        |d¬«      ‚|S )NÚoutputsz%outputs not specified in profile '{}'ú
c              3   ó>   K  — | ]  }d j                  |«      –— Œ y­w)z - {}N)r%   )Ú.0Úoutputs     r*   ú	<genexpr>z,Profile._get_profile_data.<locals>.<genexpr>Ð   s   è ø€ ÒM¸6 §¡¨v× 6ÑMùs   ‚zcThe profile '{}' does not have a target named '{}'. The valid target names for this profile are:
{}Úinvalid_target)Úresult_typezoutput 'z' of profile 'z"' is misconfigured in profiles.yml)r   r%   r"   rN   rF   )rV   r/   r0   rr   r(   Úprofile_datas         r*   Ú_get_profile_datazProfile._get_profile_dataÇ   s½   € ð ˜GÑ#Ü!Ð"I×"PÑ"PÐQ]Ó"^Ó_Ð_Ø˜)Ñ$ˆà˜gÑ%Ø—i‘iÑMÀWÔMÓMˆGð?ß?E¹vØ  +¨wó@ð ô " #Ð3CÔDÐDØ˜{Ñ+ˆä˜,¬Ô-à˜;˜- ~°l°^ð D0ð 1ð ô " #Ð3CÔDÐDàÐr9   c                 ó>   —  | ||||¬«      }|j                  «        |S )aÜ  Create a profile from an existing set of Credentials and the
        remaining information.

        :param credentials: The credentials dict for this profile.
        :param threads: The number of threads to use for connections.
        :param profile_name: The profile name used for this profile.
        :param target_name: The target name used for this profile.
        :raises DbtProfileError: If the profile is invalid.
        :returns: The new Profile object.
        r<   )rS   )r`   r2   r1   r/   r0   rV   s         r*   Úfrom_credentialszProfile.from_credentialsã   s-   € ñ& Ø%Ø#ØØ#ô	
ˆð 	×ÑÔØˆr9   Úraw_profileÚtarget_overrideÚrendererc                 ó  — |�|}n1d|v r|j                  |d   «      }nd}t        t        ||¬«      «       | j                  |||«      }	 |j	                  |«      }||fS # t
        $ r}t        t        |«      «      |‚d}~ww xY w)zYThis is a containment zone for the hateful way we're rendering
        profiles.
        NrI   Údefault)r/   r0   )Úrender_valuer   r   r{   Úrender_datar   r   r]   )	r`   r~   r/   r   r€   r0   Úraw_profile_datarz   rU   s	            r*   Úrender_profilezProfile.render_profileÿ   s�   € ð$ Ð&Ø)‰KØ˜Ñ$à"×/Ñ/°¸HÑ0EÓF‰Kà#ˆKÜÔ+¸ÐS^Ô_Ô`à×0Ñ0°¸lÈKÓXÐð	5Ø#×/Ñ/Ð0@ÓAˆLð ˜LÐ(Ð(øô  ò 	5Ü!¤# c£(Ó+°Ð4ûð	5ús   ÁA  Á 	BÁ)A>Á>BÚthreads_overridec                 ó´   — | j                  ||||«      \  }}|j                  dt        «      }|�|}| j                  |||«      }	| j	                  |	|||¬«      S )aÑ  Create a profile from its raw profile information.

         (this is an intermediate step, mostly useful for unit testing)

        :param raw_profile: The profile data for a single profile, from
            disk as yaml and its values rendered with jinja.
        :param profile_name: The profile name used.
        :param renderer: The config renderer.
        :param target_override: The target to use, if provided on
            the command line.
        :param threads_override: The thread count to use, if
            provided on the command line.
        :raises DbtProfileError: If the profile is invalid or missing, or the
            target could not be found
        :returns: The new Profile object.
        r1   )r2   r/   r0   r1   )r†   rZ   ÚDEFAULT_THREADSrb   r}   )
r`   r~   r/   r€   r   r‡   r0   rz   r1   r2   s
             r*   Úfrom_raw_profile_infozProfile.from_raw_profile_info"  s~   € ð4 %(×$6Ñ$6Ø˜ ¸ó%
Ñ!ˆ�\ð ×"Ñ" 9¬oÓ>ˆØÐ'Ø&ˆGà#&×#@Ñ#@Ø˜,¨ó$
ˆð ×#Ñ#Ø#Ø%Ø#Øð	 $ó 
ð 	
r9   Úraw_profilesc                 óÂ   — ||vrt        dj                  |«      «      ‚||   }|s%d|› d�}t        t        j                  |¬«      «      ‚| j	                  |||||¬«      S )a”  
        :param raw_profiles: The profile data, from disk as yaml.
        :param profile_name: The profile name to use.
        :param renderer: The config renderer.
        :param target_override: The target to use, if provided on the command
            line.
        :param threads_override: The thread count to use, if provided on the
            command line.
        :raises DbtProjectError: If there is no profile name specified in the
            project or the command line arguments
        :raises DbtProfileError: If the profile is invalid or missing, or the
            target could not be found
        :returns: The new Profile object.
        z!Could not find profile named '{}'zProfile z in profiles.yml is emptyr   )r~   r/   r€   r   r‡   )r   r%   r   r$   rŠ   )r`   r‹   r/   r€   r   r‡   r~   r(   s           r*   Úfrom_raw_profileszProfile.from_raw_profilesQ  s‚   € ð. ˜|Ñ+Ü!Ð"E×"LÑ"LÈ\Ó"ZÓ[Ð[ð # <Ñ0ˆÙØ˜\˜NÐ*CÐDˆCÜ!Ô"9×"@Ñ"@ÈcÐ"@Ó"RÓSÐSà×(Ñ(Ø#Ø%ØØ+Ø-ð )ó 
ð 	
r9   Úprofile_name_overridec                 ó�   — t        «       }t        |j                  «      }| j                  ||«      }| j	                  |||||¬«      S )a¿  Given the raw profiles as read from disk and the name of the desired
        profile if specified, return the profile component of the runtime
        config.

        :param args argparse.Namespace: The arguments as parsed from the cli.
        :param project_profile_name Optional[str]: The profile name, if
            specified in a project.
        :raises DbtProjectError: If there is no profile name specified in the
            project or the command line arguments, or if the specified profile
            is not found
        :raises DbtProfileError: If the profile is invalid or missing, or the
            target could not be found.
        :returns Profile: The new Profile object.
        )r‹   r/   r€   r   r‡   )r   r+   ÚPROFILES_DIRrp   r�   )	r`   r€   rd   rŽ   r   r‡   Úflagsr‹   r/   s	            r*   ÚrenderzProfile.renderz  sV   € ô. “ˆÜ# E×$6Ñ$6Ó7ˆØ×,Ñ,Ð-BÐDXÓYˆØ×$Ñ$Ø%Ø%ØØ+Ø-ð %ó 
ð 	
r9   )FrM   )NN)NNN)Ú__name__Ú
__module__Ú__qualname__r]   Ú__annotations__Úintr   r   r   Úboolr8   rA   rJ   ÚobjectrQ   rS   Ústaticmethodrb   r   rp   r{   Úclassmethodr}   r   r   r†   rŠ   r�   r’   © r9   r*   r.   r.   7   sG  … àÓØÓØƒLØÓØ˜3 ˜8‘nÓ$ØÓð
àð
ð ð
ð ð	
ð
 !ð
ð 
ó
ñ*°Tð ÀdÈ3ÐPSÈ8Ánó ð&  S¨# X¡ó ðA˜Fð A tó Aò
3ð ðØ�c˜3�h‘ðØ/2ðØADðà	òó ðð> ð /3ñ Ø# C™=ð à& s™mð ð 
ò ó ð ðD ðØ�c˜3�h‘ðØ/2ðØADðà	ˆc�3ˆh‰òó ðð6 ðà ðð ðð ð	ð
 ðð 
òó ðð6 ð )à˜#˜s˜(‘^ð )ð ð )ð " #™ð	 )ð
 "ð )ð 
ˆs�D˜˜c˜‘NÐ"Ñ	#ò )ó ð )ðD ð *.Ø*.ñ,
à˜#˜s˜(‘^ð,
ð ð,
ð "ð	,
ð
 " #™ð,
ð # 3™-ð,
ð 
ò,
ó ð,
ð\ ð *.Ø*.ñ&
à˜3 ˜8‘nð&
ð ð&
ð "ð	&
ð
 " #™ð&
ð # 3™-ð&
ð 
ò&
ó ð&
ðP ð
 04Ø)-Ø*.ñ
à!ð
ð ' s™mð
ð  (¨™}ð	
ð
 " #™ð
ð # 3™-ð
ð 
ò
ó ñ
r9   r.   )(r    Údataclassesr   Útypingr   r   r   r   Ú!dbt.adapters.contracts.connectionr   r	   Údbt.clients.yaml_helperr
   Údbt.contracts.projectr   Údbt.events.typesr   Údbt.exceptionsr   r   r   r   r   Ú	dbt.flagsr   Údbt_common.clients.systemr   Údbt_common.dataclass_schemar   Údbt_common.events.functionsr   Údbt_common.exceptionsr   r€   r   r‰   r$   r]   r+   r.   rœ   r9   r*   ú<module>r©      s†   ðÛ 	Ý !ß -Ó -ç IÝ 2Ý /Ý 1÷õ õ  Ý 8Ý 7Ý 2Ý 4å %à€ðÐ ð˜sð  t¨C°¨H¡~ó ñ, �Ôôb
ˆnó b
ó ñb
r9   