U
    -_g                     @   s2   d dl Z d dlmZmZmZ G dd deeZdS )    N)PluginIndependentPlugin	PluginOptc                   @   sX   e Zd ZdZd ZdZdZdZdZe	dde
dd	e	d
de
dd	e	ddddgZdd ZdS )InstructlabaL  
    This plugin is used to capture information about
    Instructlab installations.
    InstructLab is an open source project for enhancing
    large language models (LLMs) used in generative
    artificial intelligence (gen AI) applications.
    Instructlab can run either as a container, or directly
    outside a container.
    instructlab)Zai)r   ilab)r   	ilab-userz
cloud-userzuser that runs instructlab)defaultZval_typedescilab-conf-dir zinstructlab data directory	get-cacheFz#Capture models and osci cached data)r	   r
   c              	      s,  d}d}d}d}d} ||} ||} ||   d  d |d |d	g d
ddddg}dddddddddg	}	zdd d }
W n tk
r   d }
Y nX j| d| dg|
d j fdd|	D |
d jd d |D |
d j|d!|
d" d#r>j| |
d t	j
 d$}zt|}W n* tk
r   d%| d& Y d S X |r(|j}d'r |d'} || || fd(d|	D  j ||d!d) d#r( || d S )*Nz/usr/share/instructlab/configz/opt/app-root/srcz.cache/instructlabz.config/instructlabz.local/share/instructlabztaxonomy/.gitztaxonomy/.githubz*src/.local/share/instructlab/taxonomy/.gitz-src/.local/share/instructlab/taxonomy/.githubztaxonomy diffz#taxonomy diff --taxonomy-base=emptyzsystem infoz
model listzconfig showdataZ	generatedZtaxonomyZtaxonomy_dataZchatlogsZcheckpointsZdatasetsZinternalZphasedzinstructlab*r      z/rhel_ai_config.yamlz/config.yaml)	containerc                    s   g | ]}  |qS  	path_join.0Zdata_dir)cont_local_pathselfr   @/usr/lib/python3/dist-packages/sos/report/plugins/instructlab.py
<listcomp>g   s   z%Instructlab.setup.<locals>.<listcomp>c                 S   s   g | ]}d | qS )zilab r   )r   subr   r   r   r   l   s     T)	recursiver   r   r   zUser "z" does not exist, will not collect Instructlab information. Use `-k instructlab.ilab-user` option to define the user to use to collect data for Instructlabr   c                    s   g | ]}  |qS r   r   r   )data_dirs_baser   r   r   r      s   )r   )r   Zadd_forbidden_pathZget_all_containers_by_regex	ExceptionZadd_copy_specZadd_cmd_outputZadd_dir_listingZ
get_optionZadd_container_logslist
containerspwdgetpwnamKeyErrorZ	_log_warnpw_dir)r   Zcont_share_conf_pathZcont_opt_pathZ	cache_dirZ
config_dirZlocal_share_dirZcont_cache_pathZcont_config_pathZsubcmdsZ	data_dirsZilab_conZ	ilab_userZuser_pwdZilab_dirr   )r   r   r   r   setup)   s    
	


 

zInstructlab.setupN)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesr   Zcommandsr   strZoption_listr$   r   r   r   r   r      s"   
	r   )r    Zsos.report.pluginsr   r   r   r   r   r   r   r   <module>   s   