Skip to content

Commit

Permalink
Refactor of all code for new d3 visualization, now if you want to ena…
Browse files Browse the repository at this point in the history
…ble d3 graph you need to set in the config visualization_graph in the [core] section either svg (defaults) or d3. This will tell tornado to return as default home either visualization, in any case regarless of this config param value, you can always to either /static/visualiser/index.html or /static/visualiser/index.d3.html in your browser.
  • Loading branch information
hadesbox committed May 11, 2015
1 parent 2687e11 commit 755064b
Show file tree
Hide file tree
Showing 8 changed files with 13,213 additions and 1 deletion.
74 changes: 74 additions & 0 deletions examples/foo.complex.py
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import shutil
import time
import random

import luigi

max_depth = 10
max_total_nodes = 50
current_nodes = 0


class Foo(luigi.Task):

def run(self):
print "Running Foo"

def requires(self):
global current_nodes
for i in xrange(30 / max_depth):
current_nodes += 1
yield Bar(i)


class Bar(luigi.Task):

num = luigi.IntParameter()

def run(self):
time.sleep(1)
self.output().open('w').close()

def requires(self):
global current_nodes

if max_total_nodes > current_nodes:
valor = int(random.uniform(1, 30))
for i in xrange(valor / max_depth):
current_nodes += 1
yield Bar(current_nodes)

def output(self):
"""
Returns the target output for this task.
:return: the target output for this task.
:rtype: object (:py:class:`~luigi.target.Target`)
"""
time.sleep(1)
return luigi.LocalTarget('/tmp/bar/%d' % self.num)


if __name__ == "__main__":
if os.path.exists('/tmp/bar'):
shutil.rmtree('/tmp/bar')

luigi.run(['--task', 'Foo', '--workers', '2'], use_optparse=True)
6 changes: 5 additions & 1 deletion luigi/server.py
Expand Up @@ -214,7 +214,11 @@ def get(self, path):
class RootPathHandler(tornado.web.RequestHandler):

def get(self):
self.redirect("/static/visualiser/index.html")
visualization_graph = configuration.get_config().get('core', 'visualization_graph', '')
if visualization_graph == "d3":
self.redirect("/static/visualiser/index.d3.html")
else:
self.redirect("/static/visualiser/index.html")


def app(scheduler):
Expand Down
25 changes: 25 additions & 0 deletions luigi/static/visualiser/css/tipsy.css
@@ -0,0 +1,25 @@
.tipsy { font-size: 10px; position: absolute; padding: 5px; z-index: 100000; }
.tipsy-inner { background-color: #000; color: #FFF; max-width: 200px; padding: 5px 8px 4px 8px; text-align: center; }

/* Rounded corners */
.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }

/* Uncomment for shadow */
.tipsy-inner { box-shadow: 0 0 5px #000000; -webkit-box-shadow: 0 0 5px #000000; -moz-box-shadow: 0 0 5px #000000; }

.tipsy-arrow { position: absolute; width: 0; height: 0; line-height: 0; border: 5px dashed #000; }

/* Rules to colour arrows */
.tipsy-arrow-n { border-bottom-color: #000; }
.tipsy-arrow-s { border-top-color: #000; }
.tipsy-arrow-e { border-left-color: #000; }
.tipsy-arrow-w { border-right-color: #000; }

.tipsy-n .tipsy-arrow { top: 0px; left: 50%; margin-left: -5px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-nw .tipsy-arrow { top: 0; left: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
.tipsy-ne .tipsy-arrow { top: 0; right: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
.tipsy-s .tipsy-arrow { bottom: 0; left: 50%; margin-left: -5px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-sw .tipsy-arrow { bottom: 0; left: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-se .tipsy-arrow { bottom: 0; right: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-e .tipsy-arrow { right: 0; top: 50%; margin-top: -5px; border-left-style: solid; border-right: none; border-top-color: transparent; border-bottom-color: transparent; }
.tipsy-w .tipsy-arrow { left: 0; top: 50%; margin-top: -5px; border-right-style: solid; border-left: none; border-top-color: transparent; border-bottom-color: transparent; }

0 comments on commit 755064b

Please sign in to comment.