File size: 1,466 Bytes
2ef05ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Publish SecureCodePairs to Hugging Face Hub under ismailtasdelen/SecureCodePairs."""
import os
from huggingface_hub import HfApi
from huggingface_hub.utils import RepositoryNotFoundError

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
REPO_ID = "ismailtasdelen/SecureCodePairs"
TOKEN = os.environ["HF_TOKEN"]

api = HfApi(token=TOKEN)

# Create repo (dataset) if it does not exist
try:
    api.repo_info(repo_id=REPO_ID, repo_type="dataset")
    print(f"Repo {REPO_ID} already exists.")
except RepositoryNotFoundError:
    api.create_repo(repo_id=REPO_ID, repo_type="dataset", private=False, exist_ok=True)
    print(f"Created repo {REPO_ID}.")

# Upload everything under the project root, preserving structure.
api.upload_folder(
    repo_id=REPO_ID,
    repo_type="dataset",
    folder_path=ROOT,
    ignore_patterns=["*.pyc", "__pycache__/*", ".git/*", "scripts/__pycache__/*",
                     "validation/*.json", "statistics/*"],
    commit_message="Release v1.2.0: SecureCodePairs (470 code pairs + 30 LLM security trajectories)",
)
print("Upload complete.")

# Create a git tag on the Hub matching local v1.0.0
try:
    api.create_tag(
        repo_id=REPO_ID,
        repo_type="dataset",
        tag="v1.2.0",
        tag_message="SecureCodePairs v1.2.0",
    )
    print("Hub tag v1.1.0 created.")
except Exception as e:
    print("Tag note:", e)

print("URL: https://huggingface.co/datasets/" + REPO_ID)