-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[instructlab] Add new plugin for Instructlab #3804
[instructlab] Add new plugin for Instructlab #3804
Conversation
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
Looking forward to suggestions about cleaning up this a bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some initial comments
8816821
to
0e4cd28
Compare
sos/report/plugins/instructlab.py
Outdated
_containers = self.get_containers() | ||
|
||
for _con in _containers: | ||
if _con[1].startswith('instructlab'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the Plugin()
container methods for returning only containers of a certain name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
sos/report/plugins/instructlab.py
Outdated
in_container = True | ||
container_names.append(_con[1]) | ||
|
||
if in_container: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this ever run outside a container? If not, we can drop the conditional. If yes, then why do we not collect these when instructlab is running on the host directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in version 1.1 of RHEL AI, instructlab can run both in a container and outside a container, in the same installation. This may change for 1.2 and later
sos/report/plugins/instructlab.py
Outdated
self.add_copy_spec( | ||
[f'{cont_share_conf_path}rhel_ai_config.yaml', | ||
f'{cont_config_path}/config.yaml'], | ||
container=cont) | ||
self.add_copy_spec( | ||
[f"{cont_local_path}/{data_dir}" | ||
for data_dir in data_dirs], | ||
container=cont | ||
) | ||
self.add_cmd_output( | ||
[f"ilab {sub}" for sub in subcmds], | ||
container=cont | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long standing sos style is to open and close the list bracket and method parens on the same line, with the contents indented.
self.add_copy_spec([
f"{thing}",
f"{thing2}"
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
sos/report/plugins/instructlab.py
Outdated
ilab_user = self.get_option("ilab_user") if \ | ||
self.get_option("ilab_user") else '' | ||
if ilab_user: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TurboTurtle we are more than happy to go ahead with py38 as agreed for future developments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As stated in the #3533, ok for us as well.
sos/report/plugins/instructlab.py
Outdated
ilab_user = self.get_option("ilab_user") if \ | ||
self.get_option("ilab_user") else '' | ||
if ilab_user: | ||
ilab_dir = f'/home/{ilab_user}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not guaranteed for this to be the home dir of the given user. The plugin should determine the correct home dir rather than hardcoding an assumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of RHEL AI it is... the default user will live in /home always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't one override the home directory (of one user or all)? Well, the bootc's kickstart will create the home directory there, but the KS template can be customized (and the docs even assumes the /home/<user>
is not hardcoded, per sentence "The default location for the InstructLab data is in the home/ directory."). So I would vote for kind-of ~{ilab_user}
approach than the hardcoded path.
sos/report/plugins/instructlab.py
Outdated
if self.get_option("ilab_conf_dir"): | ||
ilab_dir = f'{ilab_dir}{self.get_option("ilab_conf_dir")}' | ||
data_dirs_base = f'{ilab_dir}{local_share_dir}' | ||
|
||
self.add_copy_spec(f"{ilab_dir}{config_dir}") | ||
self.add_copy_spec([ | ||
f"{data_dirs_base}/{data_dir}" for data_dir in data_dirs | ||
]) | ||
self.add_dir_listing(f"{ilab_dir}/{cache_dir}", | ||
recursive=True) | ||
|
||
if self.get_option("get-cache"): | ||
self.add_copy_spec( | ||
f'{ilab_dir}/{cache_dir}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: be consistent with the use of single or double quotes for f-strings. I personally use double-quotes for any f-string substitutions though I'm not of the mind to impose that as a project style, but it is helpful to be consistent within a plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I totally missed to change this while reviewing, sorry
sos/report/plugins/instructlab.py
Outdated
[f'{cont_share_conf_path}rhel_ai_config.yaml', | ||
f'{cont_config_path}/config.yaml'], | ||
container=cont) | ||
self.add_copy_spec( | ||
[f"{cont_local_path}/{data_dir}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is harder to follow what paths we're working with when some of the variables include the trailing /
in dirs and others do not. This should be consistent within a given plugin even if we don't have a formal style recommendation for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, missed arranging some consistency while reviewing. Will fix this as well in t he next push
sos/report/plugins/instructlab.py
Outdated
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos.report.plugins import (Plugin, IndependentPlugin, PluginOpt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous parenthesis when imports don't span multiple lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
sos/report/plugins/instructlab.py
Outdated
class Instructlab(Plugin, IndependentPlugin): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A docstring explaining what the plugin is for and a high-level explanation of collections and options should be added for use with sos help
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
0e4cd28
to
c824e89
Compare
sos/report/plugins/instructlab.py
Outdated
cont_cache_path = f"{cont_opt_path}{cache_dir}" | ||
cont_config_path = f"{cont_opt_path}{config_dir}" | ||
cont_local_path = f"{cont_opt_path}{local_share_dir}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer using os.path.join
method to joining.. well.. paths :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
c824e89
to
5b94214
Compare
sos/report/plugins/instructlab.py
Outdated
ilab_dir = os.path.join("~/", ilab_user) | ||
if self.get_option("ilab_conf_dir"): | ||
ilab_dir = os.path.join( | ||
ilab_dir, self.get_option('ilab_conf_dir') | ||
) | ||
data_dirs_base = os.path.join(ilab_dir, local_share_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugin.path_join()
accounts for non-/ sysroot.
Use pwd
to source the homedir for the given user instead of relying on shell translation.
sos/report/plugins/instructlab.py
Outdated
self.add_copy_spec(f"{ilab_dir}{config_dir}") | ||
self.add_copy_spec([ | ||
f"{data_dirs_base}/{data_dir}" for data_dir in data_dirs | ||
]) | ||
self.add_dir_listing(f"{ilab_dir}/{cache_dir}", | ||
recursive=True) | ||
|
||
if self.get_option("get-cache"): | ||
self.add_copy_spec( | ||
f'{ilab_dir}/{cache_dir}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugin.path_join()
here as well. Be consistent.
sos/report/plugins/instructlab.py
Outdated
ilab_con = None | ||
for con in self.containers: | ||
if self.get_container_by_name(con): | ||
ilab_con = con | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be significantly more efficient and readable as a one-liner using the regex supporting container method.
sos/report/plugins/instructlab.py
Outdated
self.add_copy_spec( | ||
[f"{cont_share_conf_path}/rhel_ai_config.yaml", | ||
f"{cont_config_path}/config.yaml"], | ||
container=ilab_con) | ||
self.add_copy_spec( | ||
[f"{cont_local_path}/{data_dir}" | ||
for data_dir in data_dirs], | ||
container=ilab_con) | ||
self.add_cmd_output( | ||
[f"ilab {sub}" for sub in subcmds], | ||
container=ilab_con) | ||
self.add_dir_listing(cont_cache_path, | ||
recursive=True, | ||
container=ilab_con) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other paths, be consistent and use Plugin.path_join()
.
sos-style still needs addressing.
sos/report/plugins/instructlab.py
Outdated
commands = ('ilab',) | ||
|
||
option_list = [ | ||
PluginOpt('ilab_user', default='', val_type=str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not a default user to collect for?
PluginOpt('ilab_user', default='', val_type=str, | ||
desc='user that runs instructlab'), | ||
PluginOpt('ilab_conf_dir', default='', val_type=str, | ||
desc='instructlab data directory'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this option and ilab_user
to ilab-conf-dir
and ilab-user
in the next push
5b94214
to
20dee44
Compare
This change adds a new plugin that captures information from an installation of Instructlab. The capture works in two ways: - It goes through all containers whose names contain Instructlab, and - If specified, it will gather information from a user home directory. In the first case, we gather different outputs from the command 'ilab', as well as directories containing training data, configuration files, chatlogs, taxonomies, and other data. In the second case, we capture only certain directories. Users can also specify to gather .cache directory, where models and OCI directories can be found. This option is disabled by default because, while the information can be very useful, the directories are very big. Related: RH: PLMCORE-10599, RHEL-54137, RHEL-58173 Signed-off-by: Jose Castillo <[email protected]>
20dee44
to
98aff96
Compare
Add a new preset for RHEL AI, that captures the output of Instructlab plugin, as well as nvidia and bootc. Related: RHEL-58169 Depends-on: sosreport#3804 Signed-off-by: Jose Castillo <[email protected]>
Add a new preset for RHEL AI, that captures the output of Instructlab plugin, as well as nvidia and bootc. Related: RHEL-58169 Depends-on: sosreport#3804 Signed-off-by: Jose Castillo <[email protected]>
Add a new preset for RHEL AI, that captures the output of Instructlab plugin, as well as nvidia and bootc. Related: RHEL-58169 Depends-on: sosreport#3804 Signed-off-by: Jose Castillo <[email protected]>
This change adds a new plugin that captures information from an installation of Instructlab. The capture works in two ways:
In the first case, we gather different outputs from the command 'ilab', as well as directories containing training data, configuration files, chatlogs, taxonomies, and other data.
In the second case, we capture only certain directories. Users can also specify to gather .cache directory, where models and OCI directories can be found. This option is disabled by default because, while the information can be very useful, the directories are very big.
Related: RH: PLMCORE-10599, RHEL-54137, RHEL-58173
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines