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

add "report" section to webserver #203

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions sisyphus/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ def update_requirements(self, write_output=True, force=False):
if write_output:
self.write_report()

def format_report(self) -> str:
if self._report_template:
return self._report_template.format(**self._report_values)
elif callable(self._report_values):
return str(self._report_values())
else:
return pprint.pformat(self._report_values, width=140) + "\n"

def write_report(self):
# Allow for anonymous reports
if self._output_path is None:
Expand All @@ -194,12 +202,7 @@ def write_report(self):

# Actually write report
with open(outfile_name, "w") as f:
if self._report_template:
f.write(self._report_template.format(**self._report_values))
elif callable(self._report_values):
f.write(str(self._report_values()))
else:
f.write(pprint.pformat(self._report_values, width=140) + "\n")
f.write(self.format_report())
except IOError as e:
logging.warning("Error while updating %s: %s" % (outfile_name, str(e)))

Expand Down
32 changes: 31 additions & 1 deletion sisyphus/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import threading
import time

from sisyphus.graph import OutputReport, OutputPath
from sisyphus.job import Job
from sisyphus.job_path import AbstractPath
from sisyphus.tools import cache_result
Expand Down Expand Up @@ -94,7 +95,11 @@ def keepalive(sec):
@keepalive(2)
def output_view():
outputs = []
for name, path in g_sis_graph.output.items():
for target in g_sis_graph.targets:
if not isinstance(target, OutputPath):
continue
name = target.name
path = target._sis_path
if path.creator:
job = path.creator
state = job._sis_state(g_sis_engine)
Expand All @@ -110,6 +115,31 @@ def output_view():
return render_template("outputs.html", outputs=outputs)


@app.route("/reports")
@keepalive(2)
def report_view():
reports = []
for target in g_sis_graph.targets:
if not isinstance(target, OutputReport):
continue
reports.append(target.name)

reports.sort()
return render_template("reports.html", reports=reports)


@app.route("/report/<path:output_path>")
@keepalive(2)
def print_report(output_path):
if not output_path:
logging.warning("No output path given: " + str(parameters)) # noqa F821
return "No output path given: " + str(parameters) # noqa F821

output_report = g_sis_graph.targets_dict[output_path]

return render_template("report_details.html", report=output_report.format_report())


@app.route("/all")
@keepalive(2)
def overview():
Expand Down
1 change: 1 addition & 0 deletions sisyphus/templates/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions sisyphus/templates/outputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions sisyphus/templates/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
Expand Down
30 changes: 30 additions & 0 deletions sisyphus/templates/report_details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<style>
table,th,td
{
border:1px solid black;
border-collapse:collapse;
}
th,td
{
padding:5px;
}
</style>
</head>
<body>
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
</thead>
</table>
<xmp>
{{report|safe}}
</xmp>
</body>
</html>
49 changes: 49 additions & 0 deletions sisyphus/templates/reports.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<style>
table,th,td
{
border:1px solid black;
border-collapse:collapse;
}
th,td
{
padding:5px;
}
.boxed {
border: 1px solid green;
white-space: nowrap;
}
div.box {
border: solid 1px black;
padding: 4px;
margin: 2px 2px 2px 2px;
float:left;
}
</style>
</head>
<body>
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
</thead>
</table>

<table><thead>
<tr>
<th align="left"><strong><em>report</em></strong></th>
</tr>
</thead><tbody>
{% for rep in reports %}
<tr id="name_{{ rep }}">
<td align="left"><a href="/report/{{ rep }}">{{ rep }}</a></td>
</tr>
{% endfor %}
</tbody></table>
</body>
</html>
1 change: 1 addition & 0 deletions sisyphus/templates/vis_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<table><thead>
<tr>
<td align="left"><a href="/">List all outputs</a></td>
<td align="left"><a href="/reports">List all reports</a></td>
<td align="left"><a href="/all">List all jobs</a></td>
<td align="left"><a href="/vis">Visualize dependency graph</a></td>
</tr>
Expand Down
Loading