mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
Correct notebook tag logic (#317)
This commit is contained in:
1 parent
887d2c4bf6
commit
2a94afd9ec
2 files changed
+47
-19
No files matched your search
@@ -2,7 +2,9 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"# Creating Custom Pipelines\n",
|
"# Creating Custom Pipelines\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -21,7 +23,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"#### Model Components\n",
|
"#### Model Components\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -105,7 +109,6 @@
|
|||||||
"execution_count": 1,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"remove-cell",
|
|
||||||
"hide-input"
|
"hide-input"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -132,7 +135,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"class CustomDataloaderConfig(DataloaderConfig):\n",
|
"class CustomDataloaderConfig(DataloaderConfig):\n",
|
||||||
@@ -240,7 +245,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"dataloader = Dataloader()\n",
|
"dataloader = Dataloader()\n",
|
||||||
@@ -250,7 +257,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"# Creating pipelines from a config\n",
|
"# Creating pipelines from a config\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -272,7 +281,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import pprint\n",
|
"import pprint\n",
|
||||||
@@ -295,13 +306,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"source": []
|
"source": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"pipeline.get_train_loss_dict()"
|
"pipeline.get_train_loss_dict()"
|
||||||
@@ -310,7 +325,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,19 +35,30 @@ def main(check: bool = False):
|
|||||||
for ipath in notebooks:
|
for ipath in notebooks:
|
||||||
ntbk = nbf.read(ipath, nbf.NO_CONVERT)
|
ntbk = nbf.read(ipath, nbf.NO_CONVERT)
|
||||||
|
|
||||||
missing_metadata = False
|
incorrect_metadata = False
|
||||||
for cell in ntbk.cells:
|
for cell in ntbk.cells:
|
||||||
cell_tags = cell.get("metadata", {}).get("tags", [])
|
cell_tags = cell.get("metadata", {}).get("tags", [])
|
||||||
|
found_keys = []
|
||||||
|
found_tags = []
|
||||||
for key, val in text_search_dict.items():
|
for key, val in text_search_dict.items():
|
||||||
if key in cell["source"]:
|
if key in cell.source:
|
||||||
if val not in cell_tags:
|
found_keys.append(key)
|
||||||
missing_metadata = True
|
found_tags.append(val)
|
||||||
cell_tags.append(val)
|
|
||||||
if len(cell_tags) > 0:
|
if len(found_keys) > 1:
|
||||||
cell["metadata"]["tags"] = cell_tags
|
print_yellow(f"Found multiple tags {found_keys} for {ipath}")
|
||||||
if missing_metadata:
|
sys.exit(1)
|
||||||
|
|
||||||
|
if len(cell_tags) != len(found_tags):
|
||||||
|
incorrect_metadata = True
|
||||||
|
elif len(cell_tags) == 1 and len(found_keys) == 1:
|
||||||
|
if found_tags[0] != cell_tags[0]:
|
||||||
|
incorrect_metadata = True
|
||||||
|
|
||||||
|
cell["metadata"]["tags"] = found_tags
|
||||||
|
if incorrect_metadata:
|
||||||
if check:
|
if check:
|
||||||
print_yellow(f"{ipath} is missing metadata. Call `python scripts.docs.add_nb_tags.py` to add it.")
|
print_yellow(f"{ipath} has incorrect metadata. Call `python scripts.docs.add_nb_tags.py` to add it.")
|
||||||
any_missing = True
|
any_missing = True
|
||||||
else:
|
else:
|
||||||
print(f"Adding metadata to {ipath}")
|
print(f"Adding metadata to {ipath}")
|
||||||
|
|||||||
Reference in new issue
Block a user