tributario / create_dataset.py
rwayz's picture
Update create_dataset.py
4fc20c6 verified
from datasets import load_dataset
from huggingface_hub import HfApi, HfFolder
import json
import os
# Configurar autenticação no Hugging Face usando o token
HF_TOKEN = os.getenv("HF_API_KEY") # Substitua pelo token gerados
HfFolder.save_token(HF_TOKEN)
# Nome do arquivo JSON de treinamento
dataset_path = "reasoning_table.json" # Verifique se esse é o nome correto do arquivo no Space
# Criar o dataset do Hugging Face a partir do JSON
dataset = load_dataset("json", data_files=dataset_path)
# Criar repositório no Hugging Face Hub (caso ainda não exista)
repo_name = "rwayz/reasoning"
api = HfApi()
try:
api.create_repo(repo_name, token=HF_TOKEN, repo_type="dataset", private=True)
print(f"✅ Repositório {repo_name} criado no Hugging Face!")
except Exception as e:
print(f"⚠️ Repositório já existe ou erro ao criar: {e}")
# Enviar o dataset para o Hugging Face Hub
dataset.push_to_hub(repo_name, token=HF_TOKEN, private=True)
print("✅ Dataset criado e enviado para o Hugging Face Hub!")