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
+1 -1
View File
@@ -58,7 +58,7 @@ for ((i=0; i<${#PY_VERSIONS[@]}; ++i)); do
$PIP_CMD install wheel
# Add the correct Python to the path and build the wheel. This is only
# needed so that the installation finds the cython executable.
PATH=$MACPYTHON_PY_PREFIX/$PY_MM/bin:$PATH $PYTHON_EXE setup.py bdist_wheel
INCLUDE_UI=1 PATH=$MACPYTHON_PY_PREFIX/$PY_MM/bin:$PATH $PYTHON_EXE setup.py bdist_wheel
mv dist/*.whl ../.whl/
popd
done
+7 -1
View File
@@ -6,6 +6,12 @@ echo 10
EOF
chmod +x /usr/bin/nproc
# Remove this old Python 2.4.3 executable, and make the "python2" command find
# a newer version of Python. We need this for autogenerating some files for the
# UI.
rm -f /usr/bin/python2
ln -s /opt/python/cp27-cp27m/bin/python2 /usr/bin/python2
mkdir .whl
for PYTHON in cp27-cp27mu cp33-cp33m cp34-cp34m cp35-cp35m cp36-cp36m; do
# The -f flag is passed twice to also run git clean in the arrow subdirectory.
@@ -16,7 +22,7 @@ for PYTHON in cp27-cp27mu cp33-cp33m cp34-cp34m cp35-cp35m cp36-cp36m; do
# Fix the numpy version because this will be the oldest numpy version we can
# support.
/opt/python/${PYTHON}/bin/pip install numpy==1.10.4 cython
PATH=/opt/python/${PYTHON}/bin:$PATH /opt/python/${PYTHON}/bin/python setup.py bdist_wheel
INCLUDE_UI=1 PATH=/opt/python/${PYTHON}/bin:$PATH /opt/python/${PYTHON}/bin/python setup.py bdist_wheel
# In the future, run auditwheel here.
mv dist/*.whl ../.whl/
popd
+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")
+2
View File
@@ -23,6 +23,8 @@ ray_files = [
"ray/core/src/local_scheduler/local_scheduler",
"ray/core/src/local_scheduler/liblocal_scheduler_library.so",
"ray/core/src/global_scheduler/global_scheduler",
"ray/core/src/catapult_files/index.html",
"ray/core/src/catapult_files/trace_viewer_full.html",
"ray/WebUI.ipynb"
]