Skip to content

Commit

Permalink
fix getting logs when no logs are available
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianMorawiec committed Oct 7, 2024
1 parent c510666 commit a74a89a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,22 @@ def get_workflow_logs(self, wf_run_id: WorkflowRunId) -> WorkflowLogs:
"""
_check_token_validity(self._token)

try:
wf_def = self._client.get_workflow_run(wf_run_id).workflow_def
except (_exceptions.InvalidWorkflowRunID, _exceptions.WorkflowRunNotFound) as e:
raise exceptions.WorkflowRunNotFoundError(
f"Workflow run with id `{wf_run_id}` not found"
) from e
except (_exceptions.InvalidTokenError, _exceptions.ForbiddenError) as e:
raise exceptions.UnauthorizedError(
"Could not get the workflow status for run with id "
f"`{wf_run_id}` "
"- the authorization token was rejected by the remote cluster."
) from e

try:
messages = self._client.get_workflow_run_logs(wf_run_id)
sys_messages = self._client.get_system_logs(wf_run_id)
wf_def = self._client.get_workflow_run(wf_run_id).workflow_def
except (_exceptions.InvalidWorkflowRunID, _exceptions.WorkflowRunNotFound) as e:
raise exceptions.WorkflowRunNotFoundError(
f"Workflow run with id `{wf_run_id}` not found"
Expand All @@ -652,6 +664,9 @@ def get_workflow_logs(self, wf_run_id: WorkflowRunId) -> WorkflowLogs:
f"Failed to decode logs for workflow run with id `{wf_run_id}`. "
"Please report this as a bug."
) from e
except _exceptions.WorkflowRunLogsNotFound:
messages = []
sys_messages = []

task_logs = {}
env_logs = LogAccumulator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def resolve_log_switches(
for log_type in user_switch_values
if log_availibility[log_type] and user_switch_values[log_type] is None
]
if not valid_switches:
warnings.warn("No logs are available for this workflow.")
return ret_switch_values

choice: t.Union[str, WorkflowLogs.WorkflowLogTypeName] = self._prompter.choice(
[(switch.value, switch) for switch in valid_switches],
Expand Down

0 comments on commit a74a89a

Please sign in to comment.