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:
@@ -429,23 +429,31 @@ link_model() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
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
|
local linked_count=0
|
||||||
while IFS= read -r source_file; do
|
while IFS= read -r source_file; do
|
||||||
if [[ -f "$source_file" ]]; then
|
if [[ -f "$source_file" ]]; then
|
||||||
local filename=$(basename "$source_file")
|
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
|
# Remove existing symlink or file if it exists
|
||||||
if [[ -L "$link_path" ]]; then
|
if [[ -L "$link_path" ]]; then
|
||||||
rm -f "$link_path"
|
rm -f "$link_path"
|
||||||
elif [[ -e "$link_path" ]]; then
|
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
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create symlink
|
# Create symlink
|
||||||
ln -s "$source_file" "$link_path"
|
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))
|
linked_count=$((linked_count+1))
|
||||||
fi
|
fi
|
||||||
done <<< "$model_files"
|
done <<< "$model_files"
|
||||||
|
|||||||
Reference in New Issue
Block a user