Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show task history link in visualizer when recording. #2759

Merged
merged 2 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions luigi/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,10 @@ def get_scheduler_message_response(self, task_id, message_id):
response = task.scheduler_message_responses.pop(message_id, None)
return {"response": response}

@rpc_method()
def has_task_history(self):
return self._config.record_task_history

@rpc_method()
def is_pause_enabled(self):
return {'enabled': self._config.pause_enabled}
Expand Down
10 changes: 9 additions & 1 deletion luigi/static/visualiser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ <h3 class="box-title">{{name}}</h3>
</div>
</script>

<script type="text/template" name="topNavbarItem">
<li>
<a class="js-nav-link" href="{{href}}" {{#dataTab}}data-tab="{{dataTab}}"{{/dataTab}}>
{{label}}
</a>
</li>
</script>

</head>
<body class="skin-green-light fixed">
<div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Expand All @@ -387,7 +395,7 @@ <h3 class="box-title">{{name}}</h3>
</button>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<ul class="nav navbar-nav" id="topNavbar">
<li><a class="js-nav-link" href="#tab=tasks" data-tab="taskList">Task List</a></li>
<li><a class="js-nav-link" href="#tab=graph" data-tab="dependencyGraph">Dependency Graph</a></li>
<li><a class="js-nav-link" href="#tab=workers" data-tab="workerList">Workers</a></li>
Expand Down
6 changes: 6 additions & 0 deletions luigi/static/visualiser/js/luigi.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ var LuigiAPI = (function() {
});
};

LuigiAPI.prototype.hasTaskHistory = function(callback) {
jsonRPC(this.urlRoot + '/has_task_history', {}, function(response) {
callback(response.response);
});
};

LuigiAPI.prototype.pause = function() {
jsonRPC(this.urlRoot + '/pause');
};
Expand Down
9 changes: 9 additions & 0 deletions luigi/static/visualiser/js/visualiserApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,15 @@ function visualiserApp(luigi) {
$(document).ready(function() {
loadTemplates();

luigi.hasTaskHistory(function(hasTaskHistory) {
if (hasTaskHistory) {
$('#topNavbar').append(renderTemplate('topNavbarItem', {
label: "History",
href: "../../history",
}).children()[0]);
}
});

luigi.isPauseEnabled(function(enabled) {
if (enabled) {
luigi.isPaused(createPauseToggle);
Expand Down
14 changes: 14 additions & 0 deletions test/scheduler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from helpers import unittest

import luigi.scheduler
import luigi.configuration
from helpers import with_config


Expand Down Expand Up @@ -229,6 +230,19 @@ def test_per_task_retry_policy(self):
task_9.add_failure()
self.assertTrue(task_9.has_excessive_failures())

@with_config({'scheduler': {'record_task_history': 'true'}})
def test_has_task_history(self):
cfg = luigi.configuration.get_config()
with tempfile.NamedTemporaryFile(suffix='.db', delete=True) as fn:
cfg.set('task_history', 'db_connection', 'sqlite:///' + fn.name)
s = luigi.scheduler.Scheduler()
self.assertTrue(s.has_task_history())

@with_config({'scheduler': {'record_task_history': 'false'}})
def test_has_no_task_history(self):
s = luigi.scheduler.Scheduler()
self.assertFalse(s.has_task_history())

@with_config({'scheduler': {'pause_enabled': 'false'}})
def test_pause_disabled(self):
s = luigi.scheduler.Scheduler()
Expand Down