Data Fetchers¶
tfbpapi.fetchers.HfDataCardFetcher
¶
Handles fetching dataset cards from HuggingFace Hub.
Source code in tfbpapi/fetchers.py
__init__(token=None)
¶
Initialize the fetcher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
HuggingFace token for authentication |
None
|
fetch(repo_id, repo_type='dataset')
¶
Fetch and return dataset card data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Repository identifier (e.g., “user/dataset”) |
required |
repo_type
|
str
|
Type of repository (“dataset”, “model”, “space”) |
'dataset'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dataset card data as dictionary |
Raises:
| Type | Description |
|---|---|
HfDataFetchError
|
If fetching fails |
Source code in tfbpapi/fetchers.py
tfbpapi.fetchers.HfRepoStructureFetcher
¶
Handles fetching repository structure from HuggingFace Hub.
Source code in tfbpapi/fetchers.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
__init__(token=None)
¶
Initialize the fetcher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
HuggingFace token for authentication |
None
|
Source code in tfbpapi/fetchers.py
fetch(repo_id, force_refresh=False)
¶
Fetch repository structure information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Repository identifier (e.g., “user/dataset”) |
required |
force_refresh
|
bool
|
If True, bypass cache and fetch fresh data |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Repository structure information |
Raises:
| Type | Description |
|---|---|
HfDataFetchError
|
If fetching fails |
Source code in tfbpapi/fetchers.py
get_dataset_files(repo_id, path_pattern=None, force_refresh=False)
¶
Get dataset files, optionally filtered by path pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Repository identifier |
required |
path_pattern
|
str | None
|
Optional regex pattern to filter files |
None
|
force_refresh
|
bool
|
If True, bypass cache and fetch fresh data |
False
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of matching files |
Raises:
| Type | Description |
|---|---|
HfDataFetchError
|
If fetching fails |
Source code in tfbpapi/fetchers.py
get_partition_values(repo_id, partition_column, force_refresh=False)
¶
Get all values for a specific partition column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Repository identifier |
required |
partition_column
|
str
|
Name of the partition column |
required |
force_refresh
|
bool
|
If True, bypass cache and fetch fresh data |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of unique partition values |
Raises:
| Type | Description |
|---|---|
HfDataFetchError
|
If fetching fails |
Source code in tfbpapi/fetchers.py
tfbpapi.fetchers.HfSizeInfoFetcher
¶
Handles fetching size information from HuggingFace Dataset Server API.
Source code in tfbpapi/fetchers.py
__init__(token=None)
¶
Initialize the fetcher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
HuggingFace token for authentication |
None
|
Source code in tfbpapi/fetchers.py
fetch(repo_id)
¶
Fetch dataset size information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Repository identifier (e.g., “user/dataset”) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Size information as dictionary |
Raises:
| Type | Description |
|---|---|
HfDataFetchError
|
If fetching fails |