feat: add model name prefix to all linked files

Extract model name from repo_id (e.g., 'musicgen-medium' from 'facebook/musicgen-medium')
and prefix all linked files with it for better organization and clarity.

Examples:
- pytorch_model.bin -> musicgen-medium-pytorch_model.bin
- model.safetensors -> musicgen-small-model.safetensors
This commit is contained in:
2025-11-22 17:02:41 +01:00
parent eacd771207
commit 1f94435d36

View File

@@ -429,23 +429,31 @@ link_model() {
return 1
fi
# Extract model name from repo_id for prefixing filenames
# e.g., "facebook/musicgen-medium" -> "musicgen-medium"
local model_name=$(echo "$repo_id" | sed 's/.*\///')
local linked_count=0
while IFS= read -r source_file; do
if [[ -f "$source_file" ]]; then
local filename=$(basename "$source_file")
local link_path="${target_dir}/${filename}"
# Add model name prefix to filename for better organization
# e.g., "pytorch_model.bin" -> "musicgen-medium-pytorch_model.bin"
local prefixed_filename="${model_name}-${filename}"
local link_path="${target_dir}/${prefixed_filename}"
# Remove existing symlink or file if it exists
if [[ -L "$link_path" ]]; then
rm -f "$link_path"
elif [[ -e "$link_path" ]]; then
print_warning "File already exists (not a symlink): ${filename}"
print_warning "File already exists (not a symlink): ${prefixed_filename}"
continue
fi
# Create symlink
ln -s "$source_file" "$link_path"
print_detail "${LINK} Linked: ${DIM}${filename}${RESET}"
print_detail "${LINK} Linked: ${DIM}${prefixed_filename}${RESET}"
linked_count=$((linked_count+1))
fi
done <<< "$model_files"