|
10 | 10 |
|
11 | 11 | import fiddle as fdl |
12 | 12 | import fiddle._src.experimental.dataclasses as fdl_dc |
13 | | -from torchx.schedulers.api import (AppDryRunInfo, DescribeAppResponse, |
14 | | - ListAppResponse, Scheduler, Stream, |
15 | | - split_lines) |
16 | | -from torchx.specs import (AppDef, AppState, ReplicaStatus, Role, RoleStatus, |
17 | | - runopts) |
| 13 | +from torchx.schedulers.api import ( |
| 14 | + AppDryRunInfo, |
| 15 | + DescribeAppResponse, |
| 16 | + ListAppResponse, |
| 17 | + Scheduler, |
| 18 | + Stream, |
| 19 | + split_lines, |
| 20 | +) |
| 21 | +from torchx.specs import AppDef, AppState, ReplicaStatus, Role, RoleStatus, runopts |
18 | 22 |
|
19 | 23 | from nemo_run.config import get_nemorun_home |
20 | 24 | from nemo_run.core.execution.base import Executor |
@@ -180,22 +184,27 @@ def log_iter( |
180 | 184 | stored_data = _get_job_dirs() |
181 | 185 | job_info = stored_data.get(app_id) |
182 | 186 | _, _, job_id = app_id.split("___") |
183 | | - executor: Optional[DGXCloudExecutor] = job_info.get("executor", None) # type: ignore |
| 187 | + executor: DGXCloudExecutor = job_info.get("executor", None) # type: ignore |
184 | 188 | if not executor: |
185 | | - yield [""] |
| 189 | + return [""] |
186 | 190 |
|
187 | | - for fetched_log in executor.fetch_logs( |
| 191 | + for log in executor.fetch_logs( |
188 | 192 | job_id=job_id, |
189 | 193 | stream=should_tail, |
190 | 194 | ): |
191 | | - if isinstance(fetched_log, str): |
192 | | - if len(fetched_log) == 0: |
193 | | - yield "" |
| 195 | + yield f"{log}\n" |
| 196 | + |
| 197 | + logs = executor.fetch_logs( |
| 198 | + job_id=job_id, |
| 199 | + stream=should_tail, |
| 200 | + ) # type: ignore |
| 201 | + if isinstance(logs, str): |
| 202 | + if len(logs) == 0: |
| 203 | + logs = [] |
194 | 204 | else: |
195 | | - for splitted_line in split_lines(fetched_log): |
196 | | - yield splitted_line |
| 205 | + logs = split_lines(logs) |
197 | 206 |
|
198 | | - yield fetched_log |
| 207 | + return logs |
199 | 208 |
|
200 | 209 | def _cancel_existing(self, app_id: str) -> None: |
201 | 210 | """ |
|
0 commit comments