o
    "i                     @   s   d Z ddlZddlmZ ejdeee j	d d  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dlmZ ddlmZ ddlmZ ddlmZmZ defddZ dS )z"Tax taxonomy seeding orchestrator.    N)Path   base_platform)SessionLocal   )TAX_TYPE_TAGS)INDUSTRY_TAGS)KNOWLEDGE_ASSET_TAGS)VALIDITY_TAGS)REGIONAL_TAGS)RISK_MODEL_TAGS)OPTIMIZATION_TAGS)SCENARIO_TAGS)seed_tag_categoriescreate_tag_recursive	tenant_idc           
   
   C   s   t  }zizItd|  d t|| }ttttttt	t
d}d}| D ]\}}||}|r?|D ]}t|||j|  |d7 }q0q#|  td| d W n tye }	 z|  td|	   d	}	~	ww W |  d	S |  w )
z%Initialize tax taxonomy for a tenant.z Seeding tax taxonomy for tenant z...)tax_typeindustryknowledge_assetvalidityregional
risk_modeloptimizationscenarior   r   u   ✓ Tax taxonomy seeded: z
 root tagsu   ✗ Failed: N)r   printr   r   r   r	   r
   r   r   r   r   itemsgetr   idcommit	Exceptionrollbackclose)
r   db
categoriesmapping
root_countcodetagscategorytag_datae r+   V/lsinfo/ai/hellotax_ai/industry_accelerator/tax/scripts/seed/taxonomy/seed_taxonomy.pyseed_taxonomy   s>   


r-   )!__doc__syspathlibr   pathinsertstr__file__resolveparentsapp.db.sessionr   tax_type_tagsr   industry_tagsr   knowledge_asset_tagsr	   validity_tagsr
   regional_tagsr   risk_model_tagsr   optimization_tagsr   scenario_tagsr   tag_helpersr   r   intr-   r+   r+   r+   r,   <module>   s    $