Skip to content

Commit

Permalink
Add rerun command snippet in "show error" modal (#3117)
Browse files Browse the repository at this point in the history
* add re-run command snippet to show error modal

To facilitate quick re-run of failed tasks this commit adds a text
snippet to the "Show error" modal in the task visualiser. The scheduler
api call was modified to include the extra information needed to create
call command.

* use JSON.stringify and remove `=` in cmd string

* ensure all underscores are replaced with hyphens
  • Loading branch information
leifdenby committed Nov 7, 2021
1 parent df5afd7 commit 857deff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion luigi/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,9 @@ def re_enable_task(self, task_id):
def fetch_error(self, task_id, **kwargs):
if self._state.has_task(task_id):
task = self._state.get_task(task_id)
return {"taskId": task_id, "error": task.expl, 'displayName': task.pretty_id}
return {"taskId": task_id, "error": task.expl, 'displayName':
task.pretty_id, 'taskParams': task.params, 'taskModule':
task.module, 'taskFamily': task.family}
else:
return {"taskId": task_id, "error": ""}

Expand Down
2 changes: 2 additions & 0 deletions luigi/static/visualiser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ <h4 class="modal-title" id="myModalLabel">Traceback for {{displayName}}</h4>
</div>
<div class="modal-body">
<pre class="pre-scrollable">{{error}}</pre>
Command to re-run:
<pre class="pre-scrollable">luigi --module {{taskModule}} {{taskFamily}} {{taskParams}}</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
Expand Down
3 changes: 3 additions & 0 deletions luigi/static/visualiser/js/visualiserApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ function visualiserApp(luigi) {

function showErrorTrace(data) {
data.error = decodeError(data.error);
if (data.taskParams) {
data.taskParams = Object.entries(data.taskParams).map(([k,v]) => `--${k.replace(/_/g, '-')} ${JSON.stringify(v)}`).join(" ");
}
$("#errorModal").empty().append(renderTemplate("errorTemplate", data));
$("#errorModal").modal({});
}
Expand Down

0 comments on commit 857deff

Please sign in to comment.