diff --git a/docs/tutorials/pipelines/creating_pipelines.ipynb b/docs/tutorials/pipelines/creating_pipelines.ipynb index a74f447cb..9ab6c250a 100644 --- a/docs/tutorials/pipelines/creating_pipelines.ipynb +++ b/docs/tutorials/pipelines/creating_pipelines.ipynb @@ -2,7 +2,9 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "# Creating Custom Pipelines\n", "\n", @@ -21,7 +23,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "#### Model Components\n", "\n", @@ -105,7 +109,6 @@ "execution_count": 1, "metadata": { "tags": [ - "remove-cell", "hide-input" ] }, @@ -132,7 +135,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "class CustomDataloaderConfig(DataloaderConfig):\n", @@ -240,7 +245,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "dataloader = Dataloader()\n", @@ -250,7 +257,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "# Creating pipelines from a config\n", "\n", @@ -272,7 +281,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pprint\n", @@ -295,13 +306,17 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "pipeline.get_train_loss_dict()" @@ -310,7 +325,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [] } diff --git a/scripts/docs/add_nb_tags.py b/scripts/docs/add_nb_tags.py index c34b673da..309b46d54 100644 --- a/scripts/docs/add_nb_tags.py +++ b/scripts/docs/add_nb_tags.py @@ -35,19 +35,30 @@ def main(check: bool = False): for ipath in notebooks: ntbk = nbf.read(ipath, nbf.NO_CONVERT) - missing_metadata = False + incorrect_metadata = False for cell in ntbk.cells: cell_tags = cell.get("metadata", {}).get("tags", []) + found_keys = [] + found_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 key in cell.source: + found_keys.append(key) + found_tags.append(val) + + if len(found_keys) > 1: + print_yellow(f"Found multiple tags {found_keys} for {ipath}") + 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: - 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 else: print(f"Adding metadata to {ipath}")