Skip to content

Commit

Permalink
[bug fix] log-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
valayDave committed Aug 20, 2024
1 parent 159f714 commit 6e29e38
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions services/ui_backend_service/data/cache/get_log_file_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6e29e38

Please sign in to comment.