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

Integrate Heng's provenance vis to ReproUnzip 🎉 #269

Open
wants to merge 5 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
6 changes: 6 additions & 0 deletions reprounzip-qt/reprounzip_qt/gui/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def __init__(self, package='', **kwargs):

buttons = QtGui.QHBoxLayout()
buttons.addStretch(1)
vis = QtGui.QPushButton("Show provenance")
vis.clicked.connect(self._show_vis)
buttons.addWidget(vis)
self.unpack_widget = QtGui.QPushButton("Unpack experiment",
enabled=False)
self.unpack_widget.clicked.connect(self._unpack)
Expand Down Expand Up @@ -318,3 +321,6 @@ def _unpack(self):
options.get('root'))
else:
error_msg(self, "No unpacker selected", 'warning')

def _show_vis(self):
handle_error(self, reprounzip.show_vis(self.package_widget.text()))
11 changes: 11 additions & 0 deletions reprounzip-qt/reprounzip_qt/reprounzip_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,17 @@ def download(directory, name, path, unpacker=None, root=None):
return code == 0


def show_vis(package):
reprounzip = find_command('reprounzip')
if reprounzip is None:
return ("Couldn't find reprounzip command -- is reprounzip installed?",
'critical')

run_in_builtin_terminal([reprounzip, 'vis', package], {},
text="Running provenance visualization")
return True


def run_in_builtin_terminal_maybe(cmd, root, env={}, **kwargs):
if root is None:
code = run_in_builtin_terminal(cmd, env, **kwargs)
Expand Down
27 changes: 27 additions & 0 deletions reprounzip-vis/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (C) 2014-2017, New York University
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions reprounzip-vis/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.rst
include LICENSE.txt
26 changes: 26 additions & 0 deletions reprounzip-vis/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ReproZip
========

`ReproZip <https://www.reprozip.org/>`__ is a tool aimed at simplifying the process of creating reproducible experiments from command-line executions, a frequently-used common denominator in computational science. It tracks operating system calls and creates a package that contains all the binaries, files and dependencies required to run a given command on the author's computational environment (packing step). A reviewer can then extract the experiment in his environment to reproduce the results (unpacking step).

reprounzip
----------

This is the component responsible for the unpacking step on Linux distributions.

Please refer to `reprozip <https://pypi.python.org/pypi/reprozip>`__, `reprounzip-vagrant <https://pypi.python.org/pypi/reprounzip-vagrant>`_, and `reprounzip-docker <https://pypi.python.org/pypi/reprounzip-docker>`_ for other components and plugins.

A GUI is available at `reprounzip-qt <https://pypi.python.org/pypi/reprounzip-qt>`_.

Additional Information
----------------------

For more detailed information, please refer to our `website <https://www.reprozip.org/>`_, as well as to our `documentation <https://reprozip.readthedocs.io/>`_.

ReproZip is currently being developed at `NYU <http://engineering.nyu.edu/>`_. The team includes:

* `Fernando Chirigati <https://vgc.poly.edu/~fchirigati/>`_
* `Juliana Freire <https://vgc.poly.edu/~juliana/>`_
* `Remi Rampin <https://remirampin.com/>`_
* `Dennis Shasha <http://cs.nyu.edu/shasha/>`_
* `Vicky Steeves <https://vickysteeves.com/>`_
88 changes: 88 additions & 0 deletions reprounzip-vis/reprounzip_vis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import argparse
import BaseHTTPServer
import SocketServer
import mimetypes
import os
import pkg_resources
from rpaths import Path
import shutil
import tempfile
import webbrowser

from reprounzip.common import RPZPack
from reprounzip.unpackers.common import COMPAT_OK
from reprounzip.unpackers.graph import generate

__version__ = '0.1'


class VisHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
server_version = 'ReproUnzip/' + __version__

def do_GET(self):
print("Serving %s" % self.path)
if self.path == '/provenance.json':
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
with open(self.provenance_json, 'rb') as f:
shutil.copyfileobj(f, self.wfile)
else:
try:
f = pkg_resources.resource_stream('reprounzip_vis',
'static/' + self.path)
except IOError:
self.send_response(404)
else:
self.send_response(200)
if self.path == '/':
ctype = 'text/html'
else:
ctype = mimetypes.guess_type(self.path)[0]
self.send_header('Content-Type', ctype)
self.end_headers()
shutil.copyfileobj(f, self.wfile)
f.close()


def show_vis(args):
# Extract JSON from package
fd, json_file = tempfile.mkstemp(prefix='reprounzip_vis_', suffix='.json')
try:
rpz_pack = RPZPack(args.pack)
with rpz_pack.with_config() as config:
with rpz_pack.with_trace() as trace:
generate(Path(json_file), config, trace, graph_format='json')
os.close(fd)

VisHTTPHandler.provenance_json = json_file

# Serve static files and JSON document to browser
port = 8002

httpd = SocketServer.TCPServer(('', port), VisHTTPHandler)
print("serving at port %d" % port)

# Open web browser
webbrowser.open('http://localhost:%d/index.html' % port)

# Serve until killed
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
finally:
httpd.server_close()
finally:
os.remove(json_file)


def setup_vis(parser, **kwargs):
"""Visualizes the provenance of a package as a D3 graph in the browser.
"""
parser.add_argument(
'pack', nargs=argparse.OPTIONAL,
help="Pack to visualize")
parser.set_defaults(func=show_vis)

return {'test_compatibility': COMPAT_OK}
Loading