made extension and suggix changes.

This commit is contained in:
ArEnSc committed 2024-02-05 18:51:09 -05:00
1 parent 7450dd1525
commit 5ba8d876f0
5 files changed
+49 -48

No files matched your search

@@ -26,7 +26,7 @@ pub struct FileBucketDirectory {
// gets you cloud bucket path e.g weights/a/b/c/d/clould_path_entropy
let remote_cloud_base_directory = format!("{}/{}{}", file_descriptor.remote_directory_path(), middle, entropy);
// gets you name of the file with suffix and prefix and entropy in the centre
let file_name = format!("{}_{}.{}", bucket_details.get_prefix(), entropy, bucket_details.get_suffix());
let file_name = format!("{}{}{}", bucket_details.get_prefix(), entropy, bucket_details.get_suffix());
// note: no longer optional because it's easy to know what it would be in the db explicit is better than implcit.
// This is the full path you download from
let full_remote_cloud_file_path = format!("{}/{}", remote_cloud_base_directory , file_name);
@@ -46,7 +46,7 @@ pub struct FileBucketDirectory {
// gets you cloud bucket path e.g weights/a/b/c/d/clould_path_entropy
let remote_cloud_base_directory = format!("{}/{}{}", file_descriptor.remote_directory_path(), middle, entropy);
// gets you name of the file with suffix and prefix and entropy in the centre
let file_name = format!("{}_{}.{}", file_descriptor.get_prefix(), entropy, file_descriptor.get_suffix());
let file_name = format!("{}{}{}", file_descriptor.get_prefix(), entropy, file_descriptor.get_suffix());
// note: no longer optional because it's easy to know what it would be in the db explicit is better than implcit.
// This is the full path you upload to.
@@ -10,11 +10,11 @@ impl FileDescriptor for MediaImagePngDescriptor {
MEDIA_FILE_DIRECTORY
}
fn get_suffix(&self)->String {
"png".to_string()
".png".to_string()
}
fn get_prefix(&self)->String {
"image".to_string()
"image_".to_string()
}
fn is_public(&self) -> bool {
@@ -28,11 +28,11 @@ impl FileDescriptor for MediaVideoMp4Descriptor {
MEDIA_FILE_DIRECTORY
}
fn get_suffix(&self)->String {
"mp4".to_string()
".mp4".to_string()
}
fn get_prefix(&self)->String {
"video".to_string()
"video_".to_string()
}
fn is_public(&self) -> bool {
@@ -46,11 +46,11 @@ impl FileDescriptor for UploadVideoMp4Descriptor {
MEDIA_FILE_DIRECTORY
}
fn get_suffix(&self)->String {
"mp4".to_string()
".mp4".to_string()
}
fn get_prefix(&self)->String {
"upload".to_string()
"upload_".to_string()
}
fn is_public(&self) -> bool {
@@ -27,43 +27,44 @@ impl RemoteCloudBucketDetails {
&self.suffix
}
// this is not really useful for downloads remove...
pub fn file_descriptor_from_bucket_details(&self) -> Box<dyn FileDescriptor> {
match self.prefix.as_str() {
// Weights
"loRA" => Box::new(weights_descriptor::WeightsLoRADescriptor {}),
"sd15" =>
"loRA_" => Box::new(weights_descriptor::WeightsLoRADescriptor {}),
"sd15_" =>
match self.suffix.as_str() {
"safetensors" => Box::new(weights_descriptor::WeightsSD15Descriptor {}),
"ckpt" => Box::new(weights_descriptor::WeightsSD15CkptDescriptor {}),
".safetensors" => Box::new(weights_descriptor::WeightsSD15Descriptor {}),
".ckpt" => Box::new(weights_descriptor::WeightsSD15CkptDescriptor {}),
_ => panic!("Unknown suffix: {}",self.suffix)
},
"sdxl" => Box::new(weights_descriptor::WeightsSDXLDescriptor {}),
"valle_prompt" => Box::new(weights_descriptor::WeightsVallePromptDescriptor {}),
"rvc" => {
"sdxl_" => Box::new(weights_descriptor::WeightsSDXLDescriptor {}),
"valle_prompt_" => Box::new(weights_descriptor::WeightsVallePromptDescriptor {}),
"rvc_" => {
match self.suffix.as_str() {
"safetensors" => Box::new(weights_descriptor::WeightsRVCDescriptor {}),
"index" => Box::new(weights_descriptor::WeightsRVCIndexDescriptor {}),
".safetensors" => Box::new(weights_descriptor::WeightsRVCDescriptor {}),
".index" => Box::new(weights_descriptor::WeightsRVCIndexDescriptor {}),
_ => panic!("Unknown suffix: {}",self.suffix)
}
},
"svc" => Box::new(weights_descriptor::WeightsSVCDescriptor {}),
"workflow" => Box::new(weights_descriptor::WeightsWorkflowDescriptor {}),
"svc_" => Box::new(weights_descriptor::WeightsSVCDescriptor {}),
"workflow_" => Box::new(weights_descriptor::WeightsWorkflowDescriptor {}),
// Media
"image" => {
"image_" => {
match self.suffix.as_str() {
"png" => Box::new(media_descriptor::MediaImagePngDescriptor {}),
".png" => Box::new(media_descriptor::MediaImagePngDescriptor {}),
_ => panic!("Unknown suffix: {}",self.suffix)
}
},
"video" => {
"video_" => {
match self.suffix.as_str() {
"mp4" => Box::new(media_descriptor::MediaVideoMp4Descriptor {}),
".mp4" => Box::new(media_descriptor::MediaVideoMp4Descriptor {}),
_ => panic!("Unknown suffix: {}",self.suffix)
}
},
"upload" => {
"upload_" => {
match self.suffix.as_str() {
"mp4" => Box::new(media_descriptor::UploadVideoMp4Descriptor {}),
".mp4" => Box::new(media_descriptor::UploadVideoMp4Descriptor {}),
_ => panic!("Unknown suffix: {}",self.suffix)
}
},
@@ -162,11 +162,11 @@ mod tests {
#[tokio::test]
async fn remote_file_manager_descriptor_test() {
use super::*;
let remote_cloud_bucket_details = RemoteCloudBucketDetails::new("object_hash".to_string(), "loRA".to_string(), "safetensors".to_string());
let remote_cloud_bucket_details = RemoteCloudBucketDetails::new("object_hash".to_string(), "loRA_".to_string(), ".safetensors".to_string());
let file_descriptor = remote_cloud_bucket_details.file_descriptor_from_bucket_details();
assert_eq!(file_descriptor.get_prefix(), "loRA");
assert_eq!(file_descriptor.get_suffix(), "safetensors");
assert_eq!(file_descriptor.get_prefix(), "loRA_");
assert_eq!(file_descriptor.get_suffix(), ".safetensors");
assert_eq!(file_descriptor.is_public(), true);
}
@@ -187,8 +187,8 @@ mod tests {
println!("begin upload from file_path: {:?}", file_path);
let details = RemoteCloudBucketDetails {
object_hash: String::from("123"),
prefix: String::from("loRA"),
suffix: String::from("safetensors")
prefix: String::from("loRA_"),
suffix: String::from(".safetensors")
};
let result = remote_cloud_file_manager.download_file(details,file_path.to_string()).await;
@@ -10,13 +10,13 @@ impl FileDescriptor for WeightsLoRADescriptor {
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"safetensors".to_string()
".safetensors".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, loRA, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"loRA".to_string()
"loRA_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -35,13 +35,13 @@ impl FileDescriptor for WeightsSD15Descriptor {
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"safetensors".to_string()
".safetensors".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"sd15".to_string()
"sd15_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -59,13 +59,13 @@ impl FileDescriptor for WeightsSD15CkptDescriptor {
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"ckpt".to_string()
".ckpt".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"sd15".to_string()
"sd15_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -84,13 +84,13 @@ impl FileDescriptor for WeightsSDXLDescriptor {
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"safetensors".to_string()
".safetensors".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"sdxl".to_string()
"sdxl_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -108,13 +108,13 @@ impl FileDescriptor for crate::remote_file_manager::weights_descriptor::WeightsS
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"safetensors".to_string()
".safetensors".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"svc".to_string()
"svc_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -132,13 +132,13 @@ impl FileDescriptor for crate::remote_file_manager::weights_descriptor::WeightsR
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"pth".to_string()
".pth".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"rvc".to_string()
"rvc_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -156,13 +156,13 @@ impl FileDescriptor for crate::remote_file_manager::weights_descriptor::WeightsR
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"index".to_string()
".index".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"rvc".to_string()
"rvc_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -180,13 +180,13 @@ impl FileDescriptor for crate::remote_file_manager::weights_descriptor::WeightsV
// this will be the type of file peroid is handled by the file formatter
// e.g safetensors bin jpg
fn get_suffix(&self)->String {
"safetensors".to_string()
".safetensors".to_string()
}
// This will be the prefix of the media type or the weights type.
// name of the weights or the name of the media type
// vall-e_prompt, SD15, sd15, sdxl when implmenting add to the end
fn get_prefix(&self)->String {
"valle_prompt".to_string()
"valle_prompt_".to_string()
}
// This will be ensure that the right bucket is picked
@@ -203,11 +203,11 @@ impl FileDescriptor for WeightsWorkflowDescriptor {
}
fn get_suffix(&self) -> String {
"json".to_string()
".json".to_string()
}
fn get_prefix(&self) -> String {
"workflow".to_string()
"workflow_".to_string()
}
fn is_public(&self) -> bool {