Skip to content
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

feat: model remove cmd #1128

Merged
merged 4 commits into from
Feb 21, 2025
Merged

feat: model remove cmd #1128

merged 4 commits into from
Feb 21, 2025

Conversation

reidliu41
Copy link
Contributor

@reidliu41 reidliu41 commented Feb 16, 2025

What does this PR do?

[Provide a short summary of what this PR does and why. Link to relevant issues if applicable.]

add a subcommand, help to clean the unneeded model:

$ llama model --help
usage: llama model [-h] {download,list,prompt-format,describe,verify-download,remove} ...

Work with llama models

options:
  -h, --help            show this help message and exit

$ llama model remove --help
usage: llama model remove [-h] -m MODEL [-f]

Remove the downloaded llama model

options:
  -h, --help            show this help message and exit
  -m MODEL, --model MODEL
                        Specify the llama downloaded model name
  -f, --force           Used to forcefully remove the llama model from the storage without further confirmation

$ llama model remove -m Llama3.2-1B-Instruct:int4-qlora-eo8
Are you sure you want to remove Llama3.2-1B-Instruct:int4-qlora-eo8? (y/n): n
Removal aborted.

$ llama model remove -mLlama3.2-1B-Instruct:int4-qlora-eo8-f
Llama3.2-1B-Instruct:int4-qlora-eo8 removed.

Test Plan

[Describe the tests you ran to verify your changes with result summaries. Provide clear instructions so the plan can be easily re-executed.]


def _ask_for_confirm(model) -> bool:
input_text = input(f"Are you sure you want to remove {model}? (y/n): ").strip().lower()
if input_text == "y":
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this function at all. you can simply change this to say:

if input("....").lower() == "y":

at the callsite

if args.force:
_remove_model(args.model)
else:
confirm = _ask_for_confirm(args.model)
Copy link
Contributor

Choose a reason for hiding this comment

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

before asking for confirmation or doing anything you should check if the model is legitimate and if the directory even exists or not

reidliu added 4 commits February 21, 2025 16:42
Signed-off-by: reidliu <[email protected]>
Signed-off-by: reidliu <[email protected]>
Signed-off-by: reidliu <[email protected]>
Signed-off-by: reidliu <[email protected]>
@ashwinb ashwinb merged commit c9c4a3c into meta-llama:main Feb 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants