Skip to content

Commit

Permalink
more exception tracebacks, when in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Feb 5, 2025
1 parent dc7fd2e commit a1de5fa
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cwltool/command_line_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ def collect_output(
]
)
except OSError as e:
_logger.warning(str(e))
_logger.warning(str(e), exc_info=builder.debug)
except Exception:
_logger.error("Unexpected error from fs_access", exc_info=True)
raise
Expand Down
2 changes: 1 addition & 1 deletion cwltool/cwlprov/provenance_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def declare_artefact(self, value: Any) -> ProvEntity:
# FIXME: list value does not support adding "@id"
return coll
except TypeError:
_logger.warning("Unrecognized type %s of %r", type(value), value)
_logger.warning("Unrecognized type %s of %r", type(value), value, exc_info=True)
# Let's just fall back to Python repr()
entity = self.document.entity(uuid.uuid4().urn, {PROV_LABEL: repr(value)})
self.research_object.add_uri(entity.identifier.uri)
Expand Down
5 changes: 4 additions & 1 deletion cwltool/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ def _runner(
self.exceptions.append(err)
except Exception as err: # pylint: disable=broad-except
_logger.exception(f"Got workflow error: {err}")
self.exceptions.append(WorkflowException(str(err)))
wf_exc = WorkflowException(str(err))
wf_exc.__cause__ = err
wf_exc.__suppress_context__ = True
self.exceptions.append(wf_exc)
finally:
if runtime_context.workflow_eval_lock:
with runtime_context.workflow_eval_lock:
Expand Down
27 changes: 20 additions & 7 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,30 @@ def stderr_stdout_log_path(
except OSError as e:
if e.errno == 2:
if runtime:
_logger.error("'%s' not found: %s", runtime[0], str(e))
_logger.error(
"'%s' not found: %s", runtime[0], str(e), exc_info=runtimeContext.debug
)
else:
_logger.error("'%s' not found: %s", self.command_line[0], str(e))
_logger.error(
"'%s' not found: %s",
self.command_line[0],
str(e),
exc_info=runtimeContext.debug,
)
else:
_logger.exception("Exception while running job")
_logger.exception(
"Exception while running job: %s", str(e), exc_info=runtimeContext.debug
)
processStatus = "permanentFail"
except WorkflowException as err:
_logger.error("[job %s] Job error:\n%s", self.name, str(err))
_logger.error(
"[job %s] Job error:\n%s", self.name, str(err), exc_info=runtimeContext.debug
)
processStatus = "permanentFail"
except Exception:
_logger.exception("Exception while running job")
except Exception as err:
_logger.exception(
"Exception while running job: %s.", str(err), exc_info=runtimeContext.debug
)
processStatus = "permanentFail"
if (
runtimeContext.research_obj is not None
Expand Down Expand Up @@ -795,7 +808,7 @@ def run(
)
except Exception as err:
container = "Singularity" if runtimeContext.singularity else "Docker"
_logger.debug("%s error", container, exc_info=True)
_logger.debug("%s error", container, exc_info=runtimeContext.debug)
if docker_is_req:
raise UnsupportedRequirement(
f"{container} is required to run this tool: {str(err)}"
Expand Down
2 changes: 1 addition & 1 deletion cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ def main(
if isinstance(err.code, int):
return err.code
else:
_logger.debug("Non-integer SystemExit: %s", err.code)
_logger.debug("Non-integer SystemExit: %s", err.code, exc_info=args.debug)
return 1

del args.workflow
Expand Down
6 changes: 3 additions & 3 deletions cwltool/procgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def job(
except WorkflowException:
raise
except Exception as exc:
_logger.exception("Unexpected exception")
_logger.exception("Unexpected exception", exc_info=runtimeContext.debug)
raise WorkflowException(str(exc)) from exc


Expand All @@ -80,7 +80,7 @@ def __init__(
self.embedded_tool = load_tool(toolpath_object["run"], loadingContext)
except ValidationException as vexc:
if loadingContext.debug:
_logger.exception("Validation exception")
_logger.exception("Validation exception", exc_info=loadingContext.debug)
raise WorkflowException(
"Tool definition %s failed validation:\n%s"
% (toolpath_object["run"], indent(str(vexc)))
Expand Down Expand Up @@ -108,7 +108,7 @@ def result(
)
except ValidationException as vexc:
if runtimeContext.debug:
_logger.exception("Validation exception")
_logger.exception("Validation exception", exc_info=runtimeContext.debug)
raise WorkflowException(
"Tool definition %s failed validation:\n%s"
% (jobout["runProcess"], indent(str(vexc)))
Expand Down
4 changes: 2 additions & 2 deletions cwltool/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def resolve_local(document_loader: Optional[Loader], uri: str) -> Optional[str]:

try:
pathobj = Path(pathpart).resolve()
except OSError:
_logger.debug("local resolver could not resolve %s", uri)
except OSError as exc:
_logger.debug("local resolver could not resolve %s due to %s", uri, str(exc))
return None

if pathobj.is_file():
Expand Down
4 changes: 3 additions & 1 deletion cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ def job(
runtimeContext,
)
except WorkflowException:
_logger.error("Exception on step '%s'", runtimeContext.name)
_logger.error(
"Exception on step '%s'", runtimeContext.name, exc_info=runtimeContext.debug
)
raise
except Exception as exc:
_logger.exception("Unexpected exception")
Expand Down

0 comments on commit a1de5fa

Please sign in to comment.