Skip to content

Commit 237c512

Browse files
committed
Safeguards last_commit access in Huggingface files
It seems the `last_commit` is not always returned by the API when browsing files in the Huggingface repository. This ensures that even if the 'last_commit' is None or absent, the files are correctly listed, although without date or timestamp.
1 parent 0ee5dad commit 237c512

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/galaxy/files/sources/huggingface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _to_filesystem_path(self, path: str) -> str:
104104

105105
def _extract_timestamp(self, info: dict) -> Optional[str]:
106106
"""Extract timestamp from Hugging Face file info to use it in the RemoteFile entry."""
107-
last_commit: dict = info.get("last_commit", {})
107+
last_commit: dict = info.get("last_commit") or {}
108108
return last_commit.get("date")
109109

110110
def _get_file_hashes(self, info: dict) -> Optional[list[RemoteFileHash]]:

0 commit comments

Comments
 (0)