Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

ilab command redesign - #990

Merged
mergify[bot] merged 9 commits into
instructlab:mainfrom
cdoern:engine
Jun 11, 2024
Merged

ilab command redesign#990
mergify[bot] merged 9 commits into
instructlab:mainfrom
cdoern:engine

Conversation

@cdoern

@cdoern cdoern commented Apr 24, 2024

Copy link
Copy Markdown
Contributor

add the following groups to ilab:

model
config
data
taxonomy

inside of these commands, there are groups commands that relate to the sub-command. For example ilab model list lists all models known to the system.

a full list of the commands in this PR is:

model

  • convert
  • download
  • train
  • chat
  • serve
  • evaluate

data

  • generate

config

  • init

taxonomy

  • diff

the goal of this is to make ilab commands more logical. ilab generate for example is vague. also, adding structure allows for natural expansion of the project and makes the repo more digestible to new contributors.

Grouping ilab commands under common resources which the cli deals with makes sense as the role of instructlab grows. This is the first step in making ilab a model engine in which the cli will be a tool for full blown LLM management and deployment

@cdoern cdoern added this to the Release - 5/30 milestone Apr 25, 2024
@mergify mergify Bot added the needs-rebase This Pull Request needs to be rebased label Apr 29, 2024
@mergify

mergify Bot commented Apr 29, 2024

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. @cdoern please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added container Affects containization aspects testing Relates to testing labels May 16, 2024

@hickeyma hickeyma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should be driven by design doc and not be merged until the design merges first.

@cdoern
cdoern force-pushed the engine branch 2 times, most recently from 790b995 to 6c052ec Compare May 17, 2024 13:42
@cdoern
cdoern force-pushed the engine branch 2 times, most recently from 883eea0 to b96d96a Compare May 23, 2024 19:21
@mergify mergify Bot added ci-failure PR has at least one CI failure and removed needs-rebase This Pull Request needs to be rebased labels May 23, 2024
@cdoern
cdoern marked this pull request as ready for review May 23, 2024 19:23
@hickeyma hickeyma added hold In-progress PR. Tag should be removed before merge. enhancement New feature or request UX Affects the User Experience labels May 24, 2024
@hickeyma

Copy link
Copy Markdown
Contributor

Add hold waiting on design doc

@hickeyma hickeyma removed the hold In-progress PR. Tag should be removed before merge. label May 24, 2024
@hickeyma

Copy link
Copy Markdown
Contributor

Removed hold as design doc was merged.

@hickeyma

Copy link
Copy Markdown
Contributor

https://github.com/Mergifyio rebase

@mergify

mergify Bot commented May 24, 2024

Copy link
Copy Markdown
Contributor

rebase

☑️ Nothing to do

Details
  • any of:
    • #commits-behind>0 [📌 rebase requirement]
    • #commits>1 [📌 rebase requirement]
    • -linear-history [📌 rebase requirement]
  • -closed [📌 rebase requirement]
  • -conflict [📌 rebase requirement]
  • queue-position=-1 [📌 rebase requirement]

@hickeyma hickeyma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdoern are you good to return to this now that the design doc is merged?

@nathan-weinberg
nathan-weinberg self-requested a review May 28, 2024 16:45
@russellb
russellb self-requested a review May 29, 2024 11:22
@mergify

mergify Bot commented May 29, 2024

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. @cdoern please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase This Pull Request needs to be rebased label May 29, 2024
cdoern added 2 commits June 11, 2024 09:58
Signed-off-by: Charlie Doern <cdoern@redhat.com>
Previously, the config reading process and creation of the lab class could occur in lab.py. However, due to context passing norms in click, if we create the Lab object and
read the ocnfig into the context when creating the lab group, we lose the context after passing it down one level of command.
This means, we need to init our class object and context when at the sub-group level.

In this commit I moved this functionality and the Lab class into config.py so that we do not need to duplicate code in each submodule

Signed-off-by: Charlie Doern <cdoern@redhat.com>

@russellb russellb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are now a bunch of follow-up issues open.

The ONLY thing I'd like to request changed at this point before merging is dropping the new prettytable dependency since it is no longer used.

