-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
D3visualizer #920
D3visualizer #920
Changes from 2 commits
755064b
3e50457
3c1c919
69304c7
916c9b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the new syntax instead? On the other hand this is in the server code. Maybe it's good to not intermix with the client logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't understood what you mean about
The server.py was changed so Tornado knows what is the default url to serve index.html or index.d3.html, and this is read from the configuration so there is no client code here I think, actually regarless the configuration of the visualization_graph you can visit in your browser both localhost:8082/index.html or localhost:8082/index.d3.html. I will change the code().visualization_graph as you suggested, dont know what else to do here maybe you can suggest some ideas? Let me know (or post screenshots) of your super mega diagram and let me know if it worked fine :). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, nah. I just meant that Ignore me :) |
||
if visualization_graph == "d3": | ||
self.redirect("/static/visualiser/index.d3.html") | ||
else: | ||
self.redirect("/static/visualiser/index.html") | ||
|
||
|
||
def app(scheduler): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reasons, can you add
task_namespace = 'examples'
toFoo
andBar
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_depth, max_total_nodes, current_nodes are global variables, to store the STATE of the graph that is going to get built. The idea is that you can specify by parameters the size and limits of the foo graph. This means that this variables are needed globally within each luigi's task (requires and run) so the graph generation has a stop condition, while been dynamically generated on each run.