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

Jupyter Tutorials #1640

Merged
merged 31 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
046cc64
example jupyter tutorial for point cloud
griegler Mar 17, 2020
652383f
strip notebook output and add option point_show_normal to draw_geomet…
griegler Mar 18, 2020
721d3ae
added nbsphinx to docs; replaced most of Basic tutorials with ipynb
griegler Mar 20, 2020
160d05f
replaced many advanced tutorials with ipynb; added script to stip
griegler Mar 20, 2020
75ad058
merge upstream master
griegler Mar 20, 2020
9222337
added filter for ipynb files
benjaminum Mar 20, 2020
6f8d256
add script for enabling filter
benjaminum Mar 20, 2020
2f00fc0
added note about cleaning ipynb before commit to documentation
benjaminum Mar 21, 2020
28c20a4
nbconvert is required
benjaminum Mar 21, 2020
51b7bed
Merge pull request #1 from benjaminum/pr_ipynb_filter
griegler Mar 22, 2020
338381e
improved open3d logger such that it can redirect output to Python s s…
griegler Mar 23, 2020
094888e
add nbsphinx to travis
griegler Mar 23, 2020
6f43698
fix compilation of log example
griegler Mar 23, 2020
8c41261
draw_geometries in tutorial ipynb with custom views
griegler Mar 23, 2020
2e13069
mesh_show_wireframe and mesh_show_back_face parameters in draw_geomet…
griegler Mar 24, 2020
69179f7
apply-style
griegler Mar 24, 2020
c2fa23c
limit text output in html files generated from notebooks
benjaminum Mar 25, 2020
d0f9ec0
Merge pull request #2 from benjaminum/pr_limit_output_in_html
griegler Mar 25, 2020
2def62f
added more ipynb tutorials
griegler Mar 25, 2020
5d36d1e
addressing reviewing comments
griegler Mar 27, 2020
b0f317f
build juypter docs before running sphinx
yxlao Apr 8, 2020
305bb84
enable xvfb for travis
yxlao Apr 8, 2020
43e6398
Merge pull request #3 from yxlao/jupyter_tutorials_fix
griegler Apr 8, 2020
ea1647d
try xvfb -a
yxlao Apr 8, 2020
a73f4ce
install pandoc in travis
yxlao Apr 8, 2020
f1cd41c
merge master
griegler Apr 15, 2020
6c50651
increase jupyter timeout
griegler Apr 16, 2020
4a693ce
no timeout for notebooks
griegler Apr 17, 2020
a5a4ab9
travis_wait for make_docs.py
griegler Apr 17, 2020
ef635dd
reduce the number of iterations on travis
yxlao Apr 22, 2020
289c62f
travis build docs without openmp
griegler Apr 23, 2020
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ipynb filter=jupyter_clear_output
4 changes: 4 additions & 0 deletions .gitfilters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[filter "jupyter_clear_output"]
clean = "jupyter nbconvert --stdin --stdout --log-level=ERROR --to notebook --ClearOutputPreprocessor.enabled=True"
smudge = cat
required = true
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ compile_commands.json

# Example resources
examples/Python/ReconstructionSystem/dataset/
examples/TestData/fountain_small
examples/TestData/Armadillo.ply
examples/TestData/Bunny.ply
examples/TestData/eagle.ply
Expand All @@ -61,3 +62,12 @@ examples/Python/Basic/copy_of_lena_color.jpg
examples/Python/Basic/copy_of_crate.mtl
examples/Python/Basic/copy_of_crate.png
examples/Python/Basic/copy_of_crate.obj

# doc
docs/TestData
docs/tutorial/**/*.ipynb
docs/tutorial/**/*.py
docs/tutorial/**/*.jpg
docs/tutorial/**/*.ply
docs/tutorial/**/*.pcd
docs/tutorial/**/*.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ matrix:
- cd build
- which python
- python -V
- pip install -U -q sphinx sphinx-rtd-theme
- pip install -U -q sphinx sphinx-rtd-theme nbsphinx
- cmake -DPYTHON_EXECUTABLE=`which python` ..
- make install-pip-package -j$NPROC
- python -c "from open3d import *; import open3d; print(open3d)"
Expand Down
3 changes: 3 additions & 0 deletions docs/builddocs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Clone and build Open3D from source. Visit :ref:`compilation` for details.
conda install sphinx sphinx-autobuild


You further need to install `nbsphinx`. See `here <http://nbsphinx.readthedocs.io>`_ for installation instructions.


3. Install Doxygen
``````````````````

Expand Down
97 changes: 66 additions & 31 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import os
import re
import subprocess
from pathlib import Path
import shutil


def get_git_short_hash():
rc = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
rc = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
rc = rc.decode("utf-8").strip()
return rc

Expand All @@ -39,7 +41,8 @@ def get_git_short_hash():
sys.path.insert(
0,
os.path.join(current_file_dir, "..", "build", "lib", "python_package",
"open3d"))
"open3d"),
)

# -- General configuration ------------------------------------------------

Expand All @@ -51,26 +54,34 @@ def get_git_short_hash():
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.mathjax', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary',
'sphinx.ext.napoleon'
"sphinx.ext.mathjax",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"nbsphinx",
]

