diff --git a/sky/jobs/utils.py b/sky/jobs/utils.py index 267c205285b..6cfa886a83e 100644 --- a/sky/jobs/utils.py +++ b/sky/jobs/utils.py @@ -329,7 +329,7 @@ def stream_logs_by_id(job_id: int, follow: bool = True) -> str: f'{managed_job_state.get_failure_reason(job_id)}') log_file = managed_job_state.get_local_log_file(job_id, None) if log_file is not None: - with open(log_file, 'r', encoding='utf-8') as f: + with open(os.path.expanduser(log_file), 'r', encoding='utf-8') as f: # Stream the logs to the console without reading the whole # file into memory. start_streaming = False diff --git a/sky/utils/controller_utils.py b/sky/utils/controller_utils.py index 3f0bd5c5ed7..7ca97e6c935 100644 --- a/sky/utils/controller_utils.py +++ b/sky/utils/controller_utils.py @@ -312,7 +312,7 @@ def download_and_stream_latest_job_log( This function is only used by jobs controller and sky serve controller. """ - os.makedirs(local_dir, exist_ok=True) + os.makedirs(os.path.expanduser(local_dir), exist_ok=True) log_file = None try: log_dirs = backend.sync_down_logs( @@ -338,7 +338,7 @@ def download_and_stream_latest_job_log( # TODO(zhwu): refactor this into log_utils, along with the # refactoring for the log_lib.tail_logs. try: - with open(log_file, 'r', encoding='utf-8') as f: + with open(os.path.expanduser(log_file), 'r', encoding='utf-8') as f: # Stream the logs to the console without reading the whole # file into memory. start_streaming = False