Upload upload_lora_to_hf.py with huggingface_hub
Browse files- upload_lora_to_hf.py +11 -5
upload_lora_to_hf.py
CHANGED
|
@@ -8,8 +8,8 @@ from huggingface_hub import HfApi
|
|
| 8 |
def parse_args():
|
| 9 |
parser = argparse.ArgumentParser(description="Upload a LoRA adapter folder to a Hugging Face model repo")
|
| 10 |
parser.add_argument("--repo-id", default="ASTERIZER/LUNA-100M")
|
| 11 |
-
parser.add_argument("--folder", default="Base/out/sft/rag_mcp_lora
|
| 12 |
-
parser.add_argument("--path-in-repo", default="rag_mcp_lora
|
| 13 |
parser.add_argument("--private", action="store_true")
|
| 14 |
return parser.parse_args()
|
| 15 |
|
|
@@ -26,9 +26,15 @@ def main():
|
|
| 26 |
if not folder.is_dir():
|
| 27 |
raise NotADirectoryError(f"Expected a folder, got: {folder}")
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
raise FileNotFoundError(f"Missing expected adapter files: {', '.join(missing)}")
|
| 33 |
|
| 34 |
api = HfApi(token=token)
|
|
|
|
| 8 |
def parse_args():
|
| 9 |
parser = argparse.ArgumentParser(description="Upload a LoRA adapter folder to a Hugging Face model repo")
|
| 10 |
parser.add_argument("--repo-id", default="ASTERIZER/LUNA-100M")
|
| 11 |
+
parser.add_argument("--folder", default="Base/out/sft/rag_mcp_lora")
|
| 12 |
+
parser.add_argument("--path-in-repo", default="rag_mcp_lora")
|
| 13 |
parser.add_argument("--private", action="store_true")
|
| 14 |
return parser.parse_args()
|
| 15 |
|
|
|
|
| 26 |
if not folder.is_dir():
|
| 27 |
raise NotADirectoryError(f"Expected a folder, got: {folder}")
|
| 28 |
|
| 29 |
+
candidate_files = [
|
| 30 |
+
folder / "adapter_model.pt",
|
| 31 |
+
folder / "adapter_bundle.pt",
|
| 32 |
+
folder / "final" / "adapter_model.pt",
|
| 33 |
+
folder / "final" / "adapter_bundle.pt",
|
| 34 |
+
]
|
| 35 |
+
existing = [path for path in candidate_files if path.exists()]
|
| 36 |
+
missing = [str(path) for path in candidate_files if not path.exists()]
|
| 37 |
+
if not existing:
|
| 38 |
raise FileNotFoundError(f"Missing expected adapter files: {', '.join(missing)}")
|
| 39 |
|
| 40 |
api = HfApi(token=token)
|