Datasets:
File size: 1,464 Bytes
4164169 4963014 4164169 4963014 4164169 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import os
from pathlib import Path
from huggingface_hub import HfApi, create_repo, update_repo_settings
ROOT = Path("/root/knowledgegrapheval/type_prediction_dataset")
ENV_PATHS = [
Path("/root/knowledgegrapheval/.env"),
Path("/root/knowledge-graph-rag/.env"),
]
REPO_ID = "U4RASD/TypePrediction"
def load_env():
for env_path in ENV_PATHS:
if not env_path.exists():
continue
for line in env_path.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
os.environ.setdefault(key.strip(), value.strip().strip('"').strip("'"))
def main():
load_env()
token = os.environ.get("HF_TOKEN_UNIT") or os.environ.get("HF_TOKEN")
if not token:
raise RuntimeError("Missing HF token.")
create_repo(
repo_id=REPO_ID,
repo_type="dataset",
token=token,
exist_ok=True,
private=False,
)
update_repo_settings(
repo_id=REPO_ID,
repo_type="dataset",
token=token,
private=False,
)
api = HfApi(token=token)
api.upload_folder(
repo_id=REPO_ID,
repo_type="dataset",
folder_path=str(ROOT),
path_in_repo=".",
commit_message="Upload TypePrediction dataset",
)
print(REPO_ID)
if __name__ == "__main__":
main()
|