File size: 990 Bytes
cf91c74
 
 
 
 
 
74e5ab2
cf91c74
 
 
 
 
 
 
 
 
 
15ca86d
cf91c74
74e5ab2
cf91c74
 
 
 
 
 
74e5ab2
cf91c74
 
 
74e5ab2
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
import os
from pathlib import Path
from datetime import timedelta
from google.cloud import storage
from huggingface_hub import hf_hub_download
from google.cloud.storage import transfer_manager

from dotenv import load_dotenv
load_dotenv()

REPO_HUGGING = os.getenv("REPO_HUGGING")
HUB_TOKEN = os.getenv("HUB_TOKEN")

def download_credentials() -> None:
    """
    Downloads the GCP credentials from Hugging Face Hub
    """
    assets_dir = 'assets'
    credentials_file = os.path.join(assets_dir, "credentials.json")
    print(credentials_file)

    # Verificar si la carpeta 'assets' existe y crearla si no
    os.makedirs(assets_dir, exist_ok=True)

    # Verificar si el archivo 'credentials.json' ya existe en la carpeta 'assets'
    if not os.path.isfile(credentials_file):
        print("No habian credenciales")
        hf_hub_download(
            repo_id=REPO_HUGGING, repo_type='dataset', filename="credentials.json",
            token=HUB_TOKEN, local_dir=assets_dir
        )