mirror of
https://github.com/thinking-machines-lab/tinker.git
synced 2026-04-23 16:54:58 +00:00
move auth check before downloading and fetching archive
This commit is contained in:
parent
b142dff173
commit
ac8f2b5e70
1 changed files with 7 additions and 2 deletions
|
|
@ -358,6 +358,12 @@ def _export_checkpoint_to_hub(
|
||||||
# Validate tinker path
|
# Validate tinker path
|
||||||
parsed_tinker_path = ParsedCheckpointTinkerPath.from_tinker_path(tinker_path)
|
parsed_tinker_path = ParsedCheckpointTinkerPath.from_tinker_path(tinker_path)
|
||||||
|
|
||||||
|
api = HfApi()
|
||||||
|
try:
|
||||||
|
api.whoami()
|
||||||
|
except Exception as exc:
|
||||||
|
raise TinkerCliError("Not logged in", "Run: hf auth login") from exc
|
||||||
|
|
||||||
def _sanitize_repo_name(value: str) -> str:
|
def _sanitize_repo_name(value: str) -> str:
|
||||||
safe_chars = []
|
safe_chars = []
|
||||||
for ch in value:
|
for ch in value:
|
||||||
|
|
@ -436,7 +442,7 @@ def _export_checkpoint_to_hub(
|
||||||
|
|
||||||
readme_path = extract_dir / "README.md"
|
readme_path = extract_dir / "README.md"
|
||||||
if add_model_card and not readme_path.exists():
|
if add_model_card and not readme_path.exists():
|
||||||
tags: list[str] = ["tinker", "peft", "lora"]
|
tags: List[str] = ["tinker", "peft", "lora"]
|
||||||
if base_model != "unknown":
|
if base_model != "unknown":
|
||||||
tags.append(f"base_model:adapter:{base_model}")
|
tags.append(f"base_model:adapter:{base_model}")
|
||||||
model_card = [
|
model_card = [
|
||||||
|
|
@ -487,7 +493,6 @@ def _export_checkpoint_to_hub(
|
||||||
model_card.append("")
|
model_card.append("")
|
||||||
readme_path.write_text("\n".join(model_card), encoding="utf-8")
|
readme_path.write_text("\n".join(model_card), encoding="utf-8")
|
||||||
|
|
||||||
api = HfApi()
|
|
||||||
api.create_repo(repo_id=repo_id, private=private, exist_ok=exist_ok)
|
api.create_repo(repo_id=repo_id, private=private, exist_ok=exist_ok)
|
||||||
|
|
||||||
def _readme_tinker_path() -> str | None:
|
def _readme_tinker_path() -> str | None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue