Skip to content

Commit 612f57a

Browse files
committed
Refactor HuggingFaceFilesSource to use DEFAULT_SORT_BY constant
1 parent 7956bf0 commit 612f57a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/galaxy/files/sources/huggingface.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
from typing import (
77
Annotated,
8+
Literal,
89
Optional,
910
Union,
1011
)
@@ -38,6 +39,10 @@
3839

3940
log = logging.getLogger(__name__)
4041

42+
SortByOptions = Literal["last_modified", "trending_score", "created_at", "downloads", "likes"]
43+
44+
DEFAULT_SORT_BY: SortByOptions = "downloads"
45+
4146
MAX_REPO_LIMIT = 1000
4247

4348

@@ -137,7 +142,7 @@ def _list_repositories(
137142
endpoint=config.endpoint,
138143
)
139144
try:
140-
repos_iter = api.list_models(search=query, sort="downloads", direction=-1, limit=MAX_REPO_LIMIT)
145+
repos_iter = api.list_models(search=query, sort=DEFAULT_SORT_BY, direction=-1, limit=MAX_REPO_LIMIT)
141146

142147
# Convert repositories to directory entries
143148
entries_list: list[AnyRemoteEntry] = []

0 commit comments

Comments
 (0)