File size: 628 Bytes
d048ec3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from huggingface_hub.errors import RepositoryNotFoundError, RevisionNotFoundError

from src.envs import API, REPO_ID, TOKEN
from huggingface_hub import snapshot_download


def restart_space():
    API.restart_space(repo_id=REPO_ID)


def initialize_file(project_repo, file_path):
    try:
        print(file_path)
        snapshot_download(
            repo_id=project_repo,
            local_dir=file_path,
            repo_type="dataset",
            etag_timeout=30,
            token=TOKEN
        )
    except (RepositoryNotFoundError, RevisionNotFoundError, EnvironmentError, OSError, ValueError):
        restart_space()