Comment thread src/instructlab/lab.py Outdated
return
click.echo(
"Welcome to InstructLab CLI. This guide will help you to setup your environment."
"Welcome to InstructLab ilab. This guide will help you to setup your environment."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets changed back in a later commit, so I think it's OK ... bcf3c1d

Ideally the change would be brought back here, but it's not worth blocking on

Comment thread src/instructlab/config.py



def init_config(ctx, config_file):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/instructlab/config.py
elif not os.path.isfile(config_file):
config_obj = None
ctx.fail(
f"`{config_file}` does not exists, please run `ilab init` "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and should say "does not exist" instead of "exists"

but I don't think we need to block on this. It's pre-existing code and ilab init still works

Comment thread requirements.txt Outdated
# the below library should NOT be imported into any python files
# it is for CLI usage ONLY
yamllint>=1.35.1,<1.36.0
prettytable==3.10.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is worth making before merging

def model(ctx, config_file):
"""Command Group for Interacting with the Models in InstructLab.

If this is your first time running ilab, it's best to start with `ilab init` to create the environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/instructlab/lab.py
import typing

# Third Party
from click_didyoumean import DYMGroup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def taxonomy(ctx):
"""Command Group for Interacting with the Taxonomy of InstructLab.

If this is your first time running ilab, it's best to start with `ilab init` to create the environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/instructlab/lab.py
Returns a torch.device object:
- type is one of 'cpu', 'cuda', 'hpu'
- index is None or device index (e.g. 0 for first GPU)
If this is your first time running ilab, it's best to start with `ilab init` to create the environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/instructlab/lab.py
Comment on lines +59 to +109
ilab.add_command(model_group.model)
ilab.add_command(taxonomy_group.taxonomy)
ilab.add_command(data_group.data)
ilab.add_command(config_group.config)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're merging a bunch of commits that we know are in a broken state prior to this one. That's really not ideal, but I'm OK not blocking on it this time.

Comment thread src/instructlab/lab.py
if self.aliases:
formatter.write_paragraph()
formatter.write_text("Aliases:")
with formatter.indentation():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdoern added 7 commits June 11, 2024 17:45
ilab now has a model command which has the following subcommands:

ilab model chat
ilab model convert
ilab model serve
ilab model test
ilab model train
ilab model download

ilab model list is new, but simple and I think we should add it in with this redesign to let users get used to the idea of managing their models.

Each child group needs to init their own Lab class due to context issues in click
Signed-off-by: Charlie Doern <cdoern@redhat.com>
the data group only has one subcommand:
ilab data generate

Moved the file structure of generation so it makes more sense and lives within the data group.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
Add the config group and its one subcommand:

ilab config init

Removed the old init code. This code is still in the works as I am unsure of how to recitfy  when/how to call the init_config comman from the config group

Signed-off-by: Charlie Doern <cdoern@redhat.com>
the Taxonomy group has one command for now:
ilab taxonomy diff

ilab taxonomy download will be a future command

create this command, the parent group, and remove the command in lab.py

Signed-off-by: Charlie Doern <cdoern@redhat.com>
this commit brings all of the new commands back into lab.py, adds them to the ilab group, and cleans up the code by running the linting command.

Now that the commands are added, all tests should still pass. I had to make a few adaptations to the unit tests specifically because most tests require --config=DEFAULT

Signed-off-by: Charlie Doern <cdoern@redhat.com>
In order to alias properly, click requires a custom class that invokes a `get_command` function each time you call a click cmd. In my custom class, this function grabs a dictionary mapping cmd names to actual functions. These functions are then set to the actual cmd to be executed and returned. I also need to init the config here since
we technically skip over the "sub-parent" in this scenario. For example, in `ilab model list` the `model` part is where the config is checked into the context. We skip over that here, so it needs to happen in this get_command func.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
Signed-off-by: Charlie Doern <cdoern@redhat.com>
@cdoern

cdoern commented Jun 11, 2024

Copy link
Copy Markdown
Contributor Author

thanks for catching the prettytable dependency @russellb , this should be all set now

@russellb russellb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have shown an impressive level of diligence as you worked through feedback. Thank you for sticking through this and pushing so hard to the end. Very nice work!

I'm good with merging this now!

@alimaredia

Copy link
Copy Markdown
Contributor

@leseb @markstur If your changes requested are still relevant can you point them out or if not remove the changes requested. It's the only thing standing in the way of merging the PR.

@russellb

Copy link
Copy Markdown
Contributor

I tried to apply hold to catch the merge before it went in but just missed it.

I talked with @cdoern about the merge process and how we have Mergify configured to explicitly NOT merge when someone has previously requested changes and not come back and explicitly ACKed that they have been resolved. My preference would have been to ping both @markstur and @leseb to give them a chance to give that ACK. Only if they didn't respond would I consider dismissing the review.

I know @cdoern had all the best of intentions here and genuinely felt that it was acceptable to dismiss the reviews if the feedback was addressed. In his defense, this is not documented anywhere! As I think about it, that's probably fine when the feedback in the review was simple enough. @leseb at least was doing more in depth review and has been very responsive on this.

@cdoern has offered to revert the PR to give a chance for the final review responses. I told him I did not feel it was worth the churn in this case.

@markstur @leseb would you both be OK taking another look at this PR (post-merge) to see if there was anything else you'd like to see addressed? If it's something not captured in a follow-up issue, please raise it. If you have any more significant concerns, we can consider reverting whatever portion is affected, but I'd rather hold off on that churn unless it's justified.

Hopefully that makes sense to everyone! Let me know if I can help discuss anything further.

@markstur

Copy link
Copy Markdown
Contributor

I tried to apply hold to catch the merge before it went in but just missed it.

I talked with @cdoern about the merge process and how we have Mergify configured to explicitly NOT merge when someone has previously requested changes and not come back and explicitly ACKed that they have been resolved. My preference would have been to ping both @markstur and @leseb to give them a chance to give that ACK. Only if they didn't respond would I consider dismissing the review.

I know @cdoern had all the best of intentions here and genuinely felt that it was acceptable to dismiss the reviews if the feedback was addressed. In his defense, this is not documented anywhere! As I think about it, that's probably fine when the feedback in the review was simple enough. @leseb at least was doing more in depth review and has been very responsive on this.

@cdoern has offered to revert the PR to give a chance for the final review responses. I told him I did not feel it was worth the churn in this case.

@markstur @leseb would you both be OK taking another look at this PR (post-merge) to see if there was anything else you'd like to see addressed? If it's something not captured in a follow-up issue, please raise it. If you have any more significant concerns, we can consider reverting whatever portion is affected, but I'd rather hold off on that churn unless it's justified.

Hopefully that makes sense to everyone! Let me know if I can help discuss anything further.

yeah I was trying to ACK those when it merged. Now I'm looking at main. So far the concerns seem to be fixed or no longer relevant in what was merged

@cdoern

cdoern commented Jun 11, 2024

Copy link
Copy Markdown
Contributor Author

@markstur @leseb I am really sorry for not letting you guys ACK the PR before merging it, it was an honest mistake as I genuinely thought stale reviews which I had either made follow up issues for or addressed in the PR, could be dismissed. I did not realize this was not a normal practice and will be careful doing it in the future. Please feel free to be honest with me and let me know if you'd like this reverted, I really apologize.

@markstur

Copy link
Copy Markdown
Contributor

@markstur @leseb I am really sorry for not letting you guys ACK the PR before merging it, it was an honest mistake as I genuinely thought stale reviews which I had either made follow up issues for or addressed in the PR, could be dismissed. I did not realize this was not a normal practice and will be careful doing it in the future. Please feel free to be honest with me and let me know if you'd like this reverted, I really apologize.

@cdoern No worries. No revert needed for any of mine. Just double-checking to make sure they are resolved or no longer relevant in main. So far, so good.

@leseb

leseb commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

@markstur @leseb I am really sorry for not letting you guys ACK the PR before merging it, it was an honest mistake as I genuinely thought stale reviews which I had either made follow up issues for or addressed in the PR, could be dismissed. I did not realize this was not a normal practice and will be careful doing it in the future. Please feel free to be honest with me and let me know if you'd like this reverted, I really apologize.

@cdoern No worries, I'm not offended by how things have unfolded. There's no need to revert; we have follow-ups in place, and any missed items will be addressed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

container Affects containization aspects enhancement New feature or request testing Relates to testing UX Affects the User Experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ilab more of a model engine

8 participants