# Allow for more time for notebook cell evaluation
nbsphinx_timeout = 6000
# TODO: remove after jupyter fix
nbsphinx_allow_errors = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Open3D'
copyright = u'2018 - 2019, www.open3d.org'
author = u'www.open3d.org'
project = u"Open3D"
copyright = u"2018 - 2020, www.open3d.org"
author = u"www.open3d.org"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -93,10 +104,10 @@ def get_git_short_hash():
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand Down Expand Up @@ -127,13 +138,13 @@ def get_git_short_hash():

# '_static' contains the theme overwrite
static_path = os.path.join(theme_path, "sphinx_rtd_theme", "static")
html_static_path = [static_path, '_static']
html_static_path = [static_path, "_static"]

# Force table wrap: https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html
html_context = {
'css_files': [
'_static/theme_overrides.css', # override wide tables in RTD theme
],
"css_files": [
"_static/theme_overrides.css" # override wide tables in RTD theme
]
}

# added by Jaesik to hide "View page source"
Expand All @@ -142,23 +153,20 @@ def get_git_short_hash():
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Open3Ddoc'
htmlhelp_basename = "Open3Ddoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -167,37 +175,64 @@ def get_git_short_hash():
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Open3D.tex', u'Open3D Documentation', u'Qianyi Zhou',
'manual'),
]
latex_documents = [(
master_doc,
"Open3D.tex",
u"Open3D Documentation",
u"Qianyi Zhou",
"manual",
)]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'open3d', u'Open3D Documentation', [author], 1)]
man_pages = [(master_doc, "open3d", u"Open3D Documentation", [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Open3D', u'Open3D Documentation', author, 'Open3D',
'One line description of project.', 'Miscellaneous'),
]
texinfo_documents = [(
master_doc,
"Open3D",
u"Open3D Documentation",
author,
"Open3D",
"One line description of project.",
"Miscellaneous",
)]

# Version 0: Added by Jaesik to list Python members using the source order
# Version 1: Changed to 'groupwise': __init__ first, then methods, then
# properties. Within each, sorted alphabetically.
autodoc_member_order = 'groupwise'
autodoc_member_order = "groupwise"

# Copy jupyter notebooks and test data to tutorial folder
test_data_in_dir = Path(current_file_dir).parent / "examples" / "TestData"
test_data_out_dir = Path(current_file_dir) / "TestData"
if test_data_out_dir.exists():
shutil.rmtree(test_data_out_dir)
shutil.copytree(test_data_in_dir, test_data_out_dir)
example_dirs = ["Basic", "Advanced"]
for example_dir in example_dirs:
in_dir = Path(current_file_dir).parent / "examples" / "Python" / example_dir
out_dir = Path(current_file_dir) / "tutorial" / example_dir
# remove all existing jupyter notebooks
for nb_out_path in out_dir.glob("*.ipynb"):
nb_out_path.unlink()
shutil.copy(in_dir.parent / "open3d_tutorial.py",
out_dir.parent / "open3d_tutorial.py")
for nb_in_path in in_dir.glob("*.ipynb"):
nb_out_path = out_dir / nb_in_path.name
shutil.copy(nb_in_path, nb_out_path)


def is_enum_class(func, func_name):

def import_from_str(class_name):
components = class_name.split('.')
components = class_name.split(".")
mod = __import__(components[0])
for comp in components[1:]:
mod = getattr(mod, comp)
Expand Down
9 changes: 9 additions & 0 deletions docs/contribute/contribution_recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ Case 4: When adding a Python tutorial

* Update the `index.rst` file to include your new tutorial

.. note::
When you commit a ipynb notebook file make sure to remove the output cells
to keep the commit sizes small.
You can use the script ``examples/Python/jupyter_strip_output.sh`` for
stripping the output cells of all tutorials.
Alternatively, you can enable a pre-commit filter by running the script
``utils/scripts/git_enable_ipynb_filter.sh`` once. In any case you need to
have ``jupyter`` in your ``PATH`` and ``nbconvert`` installed.

Dos
-----------------------

Expand Down
24 changes: 1 addition & 23 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,7 @@ Running Open3D tutorials
========================

A complete set of Python tutorials and testing data will also be copied to
demonstrate the usage of Open3D Python interface.
For example, tutorial ``Basic/rgbd_redwood.py`` can be run with:

.. code-block:: bash

cd lib/Tutorial/Basic
python rgbd_redwood.py

It reads a pair of RGB-D images and visualizes them.

.. image:: _static/Basic/rgbd_images/redwood_rgbd.png
:width: 400px

It then transforms the RGB-D image into a point cloud, then renders the point
cloud using Open3D visualizer.

.. image:: _static/Basic/rgbd_images/redwood_pcd.png
:width: 400px

The Python code is quite straightforward, and the detailed explanation can be
found in :ref:`rgbd_redwood`.
You may further experiment with different tutorials or check out the complete
tutorial list in the :ref:`tutorial_index` page.
demonstrate the usage of Open3D Python interface. See ``examples/Python`` for all Python examples.

.. note:: Open3D's Python tutorial utilizes some external packages: ``numpy``,
``matplotlib``, ``opencv-python``. OpenCV is only used for reconstruction
Expand Down
Loading