OSainz commited on
Commit
dee592a
β€’
1 Parent(s): ab79de8

Use HF api to check repo existance

Browse files
Files changed (1) hide show
  1. utils.py +6 -2
utils.py CHANGED
@@ -7,6 +7,10 @@ from urllib.parse import urljoin, urlparse
7
  import requests
8
  from bs4 import BeautifulSoup
9
 
 
 
 
 
10
 
11
  def get_base_url(url: str) -> str:
12
  """
@@ -129,7 +133,7 @@ def build_dataset_url(dataset_name: str):
129
  """
130
  url = f"https://huggingface.co/datasets/{dataset_name}"
131
  # Test if the url exists
132
- if url_exists(url):
133
  return url
134
  else:
135
  return None
@@ -141,7 +145,7 @@ def build_model_url(model_name: str):
141
  """
142
  url = f"https://huggingface.co/{model_name}"
143
  # Test if the url exists
144
- if url_exists(url):
145
  return url
146
  else:
147
  return None
 
7
  import requests
8
  from bs4 import BeautifulSoup
9
 
10
+ from huggingface_hub import HfApi
11
+
12
+ HF_API = HfApi()
13
+
14
 
15
  def get_base_url(url: str) -> str:
16
  """
 
133
  """
134
  url = f"https://huggingface.co/datasets/{dataset_name}"
135
  # Test if the url exists
136
+ if url_exists(url) and HF_API.repo_exists(dataset_name, repo_type="dataset"):
137
  return url
138
  else:
139
  return None
 
145
  """
146
  url = f"https://huggingface.co/{model_name}"
147
  # Test if the url exists
148
+ if url_exists(url) and HF_API.repo_exists(model_name, repo_type="model"):
149
  return url
150
  else:
151
  return None