Update to myst_nb (#206)

* Update to myst_nb

* Fix action

* Remove action for now
This commit is contained in:
Matthew Tancik authored and GitHub committed 2022-07-25 19:22:39 -07:00
1 parent 5dd045ccb7
commit 6050dfb6e3
10 files changed
+146167 -146000

No files matched your search

+7 -4
View File
@@ -35,13 +35,11 @@ extensions = [
"sphinx.ext.duration", "sphinx.ext.duration",
"sphinx.ext.doctest", "sphinx.ext.doctest",
"sphinx.ext.autodoc", "sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx", "sphinx.ext.intersphinx",
"sphinxemoji.sphinxemoji", "sphinxemoji.sphinxemoji",
"myst_parser", "myst_nb",
"sphinx.ext.napoleon", "sphinx.ext.napoleon",
"sphinx_copybutton", "sphinx_copybutton",
"nbsphinx",
"sphinx_design", "sphinx_design",
"sphinx.ext.mathjax", "sphinx.ext.mathjax",
] ]
@@ -69,7 +67,7 @@ html_js_files = [
# -- MYST configs ----------------------------------------------------------- # -- MYST configs -----------------------------------------------------------
# To enable admonitions: # To enable admonitions:
myst_enable_extensions = ["colon_fence"] myst_enable_extensions = ["amsmath", "colon_fence", "dollarmath", "html_image"]
# -- Options for HTML output ------------------------------------------------- # -- Options for HTML output -------------------------------------------------
@@ -112,3 +110,8 @@ napoleon_use_rtype = True
napoleon_preprocess_types = False napoleon_preprocess_types = False
napoleon_type_aliases = None napoleon_type_aliases = None
napoleon_attr_annotations = True napoleon_attr_annotations = True
# -- MYSTNB -----------------------------------------------------------------
suppress_warnings = ["mystnb.unknown_mime_type", "myst.header"]
nb_execution_mode = "off"
+49 -32
View File
@@ -10,9 +10,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": {}, "metadata": {
"tags": [
"remove-cell"
]
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# HIDDEN\n",
"import torch\n", "import torch\n",
"from nerfactory.cameras import cameras\n", "from nerfactory.cameras import cameras\n",
"import plotly.graph_objects as go\n", "import plotly.graph_objects as go\n",
@@ -22,9 +27,14 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {
"tags": [
"remove-cell"
]
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# HIDDEN\n",
"def vis_camera_rays(camera):\n", "def vis_camera_rays(camera):\n",
" coords = camera.get_image_coords()\n", " coords = camera.get_image_coords()\n",
" coords[..., 0] /= camera.get_image_height()\n", " coords[..., 0] /= camera.get_image_height()\n",
@@ -77,7 +87,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -13890,6 +13904,9 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"from nerfactory.cameras import cameras\n",
"\n",
"cx = 20\n", "cx = 20\n",
"cy = 10\n", "cy = 10\n",
"fx = 20\n", "fx = 20\n",
@@ -13909,7 +13926,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -16983,7 +17004,7 @@
0, 0,
0.03252455219626427, 0.03252455219626427,
0, 0,
-6.837967969630654e-9, -6.837967969630654e-09,
0, 0,
-0.03252456337213516, -0.03252456337213516,
0, 0,
@@ -17013,7 +17034,7 @@
0, 0,
-0.03252459317445755, -0.03252459317445755,
0, 0,
1.865462451178246e-9, 1.865462451178246e-09,
0, 0,
0.03252459689974785, 0.03252459689974785,
0, 0,
@@ -17043,7 +17064,7 @@
0, 0,
0.09438992291688919, 0.09438992291688919,
0, 0,
-1.9844557996862022e-8, -1.9844557996862022e-08,
0, 0,
-0.09438996762037277, -0.09438996762037277,
0, 0,
@@ -17073,7 +17094,7 @@
0, 0,
-0.09439004957675934, -0.09439004957675934,
0, 0,
5.41378319951491e-9, 5.41378319951491e-09,
0, 0,
0.09439005702733994, 0.09439005702733994,
0, 0,
@@ -17103,7 +17124,7 @@
0, 0,
0.1470157355070114, 0.1470157355070114,
0, 0,
-3.0908619663705394e-8, -3.0908619663705394e-08,
0, 0,
-0.1470157951116562, -0.1470157951116562,
0, 0,
@@ -17133,7 +17154,7 @@
0, 0,
-0.14701592922210693, -0.14701592922210693,
0, 0,
8.432163411953297e-9, 8.432163411953297e-09,
0, 0,
0.14701594412326813, 0.14701594412326813,
0, 0,
@@ -17163,7 +17184,7 @@
0, 0,
0.1852506399154663, 0.1852506399154663,
0, 0,
-3.894713174190656e-8, -3.894713174190656e-08,
0, 0,
-0.18525072932243347, -0.18525072932243347,
0, 0,
@@ -17193,7 +17214,7 @@
0, 0,
-0.1852508783340454, -0.1852508783340454,
0, 0,
1.0625146096288063e-8, 1.0625146096288063e-08,
0, 0,
0.1852508932352066, 0.1852508932352066,
0, 0,
@@ -17223,7 +17244,7 @@
0, 0,
0.20535191893577576, 0.20535191893577576,
0, 0,
-4.3173230324100587e-8, -4.3173230324100587e-08,
0, 0,
-0.20535200834274292, -0.20535200834274292,
0, 0,
@@ -17253,7 +17274,7 @@
0, 0,
-0.20535218715667725, -0.20535218715667725,
0, 0,
1.1778065633905044e-8, 1.1778065633905044e-08,
0, 0,
0.20535220205783844, 0.20535220205783844,
0, 0,
@@ -17283,7 +17304,7 @@
0, 0,
0.20535190403461456, 0.20535190403461456,
0, 0,
-4.317322677138691e-8, -4.317322677138691e-08,
0, 0,
-0.20535199344158173, -0.20535199344158173,
0, 0,
@@ -17313,7 +17334,7 @@
0, 0,
-0.20535217225551605, -0.20535217225551605,
0, 0,
1.1778064745726624e-8, 1.1778064745726624e-08,
0, 0,
0.20535218715667725, 0.20535218715667725,
0, 0,
@@ -17343,7 +17364,7 @@
0, 0,
0.1852506548166275, 0.1852506548166275,
0, 0,
-3.894713529462024e-8, -3.894713529462024e-08,
0, 0,
-0.18525072932243347, -0.18525072932243347,
0, 0,
@@ -17373,7 +17394,7 @@
0, 0,
-0.1852508932352066, -0.1852508932352066,
0, 0,
1.0625146984466483e-8, 1.0625146984466483e-08,
0, 0,
0.1852509081363678, 0.1852509081363678,
0, 0,
@@ -17403,7 +17424,7 @@
0, 0,
0.1470157355070114, 0.1470157355070114,
0, 0,
-3.0908619663705394e-8, -3.0908619663705394e-08,
0, 0,
-0.1470157951116562, -0.1470157951116562,
0, 0,
@@ -17433,7 +17454,7 @@
0, 0,
-0.14701592922210693, -0.14701592922210693,
0, 0,
8.432163411953297e-9, 8.432163411953297e-09,
0, 0,
0.14701594412326813, 0.14701594412326813,
0, 0,
@@ -17463,7 +17484,7 @@
0, 0,
0.0943898856639862, 0.0943898856639862,
0, 0,
-1.9844549115077825e-8, -1.9844549115077825e-08,
0, 0,
-0.09438993036746979, -0.09438993036746979,
0, 0,
@@ -17493,7 +17514,7 @@
0, 0,
-0.09439001232385635, -0.09439001232385635,
0, 0,
5.413780979068861e-9, 5.413780979068861e-09,
0, 0,
0.09439001977443695, 0.09439001977443695,
0, 0,
@@ -17523,7 +17544,7 @@
0, 0,
0.03252454474568367, 0.03252454474568367,
0, 0,
-6.837966637363024e-9, -6.837966637363024e-09,
0, 0,
-0.032524559646844864, -0.032524559646844864,
0, 0,
@@ -17553,7 +17574,7 @@
0, 0,
-0.03252458572387695, -0.03252458572387695,
0, 0,
1.865462007089036e-9, 1.865462007089036e-09,
0, 0,
0.03252458944916725, 0.03252458944916725,
0, 0,
@@ -19636,19 +19657,15 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"from nerfactory.cameras import cameras\n",
"\n",
"height = 10\n", "height = 10\n",
"width = 30\n", "width = 30\n",
"\n", "\n",
"camera = cameras.EquirectangularCamera(height=height, width=width)\n", "camera = cameras.EquirectangularCamera(height=height, width=width)\n",
"vis_camera_rays(camera)" "vis_camera_rays(camera)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
@@ -19670,7 +19687,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.13" "version": "3.8.12"
} }
}, },
"nbformat": 4, "nbformat": 4,
+40 -22
View File
@@ -7,17 +7,6 @@
"# Field Encoders\n" "# Field Encoders\n"
] ]
}, },
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import mediapy as media\n",
"from nerfactory.fields.modules import encoding"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@@ -29,7 +18,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 5,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -129,6 +122,11 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"import mediapy as media\n",
"from nerfactory.fields.modules import encoding\n",
"\n",
"num_frequencies = 4\n", "num_frequencies = 4\n",
"min_freq_exp = 0\n", "min_freq_exp = 0\n",
"max_freq_exp = 6\n", "max_freq_exp = 6\n",
@@ -173,7 +171,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 25,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -273,6 +275,11 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"import mediapy as media\n",
"from nerfactory.fields.modules import encoding\n",
"\n",
"num_frequencies = 8\n", "num_frequencies = 8\n",
"scale = 10\n", "scale = 10\n",
"resolution = 128\n", "resolution = 128\n",
@@ -309,7 +316,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -351,6 +362,11 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"import mediapy as media\n",
"from nerfactory.fields.modules import encoding\n",
"\n",
"num_levels = 8\n", "num_levels = 8\n",
"min_res = 2\n", "min_res = 2\n",
"max_res = 128\n", "max_res = 128\n",
@@ -401,7 +417,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 5,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@@ -481,6 +501,11 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"import mediapy as media\n",
"from nerfactory.fields.modules import encoding\n",
"\n",
"levels = 4\n", "levels = 4\n",
"\n", "\n",
"height = 100\n", "height = 100\n",
@@ -501,13 +526,6 @@
" print(f\"Level: {level+1}\")\n", " print(f\"Level: {level+1}\")\n",
" media.show_images(encoded_values[level**2 : (level + 1) ** 2, ...], cmap=\"plasma\", border=True)" " media.show_images(encoded_values[level**2 : (level + 1) ** 2, ...], cmap=\"plasma\", border=True)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
+11 -14
View File
@@ -7,18 +7,6 @@
"# Ray Samplers" "# Ray Samplers"
] ]
}, },
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"from nerfactory.cameras.rays import RayBundle\n",
"from nerfactory.graphs.modules import ray_sampler\n",
"from matplotlib import pyplot as plt\n"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@@ -31,7 +19,11 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 13,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
@@ -83,6 +75,12 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"from nerfactory.cameras.rays import RayBundle\n",
"from nerfactory.graphs.modules import ray_sampler\n",
"from matplotlib import pyplot as plt\n",
"\n",
"num_samples = 1000\n", "num_samples = 1000\n",
"near = 2\n", "near = 2\n",
"far = 5\n", "far = 5\n",
@@ -135,7 +133,6 @@
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.12" "version": "3.8.12"
}, },
"orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "41f62990c6e03ccb48eec29860b83c64e20fcd45204ae5014afab6809cd6f1f1" "hash": "41f62990c6e03ccb48eec29860b83c64e20fcd45204ae5014afab6809cd6f1f1"
+97 -71
View File
@@ -4,34 +4,40 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Sample Representation" "# Sample Representation\n",
] "\n",
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"from nerfactory.cameras import cameras\n",
"from nerfactory.utils import plotly as vis\n",
"import plotly.graph_objects as go\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A core component of volumetric rendering is computing samples along a ray. The representation of these samples is important. We use conical frustums to represent samples. The conical frustums are defined via the following parameters:\n", "A core component of volumetric rendering is computing samples along a ray. The representation of these samples is important. We use conical frustums to represent samples. The conical frustums are defined via the following parameters:\n",
"\n", "\n",
"<img src=\"imgs/frustums.png\" alt=\"Frustums Diagram\" width=\"600\"/>" "<img src=\"imgs/frustums.png\" alt=\"Frustums Diagram\" width=\"600\"/>\n",
"\n",
"| Parameter | Dimension | Description |\n",
"| ---------- | :-------: | ----------------------------------------------------- |\n",
"| origin | 3 | The _x,y,z_ origin of the ray |\n",
"| direction | 3 | The direction of the ray represented as a unit vector |\n",
"| pixel area | 1 | The pixel's area a distance of 1 from the origin |\n",
"| start | 1 | The distance at which the frustum starts |\n",
"| end | 1 | The distance at which the frustums ends |\n",
"\n",
":::{note}\n",
"Why conical frustums and not pyramidal frustums? Those interested in this question may be interested in [_A Pixel Is Not A Little Square_](http://alvyray.com/Memos/CG/Microsoft/6_pixel.pdf) by Alvy Ray Smith.\n",
":::\n",
"\n",
":::{important}\n",
"This representation is only an approximation.\n",
"Nerfacory calculates $pixel area$ as $dx * dy$ where $dx$ and $dy$ are the distance between points neighboring rays in the $x$ and $y$ direction a distance of 1 from the origin.\n",
":::\n",
"\n",
"## 3D Frustum Visualization\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
@@ -239,7 +245,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#636EFA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -373,7 +379,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#00CC96", "color": "#EF553B",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -507,7 +513,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#00CC96",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -775,7 +781,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#FFA15A",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -909,7 +915,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#19D3F3",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1043,7 +1049,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#00CC96", "color": "#FF6692",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1177,7 +1183,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#636EFA", "color": "#B6E880",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1311,7 +1317,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#FF97FF",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1445,7 +1451,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#FECB52",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1579,7 +1585,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#636EFA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1847,7 +1853,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#00CC96",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -1981,7 +1987,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#19D3F3", "color": "#AB63FA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2115,7 +2121,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#636EFA", "color": "#FFA15A",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2249,7 +2255,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#19D3F3",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2383,7 +2389,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#FF6692",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2517,7 +2523,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FFA15A", "color": "#B6E880",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2651,7 +2657,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FF6692", "color": "#FF97FF",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2785,7 +2791,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#FECB52",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -2919,7 +2925,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#19D3F3", "color": "#636EFA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3053,7 +3059,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#EF553B",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3187,7 +3193,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#00CC96",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3321,7 +3327,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#AB63FA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3455,7 +3461,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#FFA15A",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3589,7 +3595,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#19D3F3",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3723,7 +3729,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#00CC96", "color": "#FF6692",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3857,7 +3863,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#B6E880",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -3991,7 +3997,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#FF97FF",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4125,7 +4131,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#636EFA", "color": "#FECB52",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4259,7 +4265,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FF97FF", "color": "#636EFA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4393,7 +4399,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#EF553B",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4527,7 +4533,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FF6692", "color": "#00CC96",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4795,7 +4801,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#19D3F3", "color": "#FFA15A",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -4929,7 +4935,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FECB52", "color": "#19D3F3",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5063,7 +5069,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#B6E880", "color": "#FF6692",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5331,7 +5337,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#EF553B", "color": "#FF97FF",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5465,7 +5471,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#00CC96", "color": "#FECB52",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5599,7 +5605,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#636EFA",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5733,7 +5739,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FFA15A", "color": "#EF553B",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -5867,7 +5873,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FF97FF", "color": "#00CC96",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -6135,7 +6141,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#AB63FA", "color": "#FFA15A",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -6269,7 +6275,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#00CC96", "color": "#19D3F3",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -6537,7 +6543,7 @@
}, },
{ {
"alphahull": 0, "alphahull": 0,
"color": "#FFA15A", "color": "#B6E880",
"flatshading": true, "flatshading": true,
"name": "Frustums", "name": "Frustums",
"opacity": 1, "opacity": 1,
@@ -7502,9 +7508,9 @@
} }
}, },
"text/html": [ "text/html": [
"<div> <div id=\"dee6c9ee-f715-4308-b84b-560fa13d44b6\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"dee6c9ee-f715-4308-b84b-560fa13d44b6\")) { Plotly.newPlot( \"dee6c9ee-f715-4308-b84b-560fa13d44b6\", [{\"line\":{\"color\":\"teal\",\"width\":1},\"mode\":\"lines\",\"name\":\"Ray Bundle\",\"x\":[0.0,-0.4402044117450714,0.0,-0.1481594443321228,0.0,0.1481594443321228,0.0,0.4402044117450714,0.0,-0.4444783329963684,0.0,-0.14962640404701233,0.0,0.14962640404701233,0.0,0.4444783329963684,0.0,-0.4444783329963684,0.0,-0.14962640404701233,0.0,0.14962640404701233,0.0,0.4444783329963684,0.0,-0.4402044117450714,0.0,-0.1481594443321228,0.0,0.1481594443321228,0.0,0.4402044117450714],\"y\":[0.0,0.4402044117450714,0.0,0.4444783329963684,0.0,0.4444783329963684,0.0,0.4402044117450714,0.0,0.1481594443321228,0.0,0.14962640404701233,0.0,0.14962640404701233,0.0,0.1481594443321228,0.0,-0.1481594443321228,0.0,-0.14962640404701233,0.0,-0.14962640404701233,0.0,-0.1481594443321228,0.0,-0.4402044117450714,0.0,-0.4444783329963684,0.0,-0.4444783329963684,0.0,-0.4402044117450714],\"z\":[0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.992527961730957,0.0,-2.992527961730957,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.992527961730957,0.0,-2.992527961730957,0.0,-2.963188886642456,0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.9346959590911865],\"type\":\"scatter3d\"},{\"alphahull\":0,\"color\":\"#B6E880\",\"flatshading\":true,\"name\":\"Frustums\",\"opacity\":1.0,\"x\":[-0.10901391506195068,-0.09853725135326385,-0.0932835191488266,-0.09382206201553345,-0.10009453445672989,-0.11142121255397797,-0.12657465040683746,-0.14391276240348816,-0.161556676030159,-0.17759442329406738,-0.19028803706169128,-0.19826199114322662,-0.20065218210220337,-0.19719958305358887,-0.18827833235263824,-0.17485521733760834,-0.1583847999572754,-0.14065192639827728,-0.12357820570468903,-0.10901391506195068,-0.18168987333774567,-0.16422875225543976,-0.155472531914711,-0.1563701331615448,-0.16682423651218414,-0.18570201098918915,-0.21095775067806244,-0.2398546040058136,-0.2692611515522003,-0.2959907054901123,-0.31714674830436707,-0.33043667674064636,-0.3344203233718872,-0.32866597175598145,-0.313797265291214,-0.2914254069328308,-0.263974666595459,-0.23441988229751587,-0.20596371591091156,-0.18168985843658447],\"y\":[0.10901391506195068,0.12357823550701141,0.14065192639827728,0.1583847999572754,0.17485521733760834,0.18827833235263824,0.19719958305358887,0.20065218210220337,0.19826199114322662,0.19028803706169128,0.17759442329406738,0.161556676030159,0.14391276240348816,0.12657463550567627,0.11142121255397797,0.10009454935789108,0.09382206201553345,0.0932835191488266,0.09853725135326385,0.10901391506195068,0.18168987333774567,0.20596373081207275,0.23441988229751587,0.263974666595459,0.29142534732818604,0.313797265291214,0.32866597175598145,0.3344203233718872,0.33043667674064636,0.31714674830436707,0.2959907054901123,0.2692611515522003,0.2398546040058136,0.21095773577690125,0.18570201098918915,0.16682425141334534,0.1563701331615448,0.1554725468158722,0.16422876715660095,0.18168988823890686],\"z\":[-0.9895482063293457,-0.988935112953186,-0.9871621131896973,-0.9844213724136353,-0.9810099601745605,-0.9772974848747253,-0.9736862778663635,-0.9705676436424255,-0.9682796001434326,-0.9670700430870056,-0.9670700430870056,-0.9682796001434326,-0.9705676436424255,-0.9736862778663635,-0.9772974848747253,-0.9810099601745605,-0.9844213724136353,-0.9871621131896973,-0.988935112953186,-0.9895482063293457,-1.649247169494629,-1.64822518825531,-1.6452702283859253,-1.6407023668289185,-1.635016679763794,-1.6288292407989502,-1.6228106021881104,-1.6176128387451172,-1.6137994527816772,-1.611783504486084,-1.611783504486084,-1.6137994527816772,-1.6176128387451172,-1.6228106021881104,-1.6288292407989502,-1.635016679763794,-1.6407023668289185,-1.6452702283859253,-1.6482253074645996,-1.649247169494629],\"type\":\"mesh3d\"},{\"alphahull\":0,\"color\":\"#00CC96\",\"flatshading\":true,\"name\":\"Frustums\",\"opacity\":1.0,\"x\":[-0.18168987333774567,-0.16422875225543976,-0.155472531914711,-0.1563701331615448,-0.16682423651218414,-0.18570201098918915,-0.21095775067806244,-0.2398546040058136,-0.2692611515522003,-0.2959907054901123,-0.31714674830436707,-0.33043667674064636,-0.3344203233718872,-0.32866597175598145,-0.313797265291214,-0.2914254069328308,-0.263974666595459,-0.23441988229751587,-0.20596371591091156,-0.18168985843658447,-0.25436580181121826,-0.22992022335529327,-0.2176615595817566,-0.21891814470291138,-0.233553946018219,-0.259982824325Line truncated "<div> <div id=\"36248024-5d87-433c-afb6-2eed8927eb45\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"36248024-5d87-433c-afb6-2eed8927eb45\")) { Plotly.newPlot( \"36248024-5d87-433c-afb6-2eed8927eb45\", [{\"line\":{\"color\":\"teal\",\"width\":1},\"mode\":\"lines\",\"name\":\"Ray Bundle\",\"x\":[0.0,-0.4402044117450714,0.0,-0.1481594443321228,0.0,0.1481594443321228,0.0,0.4402044117450714,0.0,-0.4444783329963684,0.0,-0.14962640404701233,0.0,0.14962640404701233,0.0,0.4444783329963684,0.0,-0.4444783329963684,0.0,-0.14962640404701233,0.0,0.14962640404701233,0.0,0.4444783329963684,0.0,-0.4402044117450714,0.0,-0.1481594443321228,0.0,0.1481594443321228,0.0,0.4402044117450714],\"y\":[0.0,0.4402044117450714,0.0,0.4444783329963684,0.0,0.4444783329963684,0.0,0.4402044117450714,0.0,0.1481594443321228,0.0,0.14962640404701233,0.0,0.14962640404701233,0.0,0.1481594443321228,0.0,-0.1481594443321228,0.0,-0.14962640404701233,0.0,-0.14962640404701233,0.0,-0.1481594443321228,0.0,-0.4402044117450714,0.0,-0.4444783329963684,0.0,-0.4444783329963684,0.0,-0.4402044117450714],\"z\":[0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.992527961730957,0.0,-2.992527961730957,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.992527961730957,0.0,-2.992527961730957,0.0,-2.963188886642456,0.0,-2.9346959590911865,0.0,-2.963188886642456,0.0,-2.963188886642456,0.0,-2.9346959590911865],\"type\":\"scatter3d\"},{\"alphahull\":0,\"color\":\"#636EFA\",\"flatshading\":true,\"name\":\"Frustums\",\"opacity\":1.0,\"x\":[-0.10901391506195068,-0.09853725135326385,-0.0932835191488266,-0.09382206201553345,-0.10009453445672989,-0.11142121255397797,-0.12657465040683746,-0.14391276240348816,-0.161556676030159,-0.17759442329406738,-0.19028803706169128,-0.19826199114322662,-0.20065218210220337,-0.19719958305358887,-0.18827833235263824,-0.17485521733760834,-0.1583847999572754,-0.14065192639827728,-0.12357820570468903,-0.10901391506195068,-0.18168987333774567,-0.16422875225543976,-0.155472531914711,-0.1563701331615448,-0.16682423651218414,-0.18570201098918915,-0.21095775067806244,-0.2398546040058136,-0.2692611515522003,-0.2959907054901123,-0.31714674830436707,-0.33043667674064636,-0.3344203233718872,-0.32866597175598145,-0.313797265291214,-0.2914254069328308,-0.263974666595459,-0.23441988229751587,-0.20596371591091156,-0.18168985843658447],\"y\":[0.10901391506195068,0.12357823550701141,0.14065192639827728,0.1583847999572754,0.17485521733760834,0.18827833235263824,0.19719958305358887,0.20065218210220337,0.19826199114322662,0.19028803706169128,0.17759442329406738,0.161556676030159,0.14391276240348816,0.12657463550567627,0.11142121255397797,0.10009454935789108,0.09382206201553345,0.0932835191488266,0.09853725135326385,0.10901391506195068,0.18168987333774567,0.20596373081207275,0.23441988229751587,0.263974666595459,0.29142534732818604,0.313797265291214,0.32866597175598145,0.3344203233718872,0.33043667674064636,0.31714674830436707,0.2959907054901123,0.2692611515522003,0.2398546040058136,0.21095773577690125,0.18570201098918915,0.16682425141334534,0.1563701331615448,0.1554725468158722,0.16422876715660095,0.18168988823890686],\"z\":[-0.9895482063293457,-0.988935112953186,-0.9871621131896973,-0.9844213724136353,-0.9810099601745605,-0.9772974848747253,-0.9736862778663635,-0.9705676436424255,-0.9682796001434326,-0.9670700430870056,-0.9670700430870056,-0.9682796001434326,-0.9705676436424255,-0.9736862778663635,-0.9772974848747253,-0.9810099601745605,-0.9844213724136353,-0.9871621131896973,-0.988935112953186,-0.9895482063293457,-1.649247169494629,-1.64822518825531,-1.6452702283859253,-1.6407023668289185,-1.635016679763794,-1.6288292407989502,-1.6228106021881104,-1.6176128387451172,-1.6137994527816772,-1.611783504486084,-1.611783504486084,-1.6137994527816772,-1.6176128387451172,-1.6228106021881104,-1.6288292407989502,-1.635016679763794,-1.6407023668289185,-1.6452702283859253,-1.6482253074645996,-1.649247169494629],\"type\":\"mesh3d\"},{\"alphahull\":0,\"color\":\"#EF553B\",\"flatshading\":true,\"name\":\"Frustums\",\"opacity\":1.0,\"x\":[-0.18168987333774567,-0.16422875225543976,-0.155472531914711,-0.1563701331615448,-0.16682423651218414,-0.18570201098918915,-0.21095775067806244,-0.2398546040058136,-0.2692611515522003,-0.2959907054901123,-0.31714674830436707,-0.33043667674064636,-0.3344203233718872,-0.32866597175598145,-0.313797265291214,-0.2914254069328308,-0.263974666595459,-0.23441988229751587,-0.20596371591091156,-0.18168985843658447,-0.25436580181121826,-0.22992022335529327,-0.2176615595817566,-0.21891814470291138,-0.233553946018219,-0.2599828243255615,-0Line truncated
" \n", " \n",
"var gd = document.getElementById('dee6c9ee-f715-4308-b84b-560fa13d44b6');\n", "var gd = document.getElementById('36248024-5d87-433c-afb6-2eed8927eb45');\n",
"var x = new MutationObserver(function (mutations, observer) {{\n", "var x = new MutationObserver(function (mutations, observer) {{\n",
" var display = window.getComputedStyle(gd).display;\n", " var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') {{\n", " if (!display || display === 'none') {{\n",
@@ -7534,6 +7540,12 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"import torch\n",
"from nerfactory.cameras import cameras\n",
"from nerfactory.utils import plotly as vis\n",
"import plotly.graph_objects as go\n",
"\n",
"cx = 2\n", "cx = 2\n",
"cy = 2\n", "cy = 2\n",
"fx = 10\n", "fx = 10\n",
@@ -7555,20 +7567,27 @@
" data=[vis_rays] + vis.get_frustums_mesh_list(ray_samples.frustums),\n", " data=[vis_rays] + vis.get_frustums_mesh_list(ray_samples.frustums),\n",
" layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums\"),\n", " layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums\"),\n",
")\n", ")\n",
"fig.show()\n" "fig.show()\n",
"fig.write_html(\"frustums.html\")\n"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"These frustums can be converted into point samples using `frustum.get_positions()`." "## Representing Frustums as Points\n",
"\n",
"These frustums can be converted into point samples using `frustum.get_positions()`.\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
@@ -8713,6 +8732,7 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"fig = go.Figure(\n", "fig = go.Figure(\n",
" data=[vis_rays, vis.get_frustum_points(ray_samples.frustums)],\n", " data=[vis_rays, vis.get_frustum_points(ray_samples.frustums)],\n",
" layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums as Points\"),\n", " layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums as Points\"),\n",
@@ -8724,13 +8744,19 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"We can also appoximate the frustums using Gaussians with `frustum.get_gaussian_blob()`." "## Representing Frustums as Gaussians\n",
"\n",
"We can also appoximate the frustums using Gaussians with `frustum.get_gaussian_blob()`.\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {
"tags": [
"hide-input"
]
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
@@ -68098,6 +68124,7 @@
} }
], ],
"source": [ "source": [
"# COLLAPSED\n",
"fig = go.Figure(\n", "fig = go.Figure(\n",
" data=[vis_rays] + vis.get_gaussian_ellipsoids_list(ray_samples.frustums.flatten().get_gaussian_blob()),\n", " data=[vis_rays] + vis.get_gaussian_ellipsoids_list(ray_samples.frustums.flatten().get_gaussian_blob()),\n",
" layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums as Gaussians\"),\n", " layout=go.Layout(scene_camera=dict(up=dict(x=0, y=1, z=0)), title=\"Frustums as Gaussians\"),\n",
@@ -68124,7 +68151,6 @@
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.12" "version": "3.8.12"
}, },
"orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "41f62990c6e03ccb48eec29860b83c64e20fcd45204ae5014afab6809cd6f1f1" "hash": "41f62990c6e03ccb48eec29860b83c64e20fcd45204ae5014afab6809cd6f1f1"
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -1,7 +1,7 @@
furo==2022.4.7 furo==2022.4.7
readthedocs-sphinx-search==0.1.2 readthedocs-sphinx-search==0.1.2
myst-parser==0.17.2 myst-nb==0.16.0
nbsphinx==0.8.9 nbformat==5.4.0
sphinx==4.5.0 sphinx==4.5.0
sphinxemoji==0.2.0 sphinxemoji==0.2.0
sphinx-copybutton==0.5.0 sphinx-copybutton==0.5.0
+2
View File
@@ -47,6 +47,8 @@ def main(continue_on_fail: bool = False):
print(f"Skipping {step}") print(f"Skipping {step}")
# Add checks for building documentation # Add checks for building documentation
print_green("Adding notebook documentation metadata")
run_command("python scripts/docs/add_nb_tags.py")
print_green("Building Documentation") print_green("Building Documentation")
run_command("cd docs/; make html SPHINXOPTS='-W;'") run_command("cd docs/; make html SPHINXOPTS='-W;'")
+64
View File
@@ -0,0 +1,64 @@
"""Helper that add tags to notebooks based on cell comments."""
import sys
from glob import glob
import dcargs
import nbformat as nbf
def main(check: bool = False):
"""Add tags to notebooks based on cell comments.
In notebook cells, you can add the folling tags to the notebook by adding a comment:
"# HIDDEN" - This cell will be hidden from the notebook.
"# OUTPUT_ONLY" - This cell will only show the output.
"# COLLAPSED" - Hide the code and include a button to show the code.
Args:
check: check will not modify the notebooks.
"""
# Collect a list of all notebooks in the content folder
notebooks = glob("./docs/**/*.ipynb", recursive=True)
# Text to look for in adding tags
text_search_dict = {
"# HIDDEN": "remove-cell", # Remove the whole cell
"# OUTPUT_ONLY": "remove-input", # Remove only the input
"# COLLAPSED": "hide-input", # Hide the input w/ a button to show
}
print_yellow = lambda x: print(f"\033[33m{x}\033[0m") # print in yellow
# Search through each notebook and look for the text, add a tag if necessary
any_missing = False
for ipath in notebooks:
ntbk = nbf.read(ipath, nbf.NO_CONVERT)
missing_metadata = False
for cell in ntbk.cells:
cell_tags = cell.get("metadata", {}).get("tags", [])
for key, val in text_search_dict.items():
if key in cell["source"]:
if val not in cell_tags:
missing_metadata = True
cell_tags.append(val)
if len(cell_tags) > 0:
cell["metadata"]["tags"] = cell_tags
if missing_metadata:
if check:
print_yellow(f"{ipath} is missing metadata. Call `python scripts.docs.add_nb_tags.py` to add it.")
any_missing = True
else:
print(f"Adding metadata to {ipath}")
nbf.write(ntbk, ipath)
if not any_missing:
print("All notebooks have correct metadata.")
if check and any_missing:
sys.exit(1)
if __name__ == "__main__":
dcargs.cli(main)
+41
View File
@@ -0,0 +1,41 @@
"""Simple yaml debugger"""
import subprocess
import sys
import dcargs
LOCAL_TESTS = ["Run license checks", "Run Black", "Python Pylint", "Test with pytest"]
def run_command(command: str) -> None:
"""Run a command kill actions if it fails
Args:
command: command to run
"""
ret_code = subprocess.call(command, shell=True)
if ret_code != 0:
print(f"\033[31mError: `{command}` failed. Exiting...\033[0m")
sys.exit(1)
def main():
"""Run the github actions locally."""
print_green = lambda x: print(f"\033[32m{x}\033[0m")
print_green("Adding notebook documentation metadata")
run_command("python scripts/docs/add_nb_tags.py")
# Add checks for building documentation
print_green("Building Documentation")
run_command("cd docs/; make html SPHINXOPTS='-W;'")
print("\n")
print_green("=" * 100)
print_green("Done")
print_green("=" * 100)
if __name__ == "__main__":
dcargs.cli(main)