diff --git a/services/ui_backend_service/data/cache/get_log_file_action.py b/services/ui_backend_service/data/cache/get_log_file_action.py index 0fe9daf6..3865a376 100644 --- a/services/ui_backend_service/data/cache/get_log_file_action.py +++ b/services/ui_backend_service/data/cache/get_log_file_action.py @@ -206,7 +206,7 @@ def log_size_exceeded_blurb(task: Task, logtype: str, max_size: int): return blurb -def fetch_logs(task: Task, to_path: str, logtype: str, force_reload: bool = False): +def fetch_logs(task: Task, to_path: str, logtype: str, force_reload: bool = False) -> List[str]: # TODO: This could theoretically be a part of the Metaflow client instead. paths = [] stream = 'stderr' if logtype == STDERR else 'stdout' @@ -243,7 +243,7 @@ def fetch_logs(task: Task, to_path: str, logtype: str, force_reload: bool = Fals ds_type = meta_dict.get("ds-type") ds_root = meta_dict.get("ds-root") if ds_type is None or ds_root is None: - return + return [] attempt = task.current_attempt @@ -305,8 +305,10 @@ def _file_line_iter(path): line_buffer = {path: None for path in paths} def _keysort(item): - # yield the oldest line and only that line. - return item[1] + # Handle None values by providing a fallback (e.g., a large timestamp for None to push it to the end). + if item[1] is None: + return float('inf') + return item[1].utc_tstamp while True: if not iterators: