Clone catapult and generate html files during installation. (#956)

* Clone catapult and generate static html during setup.

* Include UI files in installation.

* Fix directory to clone catapult to and fix linting.

* Use absolute path.

* Make sure we find a sufficiently new version of python2 when building wheels.

* Copy the trace_viewer_full.html file to the local directory if it is not present.

* Make sure wheels fail to build if UI is not included.
This commit is contained in:
Robert Nishihara
2017-09-10 13:41:16 -07:00
committed by Philipp Moritz
parent 546ba23ceb
commit f3c1248d98
7 changed files with 67 additions and 65 deletions
+11 -63
View File
@@ -4,7 +4,6 @@ import os
import pprint
import ray
import shutil
import subprocess
import tempfile
import time
@@ -289,65 +288,6 @@ def _get_temp_file_path(**kwargs):
return os.path.relpath(temp_file_path)
# Helper function that ensures that catapult is cloned to the correct location
# and that the HTML files required for task trace embedding are in the same
# directory as the web UI.
def _setup_trace_dependencies():
catapult_home = "/tmp/ray/catapult"
catapult_commit = "33a9271eb3cf5caf925293ec6a4b47c94f1ac968"
try:
# Check if we're inside a git repo
cmd = ["git",
"-C",
catapult_home,
"rev-parse",
"--is-inside-work-tree"]
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Error on non-zero exit code (e.g. - ".git not found")
if not os.path.exists(os.path.join(catapult_home)):
print(
"Cloning catapult to {} (this may take a while...)".format(
catapult_home))
cmd = ["git",
"clone",
"https://github.com/catapult-project/catapult.git",
catapult_home]
subprocess.check_call(cmd)
# Checks out the commit associated with allowing different arrow
# colors. This can and should be removed after catapult's next
# release.
print("Checking out commit {}.".format(catapult_commit))
cmd = ["git", "-C", catapult_home, "checkout", catapult_commit]
subprocess.check_call(cmd)
# Path to the embedded trace viewer HTML file.
embedded_trace_path = os.path.join(catapult_home,
"tracing",
"bin",
"index.html")
# Checks that the trace viewer renderer file exists, generates it if it
# doesn't.
if not os.path.exists("trace_viewer_full.html"):
vulcanize_bin = os.path.join(catapult_home,
"tracing",
"bin",
"vulcanize_trace_viewer")
# TODO(rkn): The vulcanize_trace_viewer script currently requires
# Python 2. Remove this dependency.
cmd = ["python2",
vulcanize_bin,
"--config",
"chrome",
"--output",
"trace_viewer_full.html"]
subprocess.check_call(cmd)
return catapult_home, embedded_trace_path
def task_timeline():
path_input = widgets.Button(description="View task timeline")
@@ -381,6 +321,14 @@ def task_timeline():
display(widgets.HBox([label_options, breakdown_opt]))
display(path_input)
# Check that the trace viewer renderer file is present, and copy it to the
# current working directory if it is not present.
if not os.path.exists("trace_viewer_full.html"):
shutil.copy(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
"../core/src/catapult_files/trace_viewer_full.html"),
"trace_viewer_full.html")
def handle_submit(sender):
json_tmp = tempfile.mktemp() + ".json"
@@ -425,9 +373,9 @@ def task_timeline():
print("Opening html file in browser...")
# Check that the catapult repo is cloned to the correct location
print(_setup_trace_dependencies())
catapult_home, trace_viewer_path = _setup_trace_dependencies()
trace_viewer_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"../core/src/catapult_files/index.html")
html_file_path = _get_temp_file_path(suffix=".html")
json_file_path = _get_temp_file_path(suffix=".json")