diff --git a/Report_API_Quickstart.ipynb b/Report_API_Quickstart.ipynb deleted file mode 100644 index 7a2c63ab..00000000 --- a/Report_API_Quickstart.ipynb +++ /dev/null @@ -1,1006 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "cPVgUCLA7NDN" - }, - "source": [ - "\"Weights\n", - "" - ] - }, - { - "cell_type": "markdown", - "source": [ - "## 📝 W&B Report API\n", - "Programmatically create, manage, and customize Reports by defining configurations, panel layouts, and runsets with the wandb-workspaces W&B library. Load and modify Reports with URLs, filter and group runs using expressions, and customize run appearances using Report templates.\n", - "\n", - "[wandb-workspaces](https://github.com/wandb/wandb-workspaces) is a Python library for programmatically creating and customizing W&B Workspaces and Reports.\n", - "\n", - "In this tutorial you will see how to use wandb-workspaces to create and customize W&B Reports." - ], - "metadata": { - "id": "notdNrjvIn2O" - } - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "S1e3tnre7NDO" - }, - "outputs": [], - "source": [ - "#install dependencies\n", - "!pip install wandb wandb-workspaces -qqq" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "9UGFOwXG7NDO" - }, - "outputs": [], - "source": [ - "#@title ## Log Runs { run: \"auto\", display-mode: \"form\" }\n", - "#@markdown If this is your first time here, consider running the setup code for a better docs experience!\n", - "#@markdown If you have run the setup code before, you can uncheck the box below to avoid unnecessary logging.\n", - "\n", - "LOG_DUMMY_RUNS = True #@param {type: \"boolean\"}\n", - "\n", - "\n", - "import requests\n", - "from PIL import Image\n", - "from io import BytesIO\n", - "import wandb\n", - "import pandas as pd\n", - "from itertools import product\n", - "import random\n", - "import math\n", - "\n", - "import wandb\n", - "import random\n", - "import string\n", - "\n", - "ENTITY = wandb.apis.PublicApi().default_entity\n", - "PROJECT = \"report-api-quickstart\" #@param {type: \"string\"}\n", - "LINEAGE_PROJECT = \"lineage-example\" #@param {type: \"string\"}\n", - "\n", - "\n", - "def get_image(url):\n", - " r = requests.get(url)\n", - " return Image.open(BytesIO(r.content))\n", - "\n", - "\n", - "def log_dummy_data():\n", - " run_names = [\n", - " \"adventurous-aardvark-1\",\n", - " \"bountiful-badger-2\",\n", - " \"clairvoyant-chipmunk-3\",\n", - " \"dastardly-duck-4\",\n", - " \"eloquent-elephant-5\",\n", - " \"flippant-flamingo-6\",\n", - " \"giddy-giraffe-7\",\n", - " \"haughty-hippo-8\",\n", - " \"ignorant-iguana-9\",\n", - " \"jolly-jackal-10\",\n", - " \"kind-koala-11\",\n", - " \"laughing-lemur-12\",\n", - " \"manic-mandrill-13\",\n", - " \"neighbourly-narwhal-14\",\n", - " \"oblivious-octopus-15\",\n", - " \"philistine-platypus-16\",\n", - " \"quant-quail-17\",\n", - " \"rowdy-rhino-18\",\n", - " \"solid-snake-19\",\n", - " \"timid-tarantula-20\",\n", - " \"understanding-unicorn-21\",\n", - " \"voracious-vulture-22\",\n", - " \"wu-tang-23\",\n", - " \"xenic-xerneas-24\",\n", - " \"yielding-yveltal-25\",\n", - " \"zooming-zygarde-26\",\n", - " ]\n", - "\n", - " opts = [\"adam\", \"sgd\"]\n", - " encoders = [\"resnet18\", \"resnet50\"]\n", - " learning_rates = [0.01]\n", - " for (i, run_name), (opt, encoder, lr) in zip(\n", - " enumerate(run_names), product(opts, encoders, learning_rates)\n", - " ):\n", - " config = {\n", - " \"optimizer\": opt,\n", - " \"encoder\": encoder,\n", - " \"learning_rate\": lr,\n", - " \"momentum\": 0.1 * random.random(),\n", - " }\n", - " displacement1 = random.random() * 2\n", - " displacement2 = random.random() * 4\n", - " with wandb.init(\n", - " entity=ENTITY, project=PROJECT, config=config, name=run_name\n", - " ) as run:\n", - " for step in range(1000):\n", - " wandb.log(\n", - " {\n", - " \"acc\": 0.1\n", - " + 0.4\n", - " * (\n", - " math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " + random.random()\n", - " + displacement1\n", - " + random.random() * run.config.momentum\n", - " ),\n", - " \"val_acc\": 0.1\n", - " + 0.4\n", - " * (\n", - " math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " - random.random()\n", - " + displacement1\n", - " ),\n", - " \"loss\": 0.1\n", - " + 0.08\n", - " * (\n", - " 3.5\n", - " - math.log(1 + step + random.random())\n", - " + random.random() * run.config.momentum\n", - " + random.random()\n", - " + displacement2\n", - " ),\n", - " \"val_loss\": 0.1\n", - " + 0.04\n", - " * (\n", - " 4.5\n", - " - math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " - random.random()\n", - " + displacement2\n", - " ),\n", - " }\n", - " )\n", - "\n", - " with wandb.init(\n", - " entity=ENTITY, project=PROJECT, config=config, name=run_names[i + 1]\n", - " ) as run:\n", - " img = get_image(\n", - " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", - " )\n", - " image = wandb.Image(img)\n", - " df = pd.DataFrame(\n", - " {\n", - " \"int\": [1, 2, 3, 4],\n", - " \"float\": [1.2, 2.3, 3.4, 4.5],\n", - " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", - " \"img\": [image] * 4,\n", - " }\n", - " )\n", - " run.log({\"img\": image, \"my-table\": df})\n", - "\n", - "\n", - "class Step:\n", - " def __init__(self, j, r, u, o, at=None):\n", - " self.job_type = j\n", - " self.runs = r\n", - " self.uses_per_run = u\n", - " self.outputs_per_run = o\n", - " self.artifact_type = at if at is not None else \"model\"\n", - " self.artifacts = []\n", - "\n", - "\n", - "def create_artifact(name: str, type: str, content: str):\n", - " art = wandb.Artifact(name, type)\n", - " with open(\"boom.txt\", \"w\") as f:\n", - " f.write(content)\n", - " art.add_file(\"boom.txt\", \"test-name\")\n", - "\n", - " img = get_image(\n", - " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", - " )\n", - " image = wandb.Image(img)\n", - " df = pd.DataFrame(\n", - " {\n", - " \"int\": [1, 2, 3, 4],\n", - " \"float\": [1.2, 2.3, 3.4, 4.5],\n", - " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", - " \"img\": [image] * 4,\n", - " }\n", - " )\n", - " art.add(wandb.Table(dataframe=df), \"dataframe\")\n", - " return art\n", - "\n", - "\n", - "def log_dummy_lineage():\n", - " pipeline = [\n", - " Step(\"dataset-generator\", 1, 0, 3, \"dataset\"),\n", - " Step(\"trainer\", 4, (1, 2), 3),\n", - " Step(\"evaluator\", 2, 1, 3),\n", - " Step(\"ensemble\", 1, 1, 1),\n", - " ]\n", - " for (i, step) in enumerate(pipeline):\n", - " for _ in range(step.runs):\n", - " with wandb.init(project=LINEAGE_PROJECT, job_type=step.job_type) as run:\n", - " # use\n", - " uses = step.uses_per_run\n", - " if type(uses) == tuple:\n", - " uses = random.choice(list(uses))\n", - "\n", - " if i > 0:\n", - " prev_step = pipeline[i - 1]\n", - " input_artifacts = random.sample(prev_step.artifacts, uses)\n", - " for a in input_artifacts:\n", - " run.use_artifact(a)\n", - " # log output artifacts\n", - " for j in range(step.outputs_per_run):\n", - " # name = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))\n", - " name = f\"{step.artifact_type}-{j}\"\n", - " content = \"\".join(\n", - " random.choices(string.ascii_lowercase + string.digits, k=12)\n", - " )\n", - " art = create_artifact(name, step.artifact_type, content)\n", - " run.log_artifact(art)\n", - " art.wait()\n", - "\n", - " # save in pipeline\n", - " step.artifacts.append(art)\n", - "\n", - "if LOG_DUMMY_RUNS:\n", - " log_dummy_data()\n", - " log_dummy_lineage()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "4tqli7A_7NDP" - }, - "source": [ - "\n", - "# 🚀 Quickstart! " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "EmDzg3wS7NDP" - }, - "outputs": [], - "source": [ - "import wandb_workspaces.reports.v2 as wr" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "eheAid__7NDP" - }, - "source": [ - "## Create, save, and load reports\n", - "- NOTE: Reports are not saved automatically to reduce clutter. Explicitly save the report by calling `report.save()`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "RVlOoOaK7NDP" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " project=PROJECT,\n", - " title='Quickstart Report',\n", - " description=\"That was easy!\"\n", - ") # Create\n", - "report.save() # Save\n", - "wr.Report.from_url(report.url) # Load" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "d3M7hocj7NDP" - }, - "source": [ - "## Add content via blocks\n", - "- Use blocks to add content like text, images, code, and more\n", - "- See `wr.blocks` for all available blocks" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "ZaSE1j897NDP" - }, - "outputs": [], - "source": [ - "report.blocks = [\n", - " wr.TableOfContents(),\n", - " wr.H1(\"Text and images example\"),\n", - " wr.P(\"Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.\"),\n", - " wr.Image('https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'),\n", - " wr.P(\"Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?\"),\n", - "]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "bMNTXROu7NDQ" - }, - "source": [ - "## Add charts and more via Panel Grid\n", - "- `PanelGrid` is a special type of block that holds `runsets` and `panels`\n", - " - `runsets` organize data logged to W&B\n", - " - `panels` visualize runset data. For a full set of panels, see `wr.panels`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "2lpA3H4R7NDQ" - }, - "outputs": [], - "source": [ - "pg = wr.PanelGrid(\n", - " runsets=[\n", - " wr.Runset(ENTITY, PROJECT, \"First Run Set\"),\n", - " wr.Runset(ENTITY, PROJECT, \"Elephants Only!\", query=\"elephant\"),\n", - " ],\n", - " panels=[\n", - " wr.LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8),\n", - " wr.BarPlot(metrics=['acc']),\n", - " wr.MediaBrowser(media_keys=['img'], num_columns=1),\n", - " wr.RunComparer(diff_only='split', layout={'w': 24, 'h': 9}),\n", - " ]\n", - ")\n", - "\n", - "report.blocks = report.blocks[:1] + [wr.H1(\"Panel Grid Example\"), pg] + report.blocks[1:]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "fbtBNA5k7NDQ" - }, - "source": [ - "## Add data lineage with Artifact blocks\n", - "- There are equivalent weave panels as well" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "rI-kgZpU7NDQ" - }, - "outputs": [], - "source": [ - "artifact_lineage = wr.WeaveBlockArtifact(entity=ENTITY, project=LINEAGE_PROJECT, artifact='model-1', tab='lineage')\n", - "\n", - "report.blocks = report.blocks[:1] + [wr.H1(\"Artifact lineage example\"), artifact_lineage] + report.blocks[1:]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "b2mMLGUK7NDQ" - }, - "source": [ - "## Customize run colors\n", - "- Pass in a `dict[run_name, color]`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "kE72SArq7NDQ" - }, - "outputs": [], - "source": [ - "pg.custom_run_colors = {\n", - " 'adventurous-aardvark-1': '#e84118',\n", - " 'bountiful-badger-2': '#fbc531',\n", - " 'clairvoyant-chipmunk-3': '#4cd137',\n", - " 'dastardly-duck-4': '#00a8ff',\n", - " 'eloquent-elephant-5': '#9c88ff',\n", - "}\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "pqu2LPgz7NDQ" - }, - "source": [ - "# ❓ FAQ " - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "c--gAdKg7NDQ" - }, - "source": [ - "## My report is too wide/narrow\n", - "- Change the report's width to the right size for you." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "RQrUg8E17NDQ" - }, - "outputs": [], - "source": [ - "report2 = report.save(clone=True)\n", - "report2.width = 'fluid'\n", - "report2.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZBRQ0-Np7NDQ" - }, - "source": [ - "## How do I resize panels?\n", - "- Pass a `dict[dim, int]` to `panel.layout`\n", - "- `dim` is a dimension, which can be `x`, `y` (the coordiantes of the top left corner) `w`, `h` (the size of the panel)\n", - "- You can pass any or all dimensions at once\n", - "- The space between two dots in a panel grid is 2." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "83rhYSSD7NDQ" - }, - "outputs": [], - "source": [ - "import wandb_workspaces.reports.v2 as wr\n", - "\n", - "\n", - "report = wr.Report(\n", - " project=PROJECT,\n", - " title=\"Resizing panels\",\n", - " description=\"Look at this wide parallel coordinates plot!\",\n", - " blocks=[\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"Step\"),\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"c::model\"),\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"c::optimizer\"),\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"Step\"),\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"val_acc\"),\n", - " wr.ParallelCoordinatesPlotColumn(metric=\"val_loss\"),\n", - " ],\n", - " layout=wr.Layout(w=24, h=9) # Adjusting the layout for the plot size\n", - " ),\n", - " ]\n", - " )\n", - " ]\n", - ")\n", - "\n", - "\n", - "report.save()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "qQTtzZ9r7NDQ" - }, - "source": [ - "## What blocks are available?\n", - "- See `wr.blocks` for a list of blocks.\n", - "- In an IDE or notebook, you can also do `wr.blocks.` to get autocomplete." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "valQfFTQ7NDQ" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " project=PROJECT,\n", - " title='W&B Block Gallery',\n", - " description=\"Check out all of the blocks available in W&B\",\n", - " blocks=[\n", - " wr.H1(text=\"Heading 1\"),\n", - " wr.P(text=\"Normal paragraph\"),\n", - " wr.H2(text=\"Heading 2\"),\n", - " wr.P(\n", - " text=[\n", - " \"here is some text, followed by\",\n", - " wr.InlineCode(text=\"select * from code in line\"),\n", - " \"and then latex\",\n", - " wr.InlineLatex(text=\"e=mc^2\"),\n", - " ]\n", - " ),\n", - " wr.H3(text=\"Heading 3\"),\n", - " wr.CodeBlock(\n", - " code=\"this:\\n- is\\n- a\\ncool:\\n- yaml\\n- file\",\n", - " language=\"yaml\",\n", - " ),\n", - " wr.WeaveBlockSummaryTable(\n", - " entity=ENTITY,\n", - " project=PROJECT,\n", - " table_name='my-table'\n", - " ),\n", - " wr.WeaveBlockArtifact(\n", - " entity=ENTITY,\n", - " project=LINEAGE_PROJECT,\n", - " artifact='model-1',\n", - " tab='lineage'\n", - " ),\n", - " wr.WeaveBlockArtifactVersionedFile(\n", - " entity=ENTITY,\n", - " project=LINEAGE_PROJECT,\n", - " artifact='model-1',\n", - " version='v0',\n", - " file=\"dataframe.table.json\"\n", - " ),\n", - " wr.MarkdownBlock(text=\"Markdown cell with *italics* and **bold** and $e=mc^2$\"),\n", - " wr.LatexBlock(text=\"\\\\gamma^2+\\\\theta^2=\\\\omega^2\\n\\\\\\\\ a^2 + b^2 = c^2\"),\n", - " wr.Image(url=\"https://api.wandb.ai/files/megatruong/images/projects/918598/350382db.gif\", caption=\"It's a me, Pikachu\"),\n", - " wr.UnorderedList(items=[\"Bullet 1\", \"Bullet 2\"]),\n", - " wr.OrderedList(items=[\"Ordered 1\", \"Ordered 2\"]),\n", - " wr.CheckedList(items=[\n", - " wr.CheckedListItem(text=\"Unchecked\", checked=False),\n", - " wr.CheckedListItem(text=\"Checked\", checked=True)\n", - " ]),\n", - " wr.BlockQuote(text=\"Block Quote 1\\nBlock Quote 2\\nBlock Quote 3\"),\n", - " wr.CalloutBlock(text=\"Callout 1\\nCallout 2\\nCallout 3\"),\n", - " wr.HorizontalRule(),\n", - " wr.Video(url=\"https://www.youtube.com/embed/6riDJMI-Y8U\"),\n", - " ]\n", - ")\n", - "\n", - "report.save()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "-koIg4Dp7NDQ" - }, - "source": [ - "## What panels are available?\n", - "- See `wr.panels` for a list of panels\n", - "- In an IDE or notebook, you can also do `wr.panels.` to get autocomplete.\n", - "- Panels have a lot of settings. Inspect the panel to see what you can do!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "E95cCJQK7NDQ" - }, - "outputs": [], - "source": [ - "import wandb_workspaces.reports.v2 as wr\n", - "\n", - "report = wr.Report(\n", - " project=PROJECT,\n", - " title='W&B Panel Gallery',\n", - " description=\"Check out all of the panels available in W&B\",\n", - " width='fluid',\n", - " blocks=[\n", - " wr.PanelGrid(\n", - " runsets=[\n", - " wr.Runset(project=LINEAGE_PROJECT),\n", - " wr.Runset(),\n", - " ],\n", - " panels=[\n", - " wr.MediaBrowser(media_keys=[\"img\"]),\n", - " wr.MarkdownPanel(markdown=\"Hello *italic* **bold** $e=mc^2$ `something`\"),\n", - "\n", - " # LinePlot with various settings enabled\n", - " wr.LinePlot(\n", - " title=\"Validation Accuracy over Time\",\n", - " x=\"Step\",\n", - " y=[\"val_acc\"],\n", - " range_x=(0, 1000),\n", - " range_y=(1, 4),\n", - " log_x=True,\n", - " log_y=False,\n", - " title_x=\"Training steps\",\n", - " title_y=\"Validation Accuracy\",\n", - " ignore_outliers=True,\n", - " groupby='encoder',\n", - " groupby_aggfunc=\"mean\",\n", - " groupby_rangefunc=\"minmax\",\n", - " smoothing_factor=0.5,\n", - " smoothing_type=\"gaussian\",\n", - " smoothing_show_original=True,\n", - " max_runs_to_show=10,\n", - " font_size=\"large\",\n", - " legend_position=\"west\",\n", - " ),\n", - " wr.ScatterPlot(\n", - " title=\"Validation Accuracy vs. Validation Loss\",\n", - " x=\"val_acc\",\n", - " y=\"val_loss\",\n", - " log_x=False,\n", - " log_y=False,\n", - " running_ymin=True,\n", - " running_ymean=True,\n", - " running_ymax=True,\n", - " font_size=\"small\",\n", - " regression=True,\n", - " ),\n", - " wr.BarPlot(\n", - " title=\"Validation Loss by Encoder\",\n", - " metrics=[\"val_loss\"],\n", - " orientation='h',\n", - " range_x=(0, 0.11),\n", - " title_x=\"Validation Loss\",\n", - " groupby='encoder',\n", - " groupby_aggfunc=\"median\",\n", - " groupby_rangefunc=\"stddev\",\n", - " max_runs_to_show=20,\n", - " max_bars_to_show=3,\n", - " font_size=\"auto\",\n", - " ),\n", - " wr.ScalarChart(\n", - " title=\"Maximum Number of Steps\",\n", - " metric=\"Step\",\n", - " groupby_aggfunc=\"max\",\n", - " groupby_rangefunc=\"stderr\",\n", - " font_size=\"large\",\n", - " ),\n", - " wr.CodeComparer(diff=\"split\"),\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.ParallelCoordinatesPlotColumn(\"Step\"),\n", - " wr.ParallelCoordinatesPlotColumn(\"c::model\"),\n", - " wr.ParallelCoordinatesPlotColumn(\"c::optimizer\"),\n", - " wr.ParallelCoordinatesPlotColumn(\"val_acc\"),\n", - " wr.ParallelCoordinatesPlotColumn(\"val_loss\"),\n", - " ],\n", - " ),\n", - " wr.ParameterImportancePlot(with_respect_to=\"val_loss\"),\n", - " wr.RunComparer(diff_only=True),\n", - " wr.CustomChart(\n", - " query={'summary': ['val_loss', 'val_acc']},\n", - " chart_name='wandb/scatter/v0',\n", - " chart_fields={'x': 'val_loss', 'y': 'val_acc'}\n", - " ),\n", - " ],\n", - " ),\n", - " # Add WeaveBlock types directly to the blocks list\n", - " wr.WeaveBlockSummaryTable(\n", - " entity=\"your_entity\",\n", - " project=\"your_project\",\n", - " table_name=\"my-table\"\n", - " ),\n", - " wr.WeaveBlockArtifact(\n", - " entity=\"your_entity\",\n", - " project=\"your_project\",\n", - " artifact='model-1',\n", - " tab='lineage'\n", - " ),\n", - " wr.WeaveBlockArtifactVersionedFile(\n", - " entity=\"your_entity\",\n", - " project=\"your_project\",\n", - " artifact='model-1',\n", - " version='v0',\n", - " file=\"dataframe.table.json\"\n", - " ),\n", - " ]\n", - ")\n", - "report.save()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_ImXrBtN7NDR" - }, - "source": [ - "## How can I link related reports together?\n", - "- Suppose have have two reports like below:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "ueOH3zoS7NDR" - }, - "outputs": [], - "source": [ - "import wandb_workspaces.reports.v2 as wr\n", - "\n", - "report1 = wr.Report(\n", - " project=PROJECT,\n", - " title='Report 1',\n", - " description=\"Great content coming from Report 1\",\n", - " blocks=[\n", - " wr.H1(text='Heading from Report 1'),\n", - " wr.P(text='Lorem ipsum dolor sit amet. Aut fuga minus nam vero saepeA aperiam eum omnis dolorum et ducimus tempore aut illum quis aut alias vero. Sed explicabo illum est eius quianon vitae sed voluptatem incidunt. Vel architecto assumenda Ad voluptatem quo dicta provident et velit officia. Aut galisum inventoreSed dolore a illum adipisci a aliquam quidem sit corporis quia cum magnam similique.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(\n", - " title=\"Episodic Return\",\n", - " x='global_step',\n", - " y=['charts/episodic_return'],\n", - " smoothing_factor=0.85,\n", - " groupby_aggfunc='mean',\n", - " groupby_rangefunc='minmax',\n", - " layout=wr.Layout(x=0, y=0, w=12, h=8)\n", - " ),\n", - " wr.MediaBrowser(\n", - " media_keys=[\"videos\"],\n", - " num_columns=4,\n", - " layout=wr.Layout(w=12, h=8)\n", - " ),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(\n", - " entity='openrlbenchmark',\n", - " project='cleanrl',\n", - " query='bigfish',\n", - " groupby=['env_id', 'exp_name']\n", - " )\n", - " ],\n", - " custom_run_colors={\n", - " wr.RunsetGroup(runset_name='Run set', keys=(wr.RunsetGroupKey(key='bigfish', value='ppg_procgen'),)): \"#2980b9\",\n", - " wr.RunsetGroup(runset_name='Run set', keys=(wr.RunsetGroupKey(key='bigfish', value='ppo_procgen'),)): \"#e74c3c\",\n", - " }\n", - " ),\n", - " ]\n", - ")\n", - "report1.save()\n", - "\n", - "report2 = wr.Report(\n", - " project=PROJECT,\n", - " title='Report 2',\n", - " description=\"Great content coming from Report 2\",\n", - " blocks=[\n", - " wr.H1(text='Heading from Report 2'),\n", - " wr.P(text='Est quod ducimus ut distinctio corruptiid optio qui cupiditate quibusdam ea corporis modi. Eum architecto vero sed error dignissimosEa repudiandae a recusandae sint ut sint molestiae ea pariatur quae. In pariatur voluptas ad facere neque 33 suscipit et odit nostrum ut internos molestiae est modi enim. Et rerum inventoreAut internos et dolores delectus aut Quis sunt sed nostrum magnam ab dolores dicta.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(\n", - " title=\"SPS\",\n", - " x='global_step',\n", - " y=['charts/SPS']\n", - " ),\n", - " wr.LinePlot(\n", - " title=\"Episodic Length\",\n", - " x='global_step',\n", - " y=['charts/episodic_length']\n", - " ),\n", - " wr.LinePlot(\n", - " title=\"Episodic Return\",\n", - " x='global_step',\n", - " y=['charts/episodic_return']\n", - " ),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(\n", - " entity=\"openrlbenchmark\",\n", - " project=\"cleanrl\",\n", - " name=\"DQN\",\n", - " groupby=[\"exp_name\"]\n", - "\n", - " ),\n", - " wr.Runset(\n", - " entity=\"openrlbenchmark\",\n", - " project=\"cleanrl\",\n", - " name=\"SAC-discrete 0.8\",\n", - " groupby=[\"exp_name\"]\n", - "\n", - " ),\n", - " wr.Runset(\n", - " entity=\"openrlbenchmark\",\n", - " project=\"cleanrl\",\n", - " name=\"SAC-discrete 0.88\",\n", - " groupby=[\"exp_name\"]\n", - "\n", - " ),\n", - " ],\n", - " custom_run_colors={\n", - " wr.RunsetGroup(runset_name='DQN', keys=(wr.RunsetGroupKey(key='dqn_atari', value='exp_name'),)): '#e84118',\n", - " wr.RunsetGroup(runset_name='SAC-discrete 0.8', keys=(wr.RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#fbc531',\n", - " wr.RunsetGroup(runset_name='SAC-discrete 0.88', keys=(wr.RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#00a8ff',\n", - " }\n", - " ),\n", - " ]\n", - ")\n", - "report2.save()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "NOhlK4G47NDR" - }, - "source": [ - "### Combine blocks into a new report" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "vfRryyUM7NDR" - }, - "outputs": [], - "source": [ - "report = wr.Report(PROJECT,\n", - " title=\"Report with links\",\n", - " description=\"Use `wr.Link(text, url)` to add links inside normal text, or use normal markdown syntax in a MarkdownBlock\",\n", - " blocks=[\n", - " wr.H1(\"This is a normal heading\"),\n", - " wr.P(\"And here is some normal text\"),\n", - "\n", - " wr.H1([\"This is a heading \", wr.Link(\"with a link!\", url=\"https://wandb.ai/\")]),\n", - " wr.P([\"Most text formats support \", wr.Link(\"adding links\", url=\"https://wandb.ai/\")]),\n", - "\n", - " wr.MarkdownBlock(\"\"\"You can also use markdown syntax for [links](https://wandb.ai/)\"\"\")\n", - " ]\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "9GWSIsVp7NDU" - }, - "outputs": [], - "source": [ - "report3 = wr.Report(\n", - " PROJECT,\n", - " title=\"Combined blocks report\",\n", - " description=\"This report combines blocks from both Report 1 and Report 2\",\n", - " blocks=[*report1.blocks, *report2.blocks]\n", - ")\n", - "report3.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "pXt2x1L07NDV" - }, - "source": [ - "## I tried mutating an object in list but it didn't work!\n", - "tl;dr: It should always work if you assign a value to the attribute instead of mutating. If you really need to mutate, do it before assignment.\n", - "\n", - "---\n", - "\n", - "This can happen in a few places that contain lists of wandb objects, e.g.:\n", - "- `report.blocks`\n", - "- `panel_grid.panels`\n", - "- `panel_grid.runsets`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "0EbcQqOM7NDV" - }, - "outputs": [], - "source": [ - "report = wr.Report(project=PROJECT)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "H0J06T757NDV" - }, - "source": [ - "Good: Assign `b`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "tgMca01g7NDV" - }, - "outputs": [], - "source": [ - "b = wr.H1(text=[\"Hello\", \" World!\"])\n", - "report.blocks = [b]\n", - "assert b.text == [\"Hello\", \" World!\"]\n", - "assert report.blocks[0].text == [\"Hello\", \" World!\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "uDQ8wSn77NDV" - }, - "source": [ - "Bad: Mutate `b` without reassigning" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "xMX5Xr0x7NDV" - }, - "outputs": [], - "source": [ - "b.text = [\"Something\", \" New\"]\n", - "assert b.text == [\"Something\", \" New\"]\n", - "assert report.blocks[0].text == [\"Hello\", \" World!\"]\n", - "\n", - "# This will error!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "KUMkP_9t7NDV" - }, - "source": [ - "Good: Mutate `b` and then reassign it" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "Wif3JPMo7NDV" - }, - "outputs": [], - "source": [ - "report.blocks = [b]\n", - "assert b.text == [\"Something\", \" New\"]\n", - "assert report.blocks[0].text == [\"Something\", \" New\"]" - ] - } - ], - "metadata": { - "accelerator": "GPU", - "colab": { - "provenance": [], - "toc_visible": true, - "include_colab_link": true - }, - "kernelspec": { - "display_name": "Python 3", - "name": "python3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file diff --git a/colabs/intro/Report_API_Quickstart.ipynb b/colabs/intro/Report_API_Quickstart.ipynb index 2c4215c3..cb4befe1 100644 --- a/colabs/intro/Report_API_Quickstart.ipynb +++ b/colabs/intro/Report_API_Quickstart.ipynb @@ -1,1802 +1,2934 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "M2WAJF1h-Xzs" - }, - "source": [ - "\"Open\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "pvQmwert-Xzt" - }, - "source": [ - "\"Weights\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "w0FL-wiC-Xzt" - }, - "source": [ - "## What is the Report API?\n", - "- Programmatically create and modify reports in Python, including support for editing blocks, panels, and runsets.\n", - "- Create report templates to reuse and share with others\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "5L6aF5NN-Xzt" - }, - "source": [ - "## Quick Links\n", - "- [🚀 Quickstart Guide](#quickstart) (~5min)\n", - "- [❓ FAQ](#faq)\n", - "- [📌 Complete Examples](#complete_examples)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "7sxmv6Kx-Xzu" - }, - "outputs": [], - "source": [ - "!pip install wandb -qqq" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "e0sKfIxF-Xzu" - }, - "source": [ - "## Setup" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "HoF7tFNc-Xzu" - }, - "outputs": [], - "source": [ - "#@title ## Log Runs { run: \"auto\", display-mode: \"form\" }\n", - "#@markdown If this is your first time here, consider running the setup code for a better docs experience!\n", - "#@markdown If you have run the setup code before, you can uncheck the box below to avoid unnecessary logging.\n", - "\n", - "LOG_DUMMY_RUNS = True #@param {type: \"boolean\"}\n", - "\n", - "\n", - "import requests\n", - "from PIL import Image\n", - "from io import BytesIO\n", - "import wandb\n", - "import pandas as pd\n", - "from itertools import product\n", - "import random\n", - "import math\n", - "\n", - "import wandb\n", - "import random\n", - "import string\n", - "\n", - "ENTITY = wandb.apis.PublicApi().default_entity\n", - "PROJECT = \"report-api-quickstart\" #@param {type: \"string\"}\n", - "LINEAGE_PROJECT = \"lineage-example\" #@param {type: \"string\"}\n", - "\n", - "\n", - "def get_image(url):\n", - " r = requests.get(url)\n", - " return Image.open(BytesIO(r.content))\n", - "\n", - "\n", - "def log_dummy_data():\n", - " run_names = [\n", - " \"adventurous-aardvark-1\",\n", - " \"bountiful-badger-2\",\n", - " \"clairvoyant-chipmunk-3\",\n", - " \"dastardly-duck-4\",\n", - " \"eloquent-elephant-5\",\n", - " \"flippant-flamingo-6\",\n", - " \"giddy-giraffe-7\",\n", - " \"haughty-hippo-8\",\n", - " \"ignorant-iguana-9\",\n", - " \"jolly-jackal-10\",\n", - " \"kind-koala-11\",\n", - " \"laughing-lemur-12\",\n", - " \"manic-mandrill-13\",\n", - " \"neighbourly-narwhal-14\",\n", - " \"oblivious-octopus-15\",\n", - " \"philistine-platypus-16\",\n", - " \"quant-quail-17\",\n", - " \"rowdy-rhino-18\",\n", - " \"solid-snake-19\",\n", - " \"timid-tarantula-20\",\n", - " \"understanding-unicorn-21\",\n", - " \"voracious-vulture-22\",\n", - " \"wu-tang-23\",\n", - " \"xenic-xerneas-24\",\n", - " \"yielding-yveltal-25\",\n", - " \"zooming-zygarde-26\",\n", - " ]\n", - "\n", - " opts = [\"adam\", \"sgd\"]\n", - " encoders = [\"resnet18\", \"resnet50\"]\n", - " learning_rates = [0.01]\n", - " for (i, run_name), (opt, encoder, lr) in zip(\n", - " enumerate(run_names), product(opts, encoders, learning_rates)\n", - " ):\n", - " config = {\n", - " \"optimizer\": opt,\n", - " \"encoder\": encoder,\n", - " \"learning_rate\": lr,\n", - " \"momentum\": 0.1 * random.random(),\n", - " }\n", - " displacement1 = random.random() * 2\n", - " displacement2 = random.random() * 4\n", - " with wandb.init(\n", - " entity=ENTITY, project=PROJECT, config=config, name=run_name\n", - " ) as run:\n", - " for step in range(1000):\n", - " wandb.log(\n", - " {\n", - " \"acc\": 0.1\n", - " + 0.4\n", - " * (\n", - " math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " + random.random()\n", - " + displacement1\n", - " + random.random() * run.config.momentum\n", - " ),\n", - " \"val_acc\": 0.1\n", - " + 0.4\n", - " * (\n", - " math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " - random.random()\n", - " + displacement1\n", - " ),\n", - " \"loss\": 0.1\n", - " + 0.08\n", - " * (\n", - " 3.5\n", - " - math.log(1 + step + random.random())\n", - " + random.random() * run.config.momentum\n", - " + random.random()\n", - " + displacement2\n", - " ),\n", - " \"val_loss\": 0.1\n", - " + 0.04\n", - " * (\n", - " 4.5\n", - " - math.log(1 + step + random.random())\n", - " + random.random() * run.config.learning_rate\n", - " - random.random()\n", - " + displacement2\n", - " ),\n", - " }\n", - " )\n", - "\n", - " with wandb.init(\n", - " entity=ENTITY, project=PROJECT, config=config, name=run_names[i + 1]\n", - " ) as run:\n", - " img = get_image(\n", - " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", - " )\n", - " image = wandb.Image(img)\n", - " df = pd.DataFrame(\n", - " {\n", - " \"int\": [1, 2, 3, 4],\n", - " \"float\": [1.2, 2.3, 3.4, 4.5],\n", - " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", - " \"img\": [image] * 4,\n", - " }\n", - " )\n", - " run.log({\"img\": image, \"my-table\": df})\n", - "\n", - "\n", - "class Step:\n", - " def __init__(self, j, r, u, o, at=None):\n", - " self.job_type = j\n", - " self.runs = r\n", - " self.uses_per_run = u\n", - " self.outputs_per_run = o\n", - " self.artifact_type = at if at is not None else \"model\"\n", - " self.artifacts = []\n", - "\n", - "\n", - "def create_artifact(name: str, type: str, content: str):\n", - " art = wandb.Artifact(name, type)\n", - " with open(\"boom.txt\", \"w\") as f:\n", - " f.write(content)\n", - " art.add_file(\"boom.txt\", \"test-name\")\n", - "\n", - " img = get_image(\n", - " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", - " )\n", - " image = wandb.Image(img)\n", - " df = pd.DataFrame(\n", - " {\n", - " \"int\": [1, 2, 3, 4],\n", - " \"float\": [1.2, 2.3, 3.4, 4.5],\n", - " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", - " \"img\": [image] * 4,\n", - " }\n", - " )\n", - " art.add(wandb.Table(dataframe=df), \"dataframe\")\n", - " return art\n", - "\n", - "\n", - "def log_dummy_lineage():\n", - " pipeline = [\n", - " Step(\"dataset-generator\", 1, 0, 3, \"dataset\"),\n", - " Step(\"trainer\", 4, (1, 2), 3),\n", - " Step(\"evaluator\", 2, 1, 3),\n", - " Step(\"ensemble\", 1, 1, 1),\n", - " ]\n", - " for (i, step) in enumerate(pipeline):\n", - " for _ in range(step.runs):\n", - " with wandb.init(project=LINEAGE_PROJECT, job_type=step.job_type) as run:\n", - " # use\n", - " uses = step.uses_per_run\n", - " if type(uses) == tuple:\n", - " uses = random.choice(list(uses))\n", - "\n", - " if i > 0:\n", - " prev_step = pipeline[i - 1]\n", - " input_artifacts = random.sample(prev_step.artifacts, uses)\n", - " for a in input_artifacts:\n", - " run.use_artifact(a)\n", - " # log output artifacts\n", - " for j in range(step.outputs_per_run):\n", - " # name = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))\n", - " name = f\"{step.artifact_type}-{j}\"\n", - " content = \"\".join(\n", - " random.choices(string.ascii_lowercase + string.digits, k=12)\n", - " )\n", - " art = create_artifact(name, step.artifact_type, content)\n", - " run.log_artifact(art)\n", - " art.wait()\n", - "\n", - " # save in pipeline\n", - " step.artifacts.append(art)\n", - "\n", - "if LOG_DUMMY_RUNS:\n", - " log_dummy_data()\n", - " log_dummy_lineage()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZdY28qJ1-Xzv" - }, - "source": [ - "\n", - "# 🚀 Quickstart! " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "_TEswLKM-Xzv" - }, - "outputs": [], - "source": [ - "import wandb_workspaces.reports.v2 as wr" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "xg8Fpy2Y-Xzv" - }, - "source": [ - "## Create, save, and load reports\n", - "- NOTE: Reports are not saved automatically to reduce clutter. Explicitly save the report by calling `report.save()`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "IXIifq0w-Xzv" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " project=PROJECT,\n", - " title='Quickstart Report',\n", - " description=\"That was easy!\"\n", - ") # Create\n", - "report.save() # Save\n", - "wr.Report.from_url(report.url) # Load" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "r98Xq-Oq-Xzv" - }, - "source": [ - "## Add content via blocks\n", - "- Use blocks to add content like text, images, code, and more\n", - "- See `wr.blocks` for all available blocks" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "IMsC1PBA-Xzv" - }, - "outputs": [], - "source": [ - "report.blocks = [\n", - " wr.TableOfContents(),\n", - " wr.H1(\"Text and images example\"),\n", - " wr.P(\"Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.\"),\n", - " wr.Image('https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'),\n", - " wr.P(\"Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?\"),\n", - "]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "3S5FkFSB-Xzv" - }, - "source": [ - "## Add charts and more via Panel Grid\n", - "- `PanelGrid` is a special type of block that holds `runsets` and `panels`\n", - " - `runsets` organize data logged to W&B\n", - " - `panels` visualize runset data. For a full set of panels, see `wr.panels`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "8ap99b4e-Xzv" - }, - "outputs": [], - "source": [ - "pg = wr.PanelGrid(\n", - " runsets=[\n", - " wr.Runset(ENTITY, PROJECT, \"First Run Set\"),\n", - " wr.Runset(ENTITY, PROJECT, \"Elephants Only!\", query=\"elephant\"),\n", - " ],\n", - " panels=[\n", - " wr.LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8),\n", - " wr.BarPlot(metrics=['acc']),\n", - " wr.MediaBrowser(media_keys='img', num_columns=1),\n", - " wr.RunComparer(diff_only='split', layout={'w': 24, 'h': 9}),\n", - " ]\n", - ")\n", - "\n", - "report.blocks = report.blocks[:1] + [wr.H1(\"Panel Grid Example\"), pg] + report.blocks[1:]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Na6t1RhW-Xzw" - }, - "source": [ - "## Add data lineage with Artifact blocks\n", - "- There are equivalent weave panels as well" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "OaOtPzA6-Xzw" - }, - "outputs": [], - "source": [ - "artifact_lineage = wr.WeaveBlockArtifact(entity=ENTITY, project=LINEAGE_PROJECT, artifact='model-1', tab='lineage')\n", - "\n", - "report.blocks = report.blocks[:1] + [wr.H1(\"Artifact lineage example\"), artifact_lineage] + report.blocks[1:]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "s9aURGQv-Xzw" - }, - "source": [ - "## Customize run colors\n", - "- Pass in a `dict[run_name, color]`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "NtT7lUUJ-Xzw" - }, - "outputs": [], - "source": [ - "pg.custom_run_colors = {\n", - " 'adventurous-aardvark-1': '#e84118',\n", - " 'bountiful-badger-2': '#fbc531',\n", - " 'clairvoyant-chipmunk-3': '#4cd137',\n", - " 'dastardly-duck-4': '#00a8ff',\n", - " 'eloquent-elephant-5': '#9c88ff',\n", - "}\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "FrSnZ3KK-Xzw" - }, - "source": [ - "## Customize run sets with grouping, filtering, and ordering\n", - "- Click on the different run sets in the iframe below and see how they are different\n", - "- Grouping: Pass in a list of columns to group by\n", - "- Filtering: Use `set_filters_with_python_expr` and pass in a valid python expression. The syntax is similar to `pandas.DataFrame.query`\n", - "- Ordering: Pass in a list of columns where each value is prefixed with `+` for ascending or `-` for descending." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "bQHzEsCb-Xzw" - }, - "outputs": [], - "source": [ - "pg.runsets = [\n", - " wr.Runset(ENTITY, PROJECT, name=\"Grouping\", groupby=[\"encoder\"]),\n", - " wr.Runset(ENTITY, PROJECT, name=\"Filtering\").set_filters_with_python_expr(\"encoder == 'resnet18' and loss < 0.05\"),\n", - " wr.Runset(ENTITY, PROJECT, name=\"Ordering\", order=[\"+momentum\", \"-Name\"]),\n", - "]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Ss9ROZ9_-Xzw" - }, - "source": [ - "## Customize group colors\n", - "- Pass in a `dict[ordertuple, color]`, where `ordertuple: tuple[runset_name, *groupby_values]`\n", - "- For example:\n", - " - Your runset is named `MyRunset`\n", - " - Your runset groupby is `[\"encoder\", \"optimizer\"]`\n", - " - Then your tuple can be `(\"MyRunset\", \"resnet18\", \"adam\")`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "_EW3h5aT-Xzw" - }, - "outputs": [], - "source": [ - "pg.custom_run_colors = {\n", - " ('Grouping', 'resnet50'): 'red',\n", - " ('Grouping', 'resnet18'): 'blue',\n", - "\n", - " # you can do both grouped and ungrouped colors in the same dict\n", - " 'adventurous-aardvark-1': '#e84118',\n", - " 'bountiful-badger-2': '#fbc531',\n", - " 'clairvoyant-chipmunk-3': '#4cd137',\n", - " 'dastardly-duck-4': '#00a8ff',\n", - " 'eloquent-elephant-5': '#9c88ff',\n", - "}\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "-A18XV-I-Xzw" - }, - "source": [ - "# ❓ FAQ " - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "rlCi7oGR-Xzw" - }, - "source": [ - "## My chart is not rendering as expected.\n", - "- We try to guess the column type, but sometimes we fail.\n", - "- Try prefixing:\n", - " - `c::` for config values\n", - " - `s::` for summary metrics\n", - " - e.g. if your config value was `optimizer`, try `c::optimizer`" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "uaAxVmDo-Xzw" - }, - "source": [ - "## My report is too wide/narrow\n", - "- Change the report's width to the right size for you." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "W49O0BtF-Xzw" - }, - "outputs": [], - "source": [ - "report2 = report.save(clone=True)\n", - "report2.width = 'fluid'\n", - "report2.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "7MIglFd3-Xzw" - }, - "source": [ - "## How do I resize panels?\n", - "- Pass a `dict[dim, int]` to `panel.layout`\n", - "- `dim` is a dimension, which can be `x`, `y` (the coordiantes of the top left corner) `w`, `h` (the size of the panel)\n", - "- You can pass any or all dimensions at once\n", - "- The space between two dots in a panel grid is 2." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "2PUn_ksa-Xzw" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " PROJECT,\n", - " title=\"Resizing panels\",\n", - " description=\"Look at this wide parallel coordinates plot!\",\n", - " blocks=[\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.PCColumn(\"Step\"),\n", - " wr.PCColumn(\"c::model\"),\n", - " wr.PCColumn(\"c::optimizer\"),\n", - " wr.PCColumn(\"Step\"),\n", - " wr.PCColumn(\"val_acc\"),\n", - " wr.PCColumn(\"val_loss\"),\n", - " ],\n", - " layout={'w': 24, 'h': 9} # change the layout!\n", - " ),\n", - " ]\n", - " )\n", - " ]\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "HiOZOhd9-Xzw" - }, - "source": [ - "## What blocks are available?\n", - "- See `wr.blocks` for a list of blocks.\n", - "- In an IDE or notebook, you can also do `wr.blocks.` to get autocomplete." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "WEXbWxK0-Xzw" - }, - "outputs": [], - "source": [ - "# Panel grid is omitted. See next section for PanelGrid and panels\n", - "report = wr.Report(\n", - " PROJECT,\n", - " title='W&B Block Gallery',\n", - " description=\"Check out all of the blocks available in W&B\",\n", - " blocks=[\n", - " wr.H1(text=\"Heading 1\"),\n", - " wr.P(text=\"Normal paragraph\"),\n", - " wr.H2(text=\"Heading 2\"),\n", - " wr.P(\n", - " [\n", - " \"here is some text, followed by\",\n", - " wr.InlineCode(\"select * from code in line\"),\n", - " \"and then latex\",\n", - " wr.InlineLaTeX(\"e=mc^2\"),\n", - " ]\n", - " ),\n", - " wr.H3(text=\"Heading 3\"),\n", - " wr.CodeBlock(\n", - " code=[\"this:\", \"- is\", \"- a\", \"cool:\", \"- yaml\", \"- file\"],\n", - " language=\"yaml\",\n", - " ),\n", - " wr.WeaveBlockSummaryTable(ENTITY, PROJECT, 'my-table'),\n", - " wr.WeaveBlockArtifact(ENTITY, LINEAGE_PROJECT, 'model-1', 'lineage'),\n", - " wr.WeaveBlockArtifactVersionedFile(ENTITY, LINEAGE_PROJECT, 'model-1', 'v0', \"dataframe.table.json\"),\n", - " wr.MarkdownBlock(text=\"Markdown cell with *italics* and **bold** and $e=mc^2$\"),\n", - " wr.LaTeXBlock(text=\"\\\\gamma^2+\\\\theta^2=\\\\omega^2\\n\\\\\\\\ a^2 + b^2 = c^2\"),\n", - " wr.Image(\"https://api.wandb.ai/files/megatruong/images/projects/918598/350382db.gif\", caption=\"It's a me, Pikachu\"),\n", - " wr.UnorderedList(items=[\"Bullet 1\", \"Bullet 2\"]),\n", - " wr.OrderedList(items=[\"Ordered 1\", \"Ordered 2\"]),\n", - " wr.CheckedList(items=[\"Unchecked\", \"Checked\"], checked=[False, True]),\n", - " wr.BlockQuote(text=\"Block Quote 1\\nBlock Quote 2\\nBlock Quote 3\"),\n", - " wr.CalloutBlock(text=[\"Callout 1\", \"Callout 2\", \"Callout 3\"]),\n", - " wr.HorizontalRule(),\n", - " wr.Video(url=\"https://www.youtube.com/embed/6riDJMI-Y8U\"),\n", - " wr.Spotify(spotify_id=\"5cfUlsdrdUE4dLMK7R9CFd\"),\n", - " wr.SoundCloud(url=\"https://api.soundcloud.com/tracks/1076901103\"),\n", - " ]\n", - ").save()\n", - "report.blocks += [wr.Gallery(ids=[report.id])] # get report id on save\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "DIOcQ5xm-Xzw" - }, - "source": [ - "## What panels are available?\n", - "- See `wr.panels` for a list of panels\n", - "- In an IDE or notebook, you can also do `wr.panels.` to get autocomplete.\n", - "- Panels have a lot of settings. Inspect the panel to see what you can do!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "dvYkqbMV-Xzw" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " project=PROJECT,\n", - " title='W&B Panel Gallery',\n", - " description=\"Check out all of the panels available in W&B\",\n", - " width='fluid',\n", - " blocks=[\n", - " wr.PanelGrid(\n", - " runsets=[\n", - " wr.Runset(project=LINEAGE_PROJECT),\n", - " wr.Runset(),\n", - " ],\n", - " panels=[\n", - " wr.MediaBrowser(media_keys=\"img\"),\n", - " wr.MarkdownPanel(\"Hello *italic* **bold** $e=mc^2$ `something`\"),\n", - "\n", - " # LinePlot showed with many settings enabled for example\n", - " wr.LinePlot(\n", - " title=\"Validation Accuracy over Time\",\n", - " x=\"Step\",\n", - " y=[\"val_acc\"],\n", - " range_x=[0, 1000],\n", - " range_y=[1, 4],\n", - " log_x=True,\n", - " title_x=\"Training steps\",\n", - " title_y=\"Validation Accuracy\",\n", - " ignore_outliers=True,\n", - " groupby='encoder',\n", - " groupby_aggfunc=\"mean\",\n", - " groupby_rangefunc=\"minmax\",\n", - " smoothing_factor=0.5,\n", - " smoothing_type=\"gaussian\",\n", - " smoothing_show_original=True,\n", - " max_runs_to_show=10,\n", - " font_size=\"large\",\n", - " legend_position=\"west\",\n", - " ),\n", - " wr.ScatterPlot(\n", - " title=\"Validation Accuracy vs. Validation Loss\",\n", - " x=\"val_acc\",\n", - " y=\"val_loss\",\n", - " log_x=False,\n", - " log_y=False,\n", - " running_ymin=True,\n", - " running_ymean=True,\n", - " running_ymax=True,\n", - " font_size=\"small\",\n", - " regression=True,\n", - " ),\n", - " wr.BarPlot(\n", - " title=\"Validation Loss by Encoder\",\n", - " metrics=[\"val_loss\"],\n", - " orientation='h',\n", - " range_x=[0, 0.11],\n", - " title_x=\"Validation Loss\",\n", - " # title_y=\"y axis title\",\n", - " groupby='encoder',\n", - " groupby_aggfunc=\"median\",\n", - " groupby_rangefunc=\"stddev\",\n", - " max_runs_to_show=20,\n", - " max_bars_to_show=3,\n", - " font_size=\"auto\",\n", - " ),\n", - " wr.ScalarChart(\n", - " title=\"Maximum Number of Steps\",\n", - " metric=\"Step\",\n", - " groupby_aggfunc=\"max\",\n", - " groupby_rangefunc=\"stderr\",\n", - " font_size=\"large\",\n", - " ),\n", - " wr.CodeComparer(diff=\"split\"),\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.PCColumn(\"Step\"),\n", - " wr.PCColumn(\"c::model\"),\n", - " wr.PCColumn(\"c::optimizer\"),\n", - " wr.PCColumn(\"Step\"),\n", - " wr.PCColumn(\"val_acc\"),\n", - " wr.PCColumn(\"val_loss\"),\n", - " ],\n", - " ),\n", - " wr.ParameterImportancePlot(with_respect_to=\"val_loss\"),\n", - " wr.RunComparer(diff_only=\"split\"),\n", - " wr.CustomChart(\n", - " query={'summary': ['val_loss', 'val_acc']},\n", - " chart_name='wandb/scatter/v0',\n", - " chart_fields={'x': 'val_loss', 'y': 'val_acc'}\n", - " ),\n", - " wr.WeavePanelSummaryTable(\"my-table\"),\n", - " wr.WeavePanelArtifact('model-1', 'lineage', layout={'w': 24, 'h': 12}),\n", - " wr.WeavePanelArtifactVersionedFile('model-1', 'v0', \"dataframe.table.json\", layout={'w': 24, 'h': 12}),\n", - " ],\n", - " ),\n", - " ]\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "qo-ePHIh-Xzx" - }, - "source": [ - "## What above weave?\n", - "- A limited subset of weave panels are available today, including Artifact, ArtifactVersionedFile, and SummaryTable\n", - "- Stay tuned for future updates around weave support!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "o2K9swaI-Xzx" - }, - "source": [ - "## Can I use this in CI (e.g. create a report for each git commit?)\n", - "- Yep! Check out [this example](https://github.com/andrewtruong/wandb-gh-actions/actions/runs/3476558992) which creates a report via Github Actions" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "oaNU3N9d-Xzx" - }, - "source": [ - "## How can I link related reports together?\n", - "- Suppose have have two reports like below:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "F_eLx-3f-Xzx" - }, - "outputs": [], - "source": [ - "report1 = wr.Report(\n", - " PROJECT,\n", - " title='Report 1',\n", - " description=\"Great content coming from Report 1\",\n", - " blocks=[\n", - " wr.H1('Heading from Report 1'),\n", - " wr.P('Lorem ipsum dolor sit amet. Aut fuga minus nam vero saepeA aperiam eum omnis dolorum et ducimus tempore aut illum quis aut alias vero. Sed explicabo illum est eius quianon vitae sed voluptatem incidunt. Vel architecto assumenda Ad voluptatem quo dicta provident et velit officia. Aut galisum inventoreSed dolore a illum adipisci a aliquam quidem sit corporis quia cum magnam similique.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='bigfish', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'bigfish', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'bigfish', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " ]\n", - ").save()\n", - "\n", - "report2 = wr.Report(\n", - " PROJECT,\n", - " title='Report 2',\n", - " description=\"Great content coming from Report 2\",\n", - " blocks=[\n", - " wr.H1('Heading from Report 2'),\n", - " wr.P('Est quod ducimus ut distinctio corruptiid optio qui cupiditate quibusdam ea corporis modi. Eum architecto vero sed error dignissimosEa repudiandae a recusandae sint ut sint molestiae ea pariatur quae. In pariatur voluptas ad facere neque 33 suscipit et odit nostrum ut internos molestiae est modi enim. Et rerum inventoreAut internos et dolores delectus aut Quis sunt sed nostrum magnam ab dolores dicta.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/SPS']),\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_length']),\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return']),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"DQN\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'dqn_atari'\"),\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"SAC-discrete 0.8\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'sac_atari' and target_entropy_scale == 0.8\"),\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"SAC-discrete 0.88\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'sac_atari' and target_entropy_scale == 0.88\"),\n", - " ],\n", - " custom_run_colors={\n", - " ('DQN', 'dqn_atari'): '#e84118',\n", - " ('SAC-discrete 0.8', 'sac_atari'): '#fbc531',\n", - " ('SAC-discrete 0.88', 'sac_atari'): '#00a8ff',\n", - " }\n", - " ),\n", - " ]\n", - ").save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "s9Jt37Iy-Xzx" - }, - "source": [ - "### Combine blocks into a new report" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "r1u2CA7B-Xzx" - }, - "outputs": [], - "source": [ - "report = wr.Report(PROJECT,\n", - " title=\"Report with links\",\n", - " description=\"Use `wr.Link(text, url)` to add links inside normal text, or use normal markdown syntax in a MarkdownBlock\",\n", - " blocks=[\n", - " wr.H1(\"This is a normal heading\"),\n", - " wr.P(\"And here is some normal text\"),\n", - "\n", - " wr.H1([\"This is a heading \", wr.Link(\"with a link!\", url=\"https://wandb.ai/\")]),\n", - " wr.P([\"Most text formats support \", wr.Link(\"adding links\", url=\"https://wandb.ai/\")]),\n", - "\n", - " wr.MarkdownBlock(\"\"\"You can also use markdown syntax for [links](https://wandb.ai/)\"\"\")\n", - " ]\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "RSjeKS5y-Xz0" - }, - "outputs": [], - "source": [ - "report3 = wr.Report(\n", - " PROJECT,\n", - " title=\"Combined blocks report\",\n", - " description=\"This report combines blocks from both Report 1 and Report 2\",\n", - " blocks=[*report1.blocks, *report2.blocks]\n", - ")\n", - "report3.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "evlCG_Yo-Xz0" - }, - "source": [ - "### Reference the two reports in a gallery block" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "eVHeoFYT-Xz0" - }, - "outputs": [], - "source": [ - "report4 = wr.Report(\n", - " PROJECT,\n", - " title=\"Referenced reports via Gallery\",\n", - " description=\"This report has gallery links to Report1 and Report 2\",\n", - " blocks=[wr.Gallery(ids=[report1.id, report2.id])]\n", - ")\n", - "report4.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Z4Pa6lbw-Xz0" - }, - "source": [ - "## How do I add links to text?\n", - "- Use `wr.Link`" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "TpbamsC8-Xz0" - }, - "source": [ - "## Do you support markdown?\n", - "Yep\n", - "- In blocks, use `wr.MarkdownBlock`\n", - "- In panels, use `wr.MarkdownPanel`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "wCwLMEjl-Xz0" - }, - "outputs": [], - "source": [ - "markdown = \"\"\"\n", - "# Ducat quicquam\n", - "\n", - "## Egit sit utque torta cuncta si oret\n", - "\n", - "Lorem markdownum voco sacrorum religata. Erat ante condita mellaque Cimmerios\n", - "cultoribus pictas manu usquam illa umbra potentia inpedienda Padumque [euntes\n", - "motae](http://nec.com/necsollemnia.aspx), detraxit! Accessus discrimen,\n", - "Cyllenius *e* solum saepe terras perfringit amorem tenent consulit falce\n", - "referemus tantum. Illo qui attonitas, Adonis ultra stabunt horret requiescere\n", - "quae deam similis miserum consuetas: tantos aegram, metuam. Tetigere\n", - "**invidiae** preces indicere populo semper, limine sui dumque, lustra\n", - "alimentaque vidi nec corpusque aquarum habebat, in.\n", - "\n", - "\n", - "## Aurea simile iunctoque dux semper verbis\n", - "\n", - "Vinctorum vidisset et caede officio, viae alia ratione aer regalia, etiamnum.\n", - "Occupat tanta; vicem, Ithaceque, et ille nec exclamat. Honori carpserat visae\n", - "magniloquo perluitur corpora tamen. Caput an Minervae sed vela est cecidere\n", - "luctus umbras iunctisque referat. Accensis **aderis capillos** pendebant\n", - "[retentas parvum](http://ipse.com/).\n", - "\n", - " if (desktop(2)) {\n", - " laser_qwerty_optical.webcam += upsRoom + window;\n", - " }\n", - " if (type) {\n", - " memoryGrayscale(backbone, mask_multimedia_html);\n", - " }\n", - " if (natInterfaceFile == 23 + 92) {\n", - " interface_sku.platform = compressionMotherboard - error_veronica_ata;\n", - " dsl_windows = 57 * -2;\n", - " definition *= -4;\n", - " } else {\n", - " frame(4, market_chip_irq, megapixel_eide);\n", - " }\n", - " if (mashupApiFlash(-1, margin) - graphicSoftwareNas.ddr_samba_reimage(port)\n", - " != control_navigation_pseudocode(yahoo.microcomputerDimm(\n", - " mips_adsl))) {\n", - " postscriptViralDirectx(1, cron_router_voip(669103, managementPitch,\n", - " ospf_up_paper), frame);\n", - " servlet_cross_paper.controlLanguage(insertion_source.viewHorizontalRead(\n", - " enterprise, widget, parse_encoding), end);\n", - " script_e(rateRss(yobibyte, fddi, vci_hyper_joystick), surgeHeat / case);\n", - " }\n", - " pcmciaRealSystem.basic_exbibyte_controller = carrier.domainDesktop(-4 +\n", - " laptop + 5);\n", - "\"\"\"\n", - "\n", - "report = wr.Report(\n", - " PROJECT,\n", - " title=\"Report with markdown\",\n", - " description=\"See what's possible with MarkdownBlock and MarkdownPanel\",\n", - " blocks=[\n", - " wr.MarkdownBlock(markdown),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.MarkdownPanel(markdown, layout={'w': 12, 'h': 18}),\n", - " wr.LinePlot(x='Step', y=['val_acc'] , layout={'x': 12, 'y': 0}),\n", - " wr.LinePlot(x='Step', y=['val_loss'], layout={'x': 12, 'y': 6}),\n", - " wr.ScatterPlot(x='val_loss', y='val_acc', layout={'x': 12, 'y': 12}),\n", - " ]\n", - " )\n", - " ]\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "7ckHP3kk-Xz0" - }, - "source": [ - "## Can I build the report up from smaller pieces / all at once?\n", - "Yep. We'll demonstrate by putting together a report with a parallel coordinates plot.\n", - "\n", - "NOTE: this section assumes you have run the [sweeps notebook](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/pytorch/Organizing_Hyperparameter_Sweeps_in_PyTorch_with_W%26B.ipynb) already." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ksykTryf-Xz0" - }, - "source": [ - "### Build it up incrementally\n", - "As you might do if you were creating a report in the UI" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "gPD3RhqU-Xz0" - }, - "source": [ - "1. Create a report" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "uNFjNkRV-Xz0" - }, - "outputs": [], - "source": [ - "report = wr.Report(project=PROJECT, title='Parallel Coordinates Example', description=\"Using the pytorch sweeps demo\")" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "junb5KM5-Xz0" - }, - "source": [ - "2. Add a panel grid" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "v_zgFrVI-Xz0" - }, - "outputs": [], - "source": [ - "pg = wr.PanelGrid()\n", - "report.blocks = [pg]" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "UhjIUOnI-Xz0" - }, - "source": [ - "3. Specify your runsets" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "6SyjOELb-Xz0" - }, - "outputs": [], - "source": [ - "pg.runsets = [wr.Runset(project='pytorch-sweeps-demo')]" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "OxAmS9Ss-Xz0" - }, - "source": [ - "4. Specify your panels" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "4KEr8nQg-Xz0" - }, - "outputs": [], - "source": [ - "pg.panels = [\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.PCColumn(metric=\"c::batch_size\"),\n", - " wr.PCColumn(metric=\"c::dropout\"),\n", - " wr.PCColumn(metric=\"c::epochs\"),\n", - " wr.PCColumn(metric=\"c::fc_layer_size\"),\n", - " wr.PCColumn(metric=\"c::learning_rate\"),\n", - " wr.PCColumn(metric=\"c::optimizer\"),\n", - " wr.PCColumn(metric=\"loss\"),\n", - " ]\n", - " )\n", - "]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6aSFNZmu-Xz1" - }, - "source": [ - "5. Save the report" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "jZj36byz-Xz1" - }, - "outputs": [], - "source": [ - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "F7WZsONp-Xz1" - }, - "source": [ - "### The same thing all-in-one" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "3Lm0kGAU-Xz1" - }, - "outputs": [], - "source": [ - "report = wr.Report(\n", - " project=PROJECT,\n", - " title=\"Parallel Coordinates Example (all-in-one)\",\n", - " description=\"Using the pytorch sweeps demo (same as the other one but written in one expression)\",\n", - " blocks=[\n", - " wr.PanelGrid(\n", - " runsets=[wr.Runset(project=\"pytorch-sweeps-demo\")],\n", - " panels=[\n", - " wr.ParallelCoordinatesPlot(\n", - " columns=[\n", - " wr.PCColumn(metric='c::batch_size'),\n", - " wr.PCColumn(metric='c::dropout'),\n", - " wr.PCColumn(metric='c::epochs'),\n", - " wr.PCColumn(metric='c::fc_layer_size'),\n", - " wr.PCColumn(metric='c::learning_rate'),\n", - " wr.PCColumn(metric='c::optimizer'),\n", - " wr.PCColumn(metric='loss'),\n", - " ]\n", - " )\n", - " ],\n", - " )\n", - " ],\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "OacCxbQ7-Xz1" - }, - "outputs": [], - "source": [ - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "sLBjW_ih-Xz1" - }, - "source": [ - "## I tried mutating an object in list but it didn't work!\n", - "tl;dr: It should always work if you assign a value to the attribute instead of mutating. If you really need to mutate, do it before assignment.\n", - "\n", - "---\n", - "\n", - "This can happen in a few places that contain lists of wandb objects, e.g.:\n", - "- `report.blocks`\n", - "- `panel_grid.panels`\n", - "- `panel_grid.runsets`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "l4hozxCZ-Xz1" - }, - "outputs": [], - "source": [ - "report = wr.Report(project=PROJECT)" + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cPVgUCLA7NDN" + }, + "source": [ + "\"Weights\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "notdNrjvIn2O" + }, + "source": [ + "## 📝 W&B Report API\n", + "Programmatically create, manage, and customize Reports by defining configurations, panel layouts, and runsets with the wandb-workspaces W&B library. Load and modify Reports with URLs, filter and group runs using expressions, and customize run appearances using Report templates.\n", + "\n", + "[wandb-workspaces](https://github.com/wandb/wandb-workspaces) is a Python library for programmatically creating and customizing W&B Workspaces and Reports.\n", + "\n", + "In this tutorial you will see how to use wandb-workspaces to create and customize W&B Reports." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "S1e3tnre7NDO" + }, + "outputs": [], + "source": [ + "#install dependencies\n", + "!pip install wandb wandb-workspaces -qqq" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "9UGFOwXG7NDO" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mnoahluna\u001b[0m. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" + ] + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084128-2y8hbgby" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run adventurous-aardvark-1 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/report-api-quickstart" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/report-api-quickstart/runs/2y8hbgby" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 3.4% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "

Run history:


acc▁▃▄▄▅▅▆▆▅▆▅▆▆▇▆▆▇▆▇▆▇▆▇▇▇▆██▇▇▇▇▇█▇▇█▇▇▇
loss█▆▄▅▄▄▄▄▄▄▃▃▂▃▃▃▂▂▂▂▃▂▂▂▂▂▁▂▂▂▂▂▂▁▁▁▁▁▂▂
val_acc▁▃▃▄▄▅▅▅▅▆▆▅▆▆▆▇▇▇▆▇▇▆▆▇█▇▆█▆▇█▇▇▇██▇▇▇█
val_loss█▇▅▅▄▄▄▄▄▄▄▃▃▃▃▃▂▃▃▃▂▂▂▂▂▂▂▂▂▁▁▂▂▂▂▂▁▂▁▂

Run summary:


acc3.4914
loss-0.01171
val_acc3.12969
val_loss0.05273

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run adventurous-aardvark-1 at: https://wandb.ai/noahluna/report-api-quickstart/runs/2y8hbgby
View project at: https://wandb.ai/noahluna/report-api-quickstart
Synced 4 W&B file(s), 0 media file(s), 4 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084128-2y8hbgby/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084135-cko2fnwe" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run bountiful-badger-2 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/report-api-quickstart" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/report-api-quickstart/runs/cko2fnwe" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 58.5% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "

Run history:


acc▁▃▃▅▅▅▆▅▆▆▆▅▆▆▆▆▆▆▆▇▆▇▇▆▇▇▇▇▇▇▇▇▇██▇███▇
loss█▆▆▅▅▅▄▃▃▃▃▃▃▃▂▂▃▃▂▂▂▂▂▂▂▃▂▂▂▂▂▂▂▂▂▂▁▂▂▁
val_acc▁▂▄▄▅▅▅▅▆▆▆▆▆▅▆▆▆▇▇▆▆▇▇▇▇▇▇▇▇█▇▇▇▇▇▇█▇█▇
val_loss█▇▆▆▄▄▄▃▄▄▄▃▃▃▃▃▃▃▃▂▃▃▂▃▂▃▃▂▁▂▁▁▂▁▁▂▁▂▂▂

Run summary:


acc3.88925
loss0.14258
val_acc3.12525
val_loss0.1342

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run bountiful-badger-2 at: https://wandb.ai/noahluna/report-api-quickstart/runs/cko2fnwe
View project at: https://wandb.ai/noahluna/report-api-quickstart
Synced 4 W&B file(s), 0 media file(s), 2 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084135-cko2fnwe/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084142-z5ept0jf" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run clairvoyant-chipmunk-3 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/report-api-quickstart" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/report-api-quickstart/runs/z5ept0jf" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 58.5% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "

Run history:


acc▁▃▃▅▄▄▅▅▅▆▆▆▆▅▇▆▇▆▇▇▆▇▇▇▇▇█▇▇██▇▇▇█▇█▇██
loss█▇▆▆▄▅▅▄▃▄▄▄▄▄▄▃▄▄▃▂▂▃▂▃▂▂▂▂▃▂▂▃▁▂▂▂▂▂▁▁
val_acc▁▂▄▄▄▄▅▅▅▅▆▆▅▇▆▆▆▆▆▇▇▇▇█▇▇█▇▇█▇▇█▇▇▇██▇█
val_loss█▇▅▅▅▅▄▄▄▄▃▃▃▄▃▃▃▂▂▂▃▂▃▂▂▂▁▂▂▁▂▂▂▂▂▁▁▂▁▁

Run summary:


acc3.71657
loss0.05718
val_acc3.41874
val_loss0.06552

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run clairvoyant-chipmunk-3 at: https://wandb.ai/noahluna/report-api-quickstart/runs/z5ept0jf
View project at: https://wandb.ai/noahluna/report-api-quickstart
Synced 4 W&B file(s), 0 media file(s), 2 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084142-z5ept0jf/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084150-5128m41p" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run dastardly-duck-4 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/report-api-quickstart" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/report-api-quickstart/runs/5128m41p" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 58.5% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "

Run history:


acc▁▃▄▅▅▅▅▅▆▆▆▆▆▆▇▆▆▆▆▆▇▆▆▇▇▆▇▇▇▇▇█▇█▇████▇
loss█▅▅▅▄▄▄▄▃▃▃▃▃▂▃▃▂▃▂▃▂▂▂▂▂▂▂▁▂▂▁▁▁▂▂▁▂▁▂▂
val_acc▁▂▄▄▄▅▅▅▆▅▅▅▆▆▆▇▆▇▆▆▇▇▇▇▆▆█▇▇█████▇▇▇█▇█
val_loss█▆▇▅▅▅▄▄▄▄▃▄▃▃▃▃▄▃▃▃▂▃▂▂▂▃▂▂▂▁▂▁▁▂▂▂▂▂▂▁

Run summary:


acc3.18347
loss0.06381
val_acc2.67917
val_loss0.06745

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run dastardly-duck-4 at: https://wandb.ai/noahluna/report-api-quickstart/runs/5128m41p
View project at: https://wandb.ai/noahluna/report-api-quickstart
Synced 4 W&B file(s), 0 media file(s), 2 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084150-5128m41p/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084157-lg5pf11v" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run eloquent-elephant-5 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/report-api-quickstart" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/report-api-quickstart/runs/lg5pf11v" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 4.8% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run eloquent-elephant-5 at: https://wandb.ai/noahluna/report-api-quickstart/runs/lg5pf11v
View project at: https://wandb.ai/noahluna/report-api-quickstart
Synced 4 W&B file(s), 2 media file(s), 6 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084157-lg5pf11v/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "JRGBIsMJ-Xz1" - }, - "source": [ - "Good: Assign `b`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "Dm9LFNZ2-Xz1" - }, - "outputs": [], - "source": [ - "b = wr.H1(text=[\"Hello\", \" World!\"])\n", - "report.blocks = [b]\n", - "assert b.text == [\"Hello\", \" World!\"]\n", - "assert report.blocks[0].text == [\"Hello\", \" World!\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "S00MLuhf-Xz1" - }, - "source": [ - "Bad: Mutate `b` without reassigning" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "46T0m0yN-Xz1" - }, - "outputs": [], - "source": [ - "b.text = [\"Something\", \" New\"]\n", - "assert b.text == [\"Something\", \" New\"]\n", - "assert report.blocks[0].text == [\"Hello\", \" World!\"]" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084207-xfnt9t2m" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run hopeful-planet-33 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "thbMAjoQ-Xz1" - }, - "source": [ - "Good: Mutate `b` and then reassign it" + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/xfnt9t2m" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 94.6% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run hopeful-planet-33 at: https://wandb.ai/noahluna/lineage-example/runs/xfnt9t2m
View project at: https://wandb.ai/noahluna/lineage-example
Synced 4 W&B file(s), 0 media file(s), 13 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084207-xfnt9t2m/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "FjczU0vE-Xz1" - }, - "outputs": [], - "source": [ - "report.blocks = [b]\n", - "assert b.text == [\"Something\", \" New\"]\n", - "assert report.blocks[0].text == [\"Something\", \" New\"]" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084221-ny73rk0c" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run brisk-cosmos-34 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/ny73rk0c" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 97.8% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run brisk-cosmos-34 at: https://wandb.ai/noahluna/lineage-example/runs/ny73rk0c
View project at: https://wandb.ai/noahluna/lineage-example
Synced 4 W&B file(s), 0 media file(s), 11 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084221-ny73rk0c/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "Cvn8kaRS-Xz1" - }, - "source": [ - "## How do I show tables?" + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "o8LfrZIX-Xz1" - }, - "outputs": [], - "source": [ - "report = wr.Report(project=PROJECT, title='Adding tables to reports', description=\"Add tables with WeaveBlockSummaryTable or WeavePanelSummaryTable\")" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084237-33c3lxip" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run apricot-wind-35 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/33c3lxip" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 97.8% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "3xkwIdsS-Xz1" - }, - "source": [ - "### Using weave blocks" + "data": { + "text/html": [ + " View run apricot-wind-35 at: https://wandb.ai/noahluna/lineage-example/runs/33c3lxip
View project at: https://wandb.ai/noahluna/lineage-example
Synced 4 W&B file(s), 0 media file(s), 11 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084237-33c3lxip/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "RHs8w3E5-Xz1" - }, - "outputs": [], - "source": [ - "report.blocks += [wr.WeaveBlockSummaryTable(ENTITY, PROJECT, \"my-table\")]\n", - "report.save()" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084250-jws4kl6t" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run solar-disco-36 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "SmV6i0cr-Xz1" - }, - "source": [ - "### Using weave panels (via PanelGrid)" + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/jws4kl6t" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 78.6% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run solar-disco-36 at: https://wandb.ai/noahluna/lineage-example/runs/jws4kl6t
View project at: https://wandb.ai/noahluna/lineage-example
Synced 5 W&B file(s), 0 media file(s), 14 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084250-jws4kl6t/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "q02NlUpZ-Xz1" - }, - "outputs": [], - "source": [ - "report.blocks += [\n", - " wr.PanelGrid(\n", - " panels=[wr.WeavePanelSummaryTable(\"my-table\")]\n", - " )\n", - "]\n", - "report.save()" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084304-ocj3j12m" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run dulcet-plant-37 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/ocj3j12m" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 90.0% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run dulcet-plant-37 at: https://wandb.ai/noahluna/lineage-example/runs/ocj3j12m
View project at: https://wandb.ai/noahluna/lineage-example
Synced 5 W&B file(s), 0 media file(s), 11 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084304-ocj3j12m/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "O5N-SdiX-Xz1" - }, - "source": [ - "## How do I show artifact lineage / versions?" + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "jXRQH1Fw-Xz1" - }, - "outputs": [], - "source": [ - "report = wr.Report(project=PROJECT, title='Adding artifact lineage to reports', description=\"via WeaveBlockArtifact, WeaveBlockArtifactVersionedFile, or their panel equivalents\")" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084317-crqgfjhh" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run spring-moon-38 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/crqgfjhh" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 90.0% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run spring-moon-38 at: https://wandb.ai/noahluna/lineage-example/runs/crqgfjhh
View project at: https://wandb.ai/noahluna/lineage-example
Synced 5 W&B file(s), 0 media file(s), 11 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084317-crqgfjhh/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "markdown", - "metadata": { - "id": "nwNe05_n-Xz1" - }, - "source": [ - "### Using weave blocks" + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "TDzAfPYT-Xz1" - }, - "outputs": [], - "source": [ - "report.blocks += [\n", - " wr.WeaveBlockArtifact(ENTITY, LINEAGE_PROJECT, \"model-1\", \"lineage\"),\n", - " wr.WeaveBlockArtifactVersionedFile(ENTITY, LINEAGE_PROJECT, \"model-1\", \"v0\", \"dataframe.table.json\")\n", - "]\n", - "report.save()" + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Rekw2GE4-Xz1" - }, - "source": [ - "### Using weave panels (via PanelGrid)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "VYI_lj4C-Xz2" - }, - "outputs": [], - "source": [ - "report.blocks += [\n", - " wr.PanelGrid(panels=[\n", - " wr.WeavePanelArtifact(\"\", \"lineage\"),\n", - " wr.WeavePanelArtifactVersionedFile(\"\", \"v0\", \"dataframe.table.json\")\n", - " ])\n", - "]\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "p2Lp73iV-Xz2" - }, - "source": [ - "## How can I create report templates?\n", - "- See some of the examples in `wr.templates`\n", - "- The most straightforward way is to create a function that returns your target report and/or its blocks." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "E0XHOx6x-Xz2" - }, - "source": [ - "### A basic template\n", - "- Just use a function" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "nwq8tuwj-Xz2" - }, - "outputs": [], - "source": [ - "def my_report_template(title, description, project, metric):\n", - " return wr.Report(\n", - " title=title,\n", - " description=description,\n", - " project=project,\n", - " blocks=[\n", - " wr.H1(f\"Look at our amazing metric called `{metric}`\"),\n", - " wr.PanelGrid(\n", - " panels=[wr.LinePlot(x='Step', y=metric, layout={'w': 24, 'h': 8})],\n", - " )\n", - " ]\n", - " ).save()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "B5JIHZiH-Xz2" - }, - "outputs": [], - "source": [ - "my_report_template('My templated report', \"Here's an example of how you can make a function for templates\", PROJECT, 'val_acc')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6jLApDB2-Xz2" - }, - "source": [ - "### More advanced templates" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "Xcvyybyz-Xz2" - }, - "outputs": [], - "source": [ - "def create_header():\n", - " return [\n", - " wr.P(),\n", - " wr.HorizontalRule(),\n", - " wr.P(),\n", - " wr.Image(\n", - " \"https://camo.githubusercontent.com/83839f20c90facc062330f8fee5a7ab910fdd04b80b4c4c7e89d6d8137543540/68747470733a2f2f692e696d6775722e636f6d2f676236423469672e706e67\"\n", - " ),\n", - " wr.P(),\n", - " wr.HorizontalRule(),\n", - " wr.P(),\n", - " ]\n", - "\n", - "def create_footer():\n", - " return [\n", - " wr.P(),\n", - " wr.HorizontalRule(),\n", - " wr.P(),\n", - " wr.H1(\"Disclaimer\"),\n", - " wr.P(\n", - " \"The views and opinions expressed in this report are those of the authors and do not necessarily reflect the official policy or position of Weights & Biases. blah blah blah blah blah boring text at the bottom\"\n", - " ),\n", - " wr.P(),\n", - " wr.HorizontalRule(),\n", - " ]\n", - "\n", - "def create_main_content(metric):\n", - " return [\n", - " wr.H1(f\"Look at our amazing metric called `{metric}`\"),\n", - " wr.PanelGrid(\n", - " panels=[wr.LinePlot(x='Step', y=metric, layout={'w': 24, 'h': 8})],\n", - " )\n", - " ]\n", - "\n", - "def create_templated_report_with_header_and_footer(title, project, metric):\n", - " return wr.Report(\n", - " title=title,\n", - " project=project,\n", - " blocks=[\n", - " *create_header(),\n", - " *create_main_content(metric),\n", - " *create_footer(),\n", - " ]).save()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "MAtT_EK9-Xz2" - }, - "outputs": [], - "source": [ - "create_templated_report_with_header_and_footer(title=\"Another templated report\", project=PROJECT, metric='val_acc')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "whUG_u7Q-Xz2" - }, - "source": [ - "# 📌 Complete Examples " - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "yZ43Fl6k-Xz2" - }, - "source": [ - "## Reinforcement Learning (RL)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "v8iCxVhE-Xz2" - }, - "outputs": [], - "source": [ - "wr.Report(\n", - " project=PROJECT,\n", - " title='Reinforcement Learning Report',\n", - " description='Aut totam dolores aut galisum atque aut placeat quia. Vel quisquam omnis ut quibusdam doloremque a delectus quia in omnis deserunt. Quo ipsum beatae aut veniam earum non ipsa reiciendis et fugiat asperiores est veritatis magni et corrupti internos. Ut quis libero ut alias reiciendis et animi delectus.',\n", - " blocks=[\n", - " wr.TableOfContents(),\n", - " wr.H1(\"Ea quidem illo est dolorem illo.\"),\n", - " wr.P(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac eros ut nunc venenatis tincidunt vel ut dolor. Sed sed felis dictum, congue risus vel, aliquet dolor. Donec ut risus vel leo dictum tristique. Nunc sed urna mi. Morbi nulla turpis, vehicula eu maximus ut, gravida id libero. Duis porta risus leo, quis lobortis enim ultrices a. Donec quam augue, vestibulum vitae mollis at, tincidunt non orci. Morbi faucibus dignissim tempor. Vestibulum ornare augue a orci tincidunt porta. Pellentesque et ante et purus gravida euismod. Maecenas sit amet sollicitudin felis, sed egestas nunc.\"),\n", - " wr.H2('Et sunt sunt eum asperiores ratione.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='bigfish', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'bigfish', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'bigfish', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " wr.H2('Sit officia inventore non omnis deleniti.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='starpilot', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'starpilot', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'starpilot', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " wr.H2('Aut amet nesciunt vel quisquam repellendus sed labore voluptas.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='bossfight', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'bossfight', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'bossfight', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " wr.HorizontalRule(),\n", - " wr.H1(\"Sed consectetur vero et voluptas voluptatem et adipisci blanditiis.\"),\n", - " wr.P(\"Sit aliquid repellendus et numquam provident quo quaerat earum 33 sunt illo et quos voluptate est officia deleniti. Vel architecto nulla ex nulla voluptatibus qui saepe officiis quo illo excepturi ea dolorum reprehenderit.\"),\n", - " wr.H2(\"Qui debitis iure 33 voluptatum eligendi.\"),\n", - " wr.P(\"Non veniam laudantium et fugit distinctio qui aliquid eius sed laudantium consequatur et quia perspiciatis. Et odio inventore est voluptas fugiat id perspiciatis dolorum et perferendis recusandae vel Quis odio 33 beatae veritatis. Ex sunt accusamus aut soluta eligendi sed perspiciatis maxime 33 dolorem dolorum est aperiam minima. Et earum rerum eos illo sint eos temporibus similique ea fuga iste sed quia soluta sit doloribus corporis sed tenetur excepturi?\"),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/SPS']),\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_length']),\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return']),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"DQN\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'dqn_atari'\"),\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"SAC-discrete 0.8\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'sac_atari' and target_entropy_scale == 0.8\"),\n", - " wr.Runset(\"openrlbenchmark\", \"cleanrl\", \"SAC-discrete 0.88\", groupby=[\"exp_name\"]).set_filters_with_python_expr(\"env_id == 'BreakoutNoFrameskip-v4' and exp_name == 'sac_atari' and target_entropy_scale == 0.88\"),\n", - " ],\n", - " custom_run_colors={\n", - " ('DQN', 'dqn_atari'): '#e84118',\n", - " ('SAC-discrete 0.8', 'sac_atari'): '#fbc531',\n", - " ('SAC-discrete 0.88', 'sac_atari'): '#00a8ff',\n", - " }\n", - " ),\n", - " ]\n", - ").save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "RLbmI_Hg-Xz2" - }, - "source": [ - "## Customer Landing Page" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "U66DEVfj-Xz2" - }, - "outputs": [], - "source": [ - "report = wr.templates.create_customer_landing_page(\n", - " project=PROJECT,\n", - " company_name='Company',\n", - " main_contact='Contact McContact (email@company.com)',\n", - " slack_link='https://company.slack.com/blah',\n", - ")\n", - "report.save()" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_DutSB2C-Xz2" - }, - "source": [ - "## Enterprise Report with Branded Header and Footer" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "dDsMOfEp-Xz2" - }, - "outputs": [], - "source": [ - "report = wr.templates.create_enterprise_report(\n", - " project=PROJECT,\n", - " body=[\n", - " wr.H1(\"Ea quidem illo est dolorem illo.\"),\n", - " wr.P(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac eros ut nunc venenatis tincidunt vel ut dolor. Sed sed felis dictum, congue risus vel, aliquet dolor. Donec ut risus vel leo dictum tristique. Nunc sed urna mi. Morbi nulla turpis, vehicula eu maximus ut, gravida id libero. Duis porta risus leo, quis lobortis enim ultrices a. Donec quam augue, vestibulum vitae mollis at, tincidunt non orci. Morbi faucibus dignissim tempor. Vestibulum ornare augue a orci tincidunt porta. Pellentesque et ante et purus gravida euismod. Maecenas sit amet sollicitudin felis, sed egestas nunc.\"),\n", - " wr.H2('Et sunt sunt eum asperiores ratione.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='bigfish', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'bigfish', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'bigfish', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " wr.H2('Sit officia inventore non omnis deleniti.'),\n", - " wr.PanelGrid(\n", - " panels=[\n", - " wr.LinePlot(x='global_step', y=['charts/episodic_return'], smoothing_factor=0.85, groupby_aggfunc='mean', groupby_rangefunc='minmax', layout={'x': 0, 'y': 0, 'w': 12, 'h': 8}),\n", - " wr.MediaBrowser(media_keys=\"videos\", num_columns=4, layout={'w': 12, 'h': 8}),\n", - " ],\n", - " runsets=[\n", - " wr.Runset(entity='openrlbenchmark', project='cleanrl', query='starpilot', groupby=['env_id', 'exp_name'])\n", - " ],\n", - " custom_run_colors={\n", - " ('Run set', 'starpilot', 'ppg_procgen'): \"#2980b9\",\n", - " ('Run set', 'starpilot', 'ppo_procgen'): \"#e74c3c\",\n", - " }\n", - " ),\n", - " ]\n", - ")\n", - "report.save()" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084333-2pwaqwvo" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run magic-water-39 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/2pwaqwvo" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 90.0% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run magic-water-39 at: https://wandb.ai/noahluna/lineage-example/runs/2pwaqwvo
View project at: https://wandb.ai/noahluna/lineage-example
Synced 5 W&B file(s), 0 media file(s), 11 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084333-2pwaqwvo/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "wandb version 0.17.7 is available! To upgrade, please run:\n", + " $ pip install wandb --upgrade" + ], + "text/plain": [ + "" ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Tracking run with wandb version 0.17.4" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Run data is saved locally in /Users/noahluna/Documents/GitHub/examples/wandb/run-20240821_084346-z4gsqxc0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Syncing run proud-sea-40 to Weights & Biases (docs)
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View project at https://wandb.ai/noahluna/lineage-example" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run at https://wandb.ai/noahluna/lineage-example/runs/z4gsqxc0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "W&B sync reduced upload amount by 76.9% " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " View run proud-sea-40 at: https://wandb.ai/noahluna/lineage-example/runs/z4gsqxc0
View project at: https://wandb.ai/noahluna/lineage-example
Synced 5 W&B file(s), 0 media file(s), 5 artifact file(s) and 1 other file(s)" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "Find logs at: ./wandb/run-20240821_084346-z4gsqxc0/logs" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "The new W&B backend becomes opt-out in version 0.18.0; try it out with `wandb.require(\"core\")`! See https://wandb.me/wandb-core for more information." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } - ], - "metadata": { - "accelerator": "GPU", - "colab": { - "provenance": [], - "toc_visible": true, - "include_colab_link": true - }, - "kernelspec": { - "display_name": "Python 3", - "name": "python3" + ], + "source": [ + "#@title ## Log Runs { run: \"auto\", display-mode: \"form\" }\n", + "#@markdown If this is your first time here, consider running the setup code for a better docs experience!\n", + "#@markdown If you have run the setup code before, you can uncheck the box below to avoid unnecessary logging.\n", + "\n", + "LOG_DUMMY_RUNS = True #@param {type: \"boolean\"}\n", + "\n", + "\n", + "import requests\n", + "from PIL import Image\n", + "from io import BytesIO\n", + "import wandb\n", + "import pandas as pd\n", + "from itertools import product\n", + "import random\n", + "import math\n", + "\n", + "import wandb\n", + "import random\n", + "import string\n", + "\n", + "ENTITY = wandb.apis.PublicApi().default_entity\n", + "PROJECT = \"report-api-quickstart\" #@param {type: \"string\"}\n", + "LINEAGE_PROJECT = \"lineage-example\" #@param {type: \"string\"}\n", + "\n", + "\n", + "def get_image(url):\n", + " r = requests.get(url)\n", + " return Image.open(BytesIO(r.content))\n", + "\n", + "\n", + "def log_dummy_data():\n", + " run_names = [\n", + " \"adventurous-aardvark-1\",\n", + " \"bountiful-badger-2\",\n", + " \"clairvoyant-chipmunk-3\",\n", + " \"dastardly-duck-4\",\n", + " \"eloquent-elephant-5\",\n", + " \"flippant-flamingo-6\",\n", + " \"giddy-giraffe-7\",\n", + " \"haughty-hippo-8\",\n", + " \"ignorant-iguana-9\",\n", + " \"jolly-jackal-10\",\n", + " \"kind-koala-11\",\n", + " \"laughing-lemur-12\",\n", + " \"manic-mandrill-13\",\n", + " \"neighbourly-narwhal-14\",\n", + " \"oblivious-octopus-15\",\n", + " \"philistine-platypus-16\",\n", + " \"quant-quail-17\",\n", + " \"rowdy-rhino-18\",\n", + " \"solid-snake-19\",\n", + " \"timid-tarantula-20\",\n", + " \"understanding-unicorn-21\",\n", + " \"voracious-vulture-22\",\n", + " \"wu-tang-23\",\n", + " \"xenic-xerneas-24\",\n", + " \"yielding-yveltal-25\",\n", + " \"zooming-zygarde-26\",\n", + " ]\n", + "\n", + " opts = [\"adam\", \"sgd\"]\n", + " encoders = [\"resnet18\", \"resnet50\"]\n", + " learning_rates = [0.01]\n", + " for (i, run_name), (opt, encoder, lr) in zip(\n", + " enumerate(run_names), product(opts, encoders, learning_rates)\n", + " ):\n", + " config = {\n", + " \"optimizer\": opt,\n", + " \"encoder\": encoder,\n", + " \"learning_rate\": lr,\n", + " \"momentum\": 0.1 * random.random(),\n", + " }\n", + " displacement1 = random.random() * 2\n", + " displacement2 = random.random() * 4\n", + " with wandb.init(\n", + " entity=ENTITY, project=PROJECT, config=config, name=run_name\n", + " ) as run:\n", + " for step in range(1000):\n", + " wandb.log(\n", + " {\n", + " \"acc\": 0.1\n", + " + 0.4\n", + " * (\n", + " math.log(1 + step + random.random())\n", + " + random.random() * run.config.learning_rate\n", + " + random.random()\n", + " + displacement1\n", + " + random.random() * run.config.momentum\n", + " ),\n", + " \"val_acc\": 0.1\n", + " + 0.4\n", + " * (\n", + " math.log(1 + step + random.random())\n", + " + random.random() * run.config.learning_rate\n", + " - random.random()\n", + " + displacement1\n", + " ),\n", + " \"loss\": 0.1\n", + " + 0.08\n", + " * (\n", + " 3.5\n", + " - math.log(1 + step + random.random())\n", + " + random.random() * run.config.momentum\n", + " + random.random()\n", + " + displacement2\n", + " ),\n", + " \"val_loss\": 0.1\n", + " + 0.04\n", + " * (\n", + " 4.5\n", + " - math.log(1 + step + random.random())\n", + " + random.random() * run.config.learning_rate\n", + " - random.random()\n", + " + displacement2\n", + " ),\n", + " }\n", + " )\n", + "\n", + " with wandb.init(\n", + " entity=ENTITY, project=PROJECT, config=config, name=run_names[i + 1]\n", + " ) as run:\n", + " img = get_image(\n", + " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", + " )\n", + " image = wandb.Image(img)\n", + " df = pd.DataFrame(\n", + " {\n", + " \"int\": [1, 2, 3, 4],\n", + " \"float\": [1.2, 2.3, 3.4, 4.5],\n", + " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", + " \"img\": [image] * 4,\n", + " }\n", + " )\n", + " run.log({\"img\": image, \"my-table\": df})\n", + "\n", + "\n", + "class Step:\n", + " def __init__(self, j, r, u, o, at=None):\n", + " self.job_type = j\n", + " self.runs = r\n", + " self.uses_per_run = u\n", + " self.outputs_per_run = o\n", + " self.artifact_type = at if at is not None else \"model\"\n", + " self.artifacts = []\n", + "\n", + "\n", + "def create_artifact(name: str, type: str, content: str):\n", + " art = wandb.Artifact(name, type)\n", + " with open(\"boom.txt\", \"w\") as f:\n", + " f.write(content)\n", + " art.add_file(\"boom.txt\", \"test-name\")\n", + "\n", + " img = get_image(\n", + " \"https://www.akc.org/wp-content/uploads/2017/11/Shiba-Inu-standing-in-profile-outdoors.jpg\"\n", + " )\n", + " image = wandb.Image(img)\n", + " df = pd.DataFrame(\n", + " {\n", + " \"int\": [1, 2, 3, 4],\n", + " \"float\": [1.2, 2.3, 3.4, 4.5],\n", + " \"str\": [\"a\", \"b\", \"c\", \"d\"],\n", + " \"img\": [image] * 4,\n", + " }\n", + " )\n", + " art.add(wandb.Table(dataframe=df), \"dataframe\")\n", + " return art\n", + "\n", + "\n", + "def log_dummy_lineage():\n", + " pipeline = [\n", + " Step(\"dataset-generator\", 1, 0, 3, \"dataset\"),\n", + " Step(\"trainer\", 4, (1, 2), 3),\n", + " Step(\"evaluator\", 2, 1, 3),\n", + " Step(\"ensemble\", 1, 1, 1),\n", + " ]\n", + " for (i, step) in enumerate(pipeline):\n", + " for _ in range(step.runs):\n", + " with wandb.init(project=LINEAGE_PROJECT, job_type=step.job_type) as run:\n", + " # use\n", + " uses = step.uses_per_run\n", + " if type(uses) == tuple:\n", + " uses = random.choice(list(uses))\n", + "\n", + " if i > 0:\n", + " prev_step = pipeline[i - 1]\n", + " input_artifacts = random.sample(prev_step.artifacts, uses)\n", + " for a in input_artifacts:\n", + " run.use_artifact(a)\n", + " # log output artifacts\n", + " for j in range(step.outputs_per_run):\n", + " # name = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))\n", + " name = f\"{step.artifact_type}-{j}\"\n", + " content = \"\".join(\n", + " random.choices(string.ascii_lowercase + string.digits, k=12)\n", + " )\n", + " art = create_artifact(name, step.artifact_type, content)\n", + " run.log_artifact(art)\n", + " art.wait()\n", + "\n", + " # save in pipeline\n", + " step.artifacts.append(art)\n", + "\n", + "if LOG_DUMMY_RUNS:\n", + " log_dummy_data()\n", + " log_dummy_lineage()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4tqli7A_7NDP" + }, + "source": [ + "\n", + "# 🚀 Quickstart! " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "EmDzg3wS7NDP" + }, + "outputs": [], + "source": [ + "import wandb_workspaces.reports.v2 as wr" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "eheAid__7NDP" + }, + "source": [ + "## Create, save, and load reports\n", + "- NOTE: Reports are not saved automatically to reduce clutter. Explicitly save the report by calling `report.save()`" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "RVlOoOaK7NDP" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTY5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='readable', description='That was easy!', id='Vmlldzo5MTA1NTY5')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report = wr.Report(\n", + " project=PROJECT,\n", + " title='Quickstart Report',\n", + " description=\"That was easy!\"\n", + ") # Create\n", + "report.save() # Save\n", + "wr.Report.from_url(report.url) # Load" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "d3M7hocj7NDP" + }, + "source": [ + "## Add content via blocks\n", + "- Use blocks to add content like text, images, code, and more\n", + "- See `wr.blocks` for all available blocks" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "ZaSE1j897NDP" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTY5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='readable', description='That was easy!', blocks=[TableOfContents(), H1(text='Text and images example'), P(text='Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.'), Image(url='https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'), P(text='Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?')], id='Vmlldzo5MTA1NTY5')" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report.blocks = [\n", + " wr.TableOfContents(),\n", + " wr.H1(\"Text and images example\"),\n", + " wr.P(\"Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.\"),\n", + " wr.Image('https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'),\n", + " wr.P(\"Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?\"),\n", + "]\n", + "report.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bMNTXROu7NDQ" + }, + "source": [ + "## Add charts and more via Panel Grid\n", + "- `PanelGrid` is a special type of block that holds `runsets` and `panels`\n", + " - `runsets` organize data logged to W&B\n", + " - `panels` visualize runset data. For a full set of panels, see `wr.panels`" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "2lpA3H4R7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTY5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='readable', description='That was easy!', blocks=[TableOfContents(), H1(text='Panel Grid Example'), PanelGrid(runsets=[Runset(entity='noahluna', project='report-api-quickstart', name='First Run Set', order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='noahluna', project='report-api-quickstart', name='Elephants Only!', query='elephant', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8, layout=Layout(x=0, y=0, w=8, h=6)), BarPlot(metrics=['acc'], orientation='h', layout=Layout(x=8, y=0, w=8, h=6)), MediaBrowser(num_columns=1, media_keys=['img'], layout=Layout(x=16, y=0, w=8, h=6)), RunComparer(diff_only='split', layout=Layout(x=0, y=6, w=24, h=9))], active_runset=0), H1(text='Text and images example'), P(text='Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.'), Image(url='https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'), P(text='Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?')], id='Vmlldzo5MTA1NTY5')" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pg = wr.PanelGrid(\n", + " runsets=[\n", + " wr.Runset(ENTITY, PROJECT, \"First Run Set\"),\n", + " wr.Runset(ENTITY, PROJECT, \"Elephants Only!\", query=\"elephant\"),\n", + " ],\n", + " panels=[\n", + " wr.LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8),\n", + " wr.BarPlot(metrics=['acc']),\n", + " wr.MediaBrowser(media_keys=['img'], num_columns=1),\n", + " wr.RunComparer(diff_only='split', layout={'w': 24, 'h': 9}),\n", + " ]\n", + ")\n", + "\n", + "report.blocks = report.blocks[:1] + [wr.H1(\"Panel Grid Example\"), pg] + report.blocks[1:]\n", + "report.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "fbtBNA5k7NDQ" + }, + "source": [ + "## Add data lineage with Artifact blocks\n", + "- There are equivalent weave panels as well" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "rI-kgZpU7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTY5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='readable', description='That was easy!', blocks=[TableOfContents(), H1(text='Artifact lineage example'), WeaveBlockArtifact(entity='noahluna', project='lineage-example', artifact='model-1', tab='lineage'), H1(text='Panel Grid Example'), PanelGrid(runsets=[Runset(entity='noahluna', project='report-api-quickstart', name='First Run Set', order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='noahluna', project='report-api-quickstart', name='Elephants Only!', query='elephant', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8, layout=Layout(x=0, y=0, w=8, h=6)), BarPlot(metrics=['acc'], orientation='h', layout=Layout(x=8, y=0, w=8, h=6)), MediaBrowser(num_columns=1, media_keys=['img'], layout=Layout(x=16, y=0, w=8, h=6)), RunComparer(diff_only='split', layout=Layout(x=0, y=6, w=24, h=9))], active_runset=0), H1(text='Text and images example'), P(text='Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.'), Image(url='https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'), P(text='Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?')], id='Vmlldzo5MTA1NTY5')" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "artifact_lineage = wr.WeaveBlockArtifact(entity=ENTITY, project=LINEAGE_PROJECT, artifact='model-1', tab='lineage')\n", + "\n", + "report.blocks = report.blocks[:1] + [wr.H1(\"Artifact lineage example\"), artifact_lineage] + report.blocks[1:]\n", + "report.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "b2mMLGUK7NDQ" + }, + "source": [ + "## Customize run colors\n", + "- Pass in a `dict[run_name, color]`" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "kE72SArq7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTY5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='readable', description='That was easy!', blocks=[TableOfContents(), H1(text='Artifact lineage example'), WeaveBlockArtifact(entity='noahluna', project='lineage-example', artifact='model-1', tab='lineage'), H1(text='Panel Grid Example'), PanelGrid(runsets=[Runset(entity='noahluna', project='report-api-quickstart', name='First Run Set', order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='noahluna', project='report-api-quickstart', name='Elephants Only!', query='elephant', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8, layout=Layout(x=0, y=0, w=8, h=6)), BarPlot(metrics=['acc'], orientation='h', layout=Layout(x=8, y=0, w=8, h=6)), MediaBrowser(num_columns=1, media_keys=['img'], layout=Layout(x=16, y=0, w=8, h=6)), RunComparer(diff_only='split', layout=Layout(x=0, y=6, w=24, h=9))], active_runset=0, custom_run_colors={'adventurous-aardvark-1': '#e84118', 'bountiful-badger-2': '#fbc531', 'clairvoyant-chipmunk-3': '#4cd137', 'dastardly-duck-4': '#00a8ff', 'eloquent-elephant-5': '#9c88ff'}), H1(text='Text and images example'), P(text='Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.'), Image(url='https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'), P(text='Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?')], id='Vmlldzo5MTA1NTY5')" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pg.custom_run_colors = {\n", + " 'adventurous-aardvark-1': '#e84118',\n", + " 'bountiful-badger-2': '#fbc531',\n", + " 'clairvoyant-chipmunk-3': '#4cd137',\n", + " 'dastardly-duck-4': '#00a8ff',\n", + " 'eloquent-elephant-5': '#9c88ff',\n", + "}\n", + "report.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pqu2LPgz7NDQ" + }, + "source": [ + "# ❓ FAQ " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "c--gAdKg7NDQ" + }, + "source": [ + "## My report is too wide/narrow\n", + "- Change the report's width to the right size for you." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "RQrUg8E17NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTcw\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Quickstart-Report--Vmlldzo5MTA1NTcw\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Quickstart Report', width='fluid', description='That was easy!', blocks=[TableOfContents(), H1(text='Artifact lineage example'), WeaveBlockArtifact(entity='noahluna', project='lineage-example', artifact='model-1', tab='lineage'), H1(text='Panel Grid Example'), PanelGrid(runsets=[Runset(entity='noahluna', project='report-api-quickstart', name='First Run Set', order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='noahluna', project='report-api-quickstart', name='Elephants Only!', query='elephant', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(x='Step', y=['val_acc'], smoothing_factor=0.8, layout=Layout(x=0, y=0, w=8, h=6)), BarPlot(metrics=['acc'], orientation='h', layout=Layout(x=8, y=0, w=8, h=6)), MediaBrowser(num_columns=1, media_keys=['img'], layout=Layout(x=16, y=0, w=8, h=6)), RunComparer(diff_only='split', layout=Layout(x=0, y=6, w=24, h=9))], active_runset=0, custom_run_colors={'adventurous-aardvark-1': '#e84118', 'bountiful-badger-2': '#fbc531', 'clairvoyant-chipmunk-3': '#4cd137', 'dastardly-duck-4': '#00a8ff', 'eloquent-elephant-5': '#9c88ff'}), H1(text='Text and images example'), P(text='Lorem ipsum dolor sit amet. Aut laborum perspiciatis sit odit omnis aut aliquam voluptatibus ut rerum molestiae sed assumenda nulla ut minus illo sit sunt explicabo? Sed quia architecto est voluptatem magni sit molestiae dolores. Non animi repellendus ea enim internos et iste itaque quo labore mollitia aut omnis totam.'), Image(url='https://api.wandb.ai/files/telidavies/images/projects/831572/8ad61fd1.png', caption='Craiyon generated images'), P(text='Et voluptatem galisum quo facilis sequi quo suscipit sunt sed iste iure! Est voluptas adipisci et doloribus commodi ab tempore numquam qui tempora adipisci. Eum sapiente cupiditate ut natus aliquid sit dolor consequatur?')], id='Vmlldzo5MTA1NTcw')" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report2 = report.save(clone=True)\n", + "report2.width = 'fluid'\n", + "report2.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZBRQ0-Np7NDQ" + }, + "source": [ + "## How do I resize panels?\n", + "- Pass a `dict[dim, int]` to `panel.layout`\n", + "- `dim` is a dimension, which can be `x`, `y` (the coordiantes of the top left corner) `w`, `h` (the size of the panel)\n", + "- You can pass any or all dimensions at once\n", + "- The space between two dots in a panel grid is 2." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "83rhYSSD7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Resizing-panels--Vmlldzo5MTA1NTcy\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Resizing panels', width='readable', description='Look at this wide parallel coordinates plot!', blocks=[PanelGrid(runsets=[Runset(name='Run set', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[ParallelCoordinatesPlot(columns=[ParallelCoordinatesPlotColumn(metric='Step'), ParallelCoordinatesPlotColumn(metric='c::model'), ParallelCoordinatesPlotColumn(metric='c::optimizer'), ParallelCoordinatesPlotColumn(metric='Step'), ParallelCoordinatesPlotColumn(metric='val_acc'), ParallelCoordinatesPlotColumn(metric='val_loss')], layout=Layout(x=0, y=0, w=24, h=9))], active_runset=0)], id='Vmlldzo5MTA1NTcy')" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" } + ], + "source": [ + "import wandb_workspaces.reports.v2 as wr\n", + "\n", + "\n", + "report = wr.Report(\n", + " project=PROJECT,\n", + " title=\"Resizing panels\",\n", + " description=\"Look at this wide parallel coordinates plot!\",\n", + " blocks=[\n", + " wr.PanelGrid(\n", + " panels=[\n", + " wr.ParallelCoordinatesPlot(\n", + " columns=[\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"Step\"),\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"c::model\"),\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"c::optimizer\"),\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"Step\"),\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"val_acc\"),\n", + " wr.ParallelCoordinatesPlotColumn(metric=\"val_loss\"),\n", + " ],\n", + " layout=wr.Layout(w=24, h=9) # Adjusting the layout for the plot size\n", + " ),\n", + " ]\n", + " )\n", + " ]\n", + ")\n", + "\n", + "\n", + "report.save()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qQTtzZ9r7NDQ" + }, + "source": [ + "## What blocks are available?\n", + "- See `wr.blocks` for a list of blocks.\n", + "- In an IDE or notebook, you can also do `wr.blocks.` to get autocomplete." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "valQfFTQ7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/W&B-Block-Gallery--Vmlldzo5MTA1NTcz\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='W&B Block Gallery', width='readable', description='Check out all of the blocks available in W&B', blocks=[H1(text='Heading 1'), P(text='Normal paragraph'), H2(text='Heading 2'), P(text=['here is some text, followed by', InlineCode(text='select * from code in line'), 'and then latex', InlineLatex(text='e=mc^2')]), H3(text='Heading 3'), CodeBlock(code='this:\\n- is\\n- a\\ncool:\\n- yaml\\n- file', language='yaml'), WeaveBlockSummaryTable(entity='noahluna', project='report-api-quickstart', table_name='my-table'), WeaveBlockArtifact(entity='noahluna', project='lineage-example', artifact='model-1', tab='lineage'), WeaveBlockArtifactVersionedFile(entity='noahluna', project='lineage-example', artifact='model-1', version='v0', file='dataframe.table.json'), MarkdownBlock(text='Markdown cell with *italics* and **bold** and $e=mc^2$'), LatexBlock(text='\\\\gamma^2+\\\\theta^2=\\\\omega^2\\n\\\\\\\\ a^2 + b^2 = c^2'), Image(url='https://api.wandb.ai/files/megatruong/images/projects/918598/350382db.gif', caption=\"It's a me, Pikachu\"), UnorderedList(items=['Bullet 1', 'Bullet 2']), OrderedList(items=['Ordered 1', 'Ordered 2']), CheckedList(items=[CheckedListItem(text='Unchecked', checked=False), CheckedListItem(text='Checked', checked=True)]), BlockQuote(text='Block Quote 1\\nBlock Quote 2\\nBlock Quote 3'), CalloutBlock(text='Callout 1\\nCallout 2\\nCallout 3'), HorizontalRule(), Video(url='https://www.youtube.com/embed/6riDJMI-Y8U')], id='Vmlldzo5MTA1NTcz')" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report = wr.Report(\n", + " project=PROJECT,\n", + " title='W&B Block Gallery',\n", + " description=\"Check out all of the blocks available in W&B\",\n", + " blocks=[\n", + " wr.H1(text=\"Heading 1\"),\n", + " wr.P(text=\"Normal paragraph\"),\n", + " wr.H2(text=\"Heading 2\"),\n", + " wr.P(\n", + " text=[\n", + " \"here is some text, followed by\",\n", + " wr.InlineCode(text=\"select * from code in line\"),\n", + " \"and then latex\",\n", + " wr.InlineLatex(text=\"e=mc^2\"),\n", + " ]\n", + " ),\n", + " wr.H3(text=\"Heading 3\"),\n", + " wr.CodeBlock(\n", + " code=\"this:\\n- is\\n- a\\ncool:\\n- yaml\\n- file\",\n", + " language=\"yaml\",\n", + " ),\n", + " wr.WeaveBlockSummaryTable(\n", + " entity=ENTITY,\n", + " project=PROJECT,\n", + " table_name='my-table'\n", + " ),\n", + " wr.WeaveBlockArtifact(\n", + " entity=ENTITY,\n", + " project=LINEAGE_PROJECT,\n", + " artifact='model-1',\n", + " tab='lineage'\n", + " ),\n", + " wr.WeaveBlockArtifactVersionedFile(\n", + " entity=ENTITY,\n", + " project=LINEAGE_PROJECT,\n", + " artifact='model-1',\n", + " version='v0',\n", + " file=\"dataframe.table.json\"\n", + " ),\n", + " wr.MarkdownBlock(text=\"Markdown cell with *italics* and **bold** and $e=mc^2$\"),\n", + " wr.LatexBlock(text=\"\\\\gamma^2+\\\\theta^2=\\\\omega^2\\n\\\\\\\\ a^2 + b^2 = c^2\"),\n", + " wr.Image(url=\"https://api.wandb.ai/files/megatruong/images/projects/918598/350382db.gif\", caption=\"It's a me, Pikachu\"),\n", + " wr.UnorderedList(items=[\"Bullet 1\", \"Bullet 2\"]),\n", + " wr.OrderedList(items=[\"Ordered 1\", \"Ordered 2\"]),\n", + " wr.CheckedList(items=[\n", + " wr.CheckedListItem(text=\"Unchecked\", checked=False),\n", + " wr.CheckedListItem(text=\"Checked\", checked=True)\n", + " ]),\n", + " wr.BlockQuote(text=\"Block Quote 1\\nBlock Quote 2\\nBlock Quote 3\"),\n", + " wr.CalloutBlock(text=\"Callout 1\\nCallout 2\\nCallout 3\"),\n", + " wr.HorizontalRule(),\n", + " wr.Video(url=\"https://www.youtube.com/embed/6riDJMI-Y8U\"),\n", + " ]\n", + ")\n", + "\n", + "report.save()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-koIg4Dp7NDQ" + }, + "source": [ + "## What panels are available?\n", + "- See `wr.panels` for a list of panels\n", + "- In an IDE or notebook, you can also do `wr.panels.` to get autocomplete.\n", + "- Panels have a lot of settings. Inspect the panel to see what you can do!" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "id": "E95cCJQK7NDQ" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/W&B-Panel-Gallery--Vmlldzo5MTA1NTc0\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='W&B Panel Gallery', width='fluid', description='Check out all of the panels available in W&B', blocks=[PanelGrid(runsets=[Runset(project='lineage-example', name='Run set', order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(name='Run set', order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[MediaBrowser(media_keys=['img'], layout=Layout(x=0, y=0, w=8, h=6)), MarkdownPanel(markdown='Hello *italic* **bold** $e=mc^2$ `something`', layout=Layout(x=8, y=0, w=8, h=6)), LinePlot(title='Validation Accuracy over Time', x='Step', y=['val_acc'], range_x=(0.0, 1000.0), range_y=(1.0, 4.0), log_x=True, log_y=False, title_x='Training steps', title_y='Validation Accuracy', ignore_outliers=True, groupby='encoder', groupby_aggfunc='mean', groupby_rangefunc='minmax', smoothing_factor=0.5, smoothing_type='gaussian', smoothing_show_original=True, max_runs_to_show=10, font_size='large', legend_position='west', layout=Layout(x=16, y=0, w=8, h=6)), ScatterPlot(title='Validation Accuracy vs. Validation Loss', x='val_acc', y='val_loss', log_x=False, log_y=False, running_ymin=True, running_ymax=True, running_ymean=True, font_size='small', regression=True, layout=Layout(x=0, y=6, w=8, h=6)), BarPlot(title='Validation Loss by Encoder', metrics=['val_loss'], orientation='h', range_x=(0.0, 0.11), title_x='Validation Loss', groupby='encoder', groupby_aggfunc='median', groupby_rangefunc='stddev', max_runs_to_show=20, max_bars_to_show=3, font_size='auto', layout=Layout(x=8, y=6, w=8, h=6)), ScalarChart(title='Maximum Number of Steps', metric='Step', groupby_aggfunc='max', groupby_rangefunc='stderr', font_size='large', layout=Layout(x=16, y=6, w=8, h=6)), CodeComparer(diff='split', layout=Layout(x=0, y=12, w=8, h=6)), ParallelCoordinatesPlot(columns=[ParallelCoordinatesPlotColumn(metric='Step'), ParallelCoordinatesPlotColumn(metric='c::model'), ParallelCoordinatesPlotColumn(metric='c::optimizer'), ParallelCoordinatesPlotColumn(metric='val_acc'), ParallelCoordinatesPlotColumn(metric='val_loss')], layout=Layout(x=8, y=12, w=8, h=6)), ParameterImportancePlot(with_respect_to='val_loss', layout=Layout(x=16, y=12, w=8, h=6)), RunComparer(diff_only=True, layout=Layout(x=0, y=18, w=8, h=6)), CustomChart(query={'summary': ['val_loss', 'val_acc'], 'id': None, 'name': None}, chart_name='wandb/scatter/v0', chart_fields={'x': 'val_loss', 'y': 'val_acc'}, layout=Layout(x=8, y=18, w=8, h=6))], active_runset=0), WeaveBlockSummaryTable(entity='your_entity', project='your_project', table_name='my-table'), WeaveBlockArtifact(entity='your_entity', project='your_project', artifact='model-1', tab='lineage'), WeaveBlockArtifactVersionedFile(entity='your_entity', project='your_project', artifact='model-1', version='v0', file='dataframe.table.json')], id='Vmlldzo5MTA1NTc0')" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import wandb_workspaces.reports.v2 as wr\n", + "\n", + "report = wr.Report(\n", + " project=PROJECT,\n", + " title='W&B Panel Gallery',\n", + " description=\"Check out all of the panels available in W&B\",\n", + " width='fluid',\n", + " blocks=[\n", + " wr.PanelGrid(\n", + " runsets=[\n", + " wr.Runset(project=LINEAGE_PROJECT),\n", + " wr.Runset(),\n", + " ],\n", + " panels=[\n", + " wr.MediaBrowser(media_keys=[\"img\"]),\n", + " wr.MarkdownPanel(markdown=\"Hello *italic* **bold** $e=mc^2$ `something`\"),\n", + "\n", + " # LinePlot with various settings enabled\n", + " wr.LinePlot(\n", + " title=\"Validation Accuracy over Time\",\n", + " x=\"Step\",\n", + " y=[\"val_acc\"],\n", + " range_x=(0, 1000),\n", + " range_y=(1, 4),\n", + " log_x=True,\n", + " log_y=False,\n", + " title_x=\"Training steps\",\n", + " title_y=\"Validation Accuracy\",\n", + " ignore_outliers=True,\n", + " groupby='encoder',\n", + " groupby_aggfunc=\"mean\",\n", + " groupby_rangefunc=\"minmax\",\n", + " smoothing_factor=0.5,\n", + " smoothing_type=\"gaussian\",\n", + " smoothing_show_original=True,\n", + " max_runs_to_show=10,\n", + " font_size=\"large\",\n", + " legend_position=\"west\",\n", + " ),\n", + " wr.ScatterPlot(\n", + " title=\"Validation Accuracy vs. Validation Loss\",\n", + " x=\"val_acc\",\n", + " y=\"val_loss\",\n", + " log_x=False,\n", + " log_y=False,\n", + " running_ymin=True,\n", + " running_ymean=True,\n", + " running_ymax=True,\n", + " font_size=\"small\",\n", + " regression=True,\n", + " ),\n", + " wr.BarPlot(\n", + " title=\"Validation Loss by Encoder\",\n", + " metrics=[\"val_loss\"],\n", + " orientation='h',\n", + " range_x=(0, 0.11),\n", + " title_x=\"Validation Loss\",\n", + " groupby='encoder',\n", + " groupby_aggfunc=\"median\",\n", + " groupby_rangefunc=\"stddev\",\n", + " max_runs_to_show=20,\n", + " max_bars_to_show=3,\n", + " font_size=\"auto\",\n", + " ),\n", + " wr.ScalarChart(\n", + " title=\"Maximum Number of Steps\",\n", + " metric=\"Step\",\n", + " groupby_aggfunc=\"max\",\n", + " groupby_rangefunc=\"stderr\",\n", + " font_size=\"large\",\n", + " ),\n", + " wr.CodeComparer(diff=\"split\"),\n", + " wr.ParallelCoordinatesPlot(\n", + " columns=[\n", + " wr.ParallelCoordinatesPlotColumn(\"Step\"),\n", + " wr.ParallelCoordinatesPlotColumn(\"c::model\"),\n", + " wr.ParallelCoordinatesPlotColumn(\"c::optimizer\"),\n", + " wr.ParallelCoordinatesPlotColumn(\"val_acc\"),\n", + " wr.ParallelCoordinatesPlotColumn(\"val_loss\"),\n", + " ],\n", + " ),\n", + " wr.ParameterImportancePlot(with_respect_to=\"val_loss\"),\n", + " wr.RunComparer(diff_only=True),\n", + " wr.CustomChart(\n", + " query={'summary': ['val_loss', 'val_acc']},\n", + " chart_name='wandb/scatter/v0',\n", + " chart_fields={'x': 'val_loss', 'y': 'val_acc'}\n", + " ),\n", + " ],\n", + " ),\n", + " # Add WeaveBlock types directly to the blocks list\n", + " wr.WeaveBlockSummaryTable(\n", + " entity=\"your_entity\",\n", + " project=\"your_project\",\n", + " table_name=\"my-table\"\n", + " ),\n", + " wr.WeaveBlockArtifact(\n", + " entity=\"your_entity\",\n", + " project=\"your_project\",\n", + " artifact='model-1',\n", + " tab='lineage'\n", + " ),\n", + " wr.WeaveBlockArtifactVersionedFile(\n", + " entity=\"your_entity\",\n", + " project=\"your_project\",\n", + " artifact='model-1',\n", + " version='v0',\n", + " file=\"dataframe.table.json\"\n", + " ),\n", + " ]\n", + ")\n", + "report.save()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_ImXrBtN7NDR" + }, + "source": [ + "## How can I link related reports together?\n", + "- Suppose have have two reports like below:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "ueOH3zoS7NDR" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Report-1--Vmlldzo5MTA1NTc1\n", + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Report-2--Vmlldzo5MTA1NTc3\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Report 2', width='readable', description='Great content coming from Report 2', blocks=[H1(text='Heading from Report 2'), P(text='Est quod ducimus ut distinctio corruptiid optio qui cupiditate quibusdam ea corporis modi. Eum architecto vero sed error dignissimosEa repudiandae a recusandae sint ut sint molestiae ea pariatur quae. In pariatur voluptas ad facere neque 33 suscipit et odit nostrum ut internos molestiae est modi enim. Et rerum inventoreAut internos et dolores delectus aut Quis sunt sed nostrum magnam ab dolores dicta.'), PanelGrid(runsets=[Runset(entity='openrlbenchmark', project='cleanrl', name='DQN', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='openrlbenchmark', project='cleanrl', name='SAC-discrete 0.8', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='openrlbenchmark', project='cleanrl', name='SAC-discrete 0.88', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(title='SPS', x='global_step', y=['charts/SPS'], layout=Layout(x=0, y=0, w=8, h=6)), LinePlot(title='Episodic Length', x='global_step', y=['charts/episodic_length'], layout=Layout(x=8, y=0, w=8, h=6)), LinePlot(title='Episodic Return', x='global_step', y=['charts/episodic_return'], layout=Layout(x=16, y=0, w=8, h=6))], active_runset=0, custom_run_colors={RunsetGroup(runset_name='DQN', keys=(RunsetGroupKey(key='dqn_atari', value='exp_name'),)): '#e84118', RunsetGroup(runset_name='SAC-discrete 0.8', keys=(RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#fbc531', RunsetGroup(runset_name='SAC-discrete 0.88', keys=(RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#00a8ff'})], id='Vmlldzo5MTA1NTc3')" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import wandb_workspaces.reports.v2 as wr\n", + "\n", + "report1 = wr.Report(\n", + " project=PROJECT,\n", + " title='Report 1',\n", + " description=\"Great content coming from Report 1\",\n", + " blocks=[\n", + " wr.H1(text='Heading from Report 1'),\n", + " wr.P(text='Lorem ipsum dolor sit amet. Aut fuga minus nam vero saepeA aperiam eum omnis dolorum et ducimus tempore aut illum quis aut alias vero. Sed explicabo illum est eius quianon vitae sed voluptatem incidunt. Vel architecto assumenda Ad voluptatem quo dicta provident et velit officia. Aut galisum inventoreSed dolore a illum adipisci a aliquam quidem sit corporis quia cum magnam similique.'),\n", + " wr.PanelGrid(\n", + " panels=[\n", + " wr.LinePlot(\n", + " title=\"Episodic Return\",\n", + " x='global_step',\n", + " y=['charts/episodic_return'],\n", + " smoothing_factor=0.85,\n", + " groupby_aggfunc='mean',\n", + " groupby_rangefunc='minmax',\n", + " layout=wr.Layout(x=0, y=0, w=12, h=8)\n", + " ),\n", + " wr.MediaBrowser(\n", + " media_keys=[\"videos\"],\n", + " num_columns=4,\n", + " layout=wr.Layout(w=12, h=8)\n", + " ),\n", + " ],\n", + " runsets=[\n", + " wr.Runset(\n", + " entity='openrlbenchmark',\n", + " project='cleanrl',\n", + " query='bigfish',\n", + " groupby=['env_id', 'exp_name']\n", + " )\n", + " ],\n", + " custom_run_colors={\n", + " wr.RunsetGroup(runset_name='Run set', keys=(wr.RunsetGroupKey(key='bigfish', value='ppg_procgen'),)): \"#2980b9\",\n", + " wr.RunsetGroup(runset_name='Run set', keys=(wr.RunsetGroupKey(key='bigfish', value='ppo_procgen'),)): \"#e74c3c\",\n", + " }\n", + " ),\n", + " ]\n", + ")\n", + "report1.save()\n", + "\n", + "report2 = wr.Report(\n", + " project=PROJECT,\n", + " title='Report 2',\n", + " description=\"Great content coming from Report 2\",\n", + " blocks=[\n", + " wr.H1(text='Heading from Report 2'),\n", + " wr.P(text='Est quod ducimus ut distinctio corruptiid optio qui cupiditate quibusdam ea corporis modi. Eum architecto vero sed error dignissimosEa repudiandae a recusandae sint ut sint molestiae ea pariatur quae. In pariatur voluptas ad facere neque 33 suscipit et odit nostrum ut internos molestiae est modi enim. Et rerum inventoreAut internos et dolores delectus aut Quis sunt sed nostrum magnam ab dolores dicta.'),\n", + " wr.PanelGrid(\n", + " panels=[\n", + " wr.LinePlot(\n", + " title=\"SPS\",\n", + " x='global_step',\n", + " y=['charts/SPS']\n", + " ),\n", + " wr.LinePlot(\n", + " title=\"Episodic Length\",\n", + " x='global_step',\n", + " y=['charts/episodic_length']\n", + " ),\n", + " wr.LinePlot(\n", + " title=\"Episodic Return\",\n", + " x='global_step',\n", + " y=['charts/episodic_return']\n", + " ),\n", + " ],\n", + " runsets=[\n", + " wr.Runset(\n", + " entity=\"openrlbenchmark\",\n", + " project=\"cleanrl\",\n", + " name=\"DQN\",\n", + " groupby=[\"exp_name\"]\n", + "\n", + " ),\n", + " wr.Runset(\n", + " entity=\"openrlbenchmark\",\n", + " project=\"cleanrl\",\n", + " name=\"SAC-discrete 0.8\",\n", + " groupby=[\"exp_name\"]\n", + "\n", + " ),\n", + " wr.Runset(\n", + " entity=\"openrlbenchmark\",\n", + " project=\"cleanrl\",\n", + " name=\"SAC-discrete 0.88\",\n", + " groupby=[\"exp_name\"]\n", + "\n", + " ),\n", + " ],\n", + " custom_run_colors={\n", + " wr.RunsetGroup(runset_name='DQN', keys=(wr.RunsetGroupKey(key='dqn_atari', value='exp_name'),)): '#e84118',\n", + " wr.RunsetGroup(runset_name='SAC-discrete 0.8', keys=(wr.RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#fbc531',\n", + " wr.RunsetGroup(runset_name='SAC-discrete 0.88', keys=(wr.RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#00a8ff',\n", + " }\n", + " ),\n", + " ]\n", + ")\n", + "report2.save()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "NOhlK4G47NDR" + }, + "source": [ + "### Combine blocks into a new report" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "id": "vfRryyUM7NDR" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Report-with-links--Vmlldzo5MTA1NTc4\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Report with links', width='readable', description='Use `wr.Link(text, url)` to add links inside normal text, or use normal markdown syntax in a MarkdownBlock', blocks=[H1(text='This is a normal heading'), P(text='And here is some normal text'), H1(text=['This is a heading ', Link(text='with a link!', url='https://wandb.ai/')]), P(text=['Most text formats support ', Link(text='adding links', url='https://wandb.ai/')]), MarkdownBlock(text='You can also use markdown syntax for [links](https://wandb.ai/)')], id='Vmlldzo5MTA1NTc4')" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report = wr.Report(PROJECT,\n", + " title=\"Report with links\",\n", + " description=\"Use `wr.Link(text, url)` to add links inside normal text, or use normal markdown syntax in a MarkdownBlock\",\n", + " blocks=[\n", + " wr.H1(\"This is a normal heading\"),\n", + " wr.P(\"And here is some normal text\"),\n", + "\n", + " wr.H1([\"This is a heading \", wr.Link(\"with a link!\", url=\"https://wandb.ai/\")]),\n", + " wr.P([\"Most text formats support \", wr.Link(\"adding links\", url=\"https://wandb.ai/\")]),\n", + "\n", + " wr.MarkdownBlock(\"\"\"You can also use markdown syntax for [links](https://wandb.ai/)\"\"\")\n", + " ]\n", + ")\n", + "report.save()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "9GWSIsVp7NDU" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34m\u001b[1mwandb\u001b[0m: Saved report to: https://wandb.ai/noahluna/report-api-quickstart/reports/Combined-blocks-report--Vmlldzo5MTA1NTc5\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Report(project='report-api-quickstart', entity='noahluna', title='Combined blocks report', width='readable', description='This report combines blocks from both Report 1 and Report 2', blocks=[H1(text='Heading from Report 1'), P(text='Lorem ipsum dolor sit amet. Aut fuga minus nam vero saepeA aperiam eum omnis dolorum et ducimus tempore aut illum quis aut alias vero. Sed explicabo illum est eius quianon vitae sed voluptatem incidunt. Vel architecto assumenda Ad voluptatem quo dicta provident et velit officia. Aut galisum inventoreSed dolore a illum adipisci a aliquam quidem sit corporis quia cum magnam similique.'), PanelGrid(runsets=[Runset(entity='openrlbenchmark', project='cleanrl', name='Run set', query='bigfish', groupby=['env_id', 'exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(title='Episodic Return', x='global_step', y=['charts/episodic_return'], groupby_aggfunc='mean', groupby_rangefunc='minmax', smoothing_factor=0.85, layout=Layout(x=0, y=0, w=12, h=8)), MediaBrowser(num_columns=4, media_keys=['videos'], layout=Layout(x=12, y=0, w=12, h=8))], active_runset=0, custom_run_colors={RunsetGroup(runset_name='Run set', keys=(RunsetGroupKey(key='bigfish', value='ppg_procgen'),)): '#2980b9', RunsetGroup(runset_name='Run set', keys=(RunsetGroupKey(key='bigfish', value='ppo_procgen'),)): '#e74c3c'}), H1(text='Heading from Report 2'), P(text='Est quod ducimus ut distinctio corruptiid optio qui cupiditate quibusdam ea corporis modi. Eum architecto vero sed error dignissimosEa repudiandae a recusandae sint ut sint molestiae ea pariatur quae. In pariatur voluptas ad facere neque 33 suscipit et odit nostrum ut internos molestiae est modi enim. Et rerum inventoreAut internos et dolores delectus aut Quis sunt sed nostrum magnam ab dolores dicta.'), PanelGrid(runsets=[Runset(entity='openrlbenchmark', project='cleanrl', name='DQN', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='openrlbenchmark', project='cleanrl', name='SAC-discrete 0.8', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)]), Runset(entity='openrlbenchmark', project='cleanrl', name='SAC-discrete 0.88', groupby=['exp_name'], order=[OrderBy(name='CreatedTimestamp', ascending=False)])], panels=[LinePlot(title='SPS', x='global_step', y=['charts/SPS'], layout=Layout(x=0, y=0, w=8, h=6)), LinePlot(title='Episodic Length', x='global_step', y=['charts/episodic_length'], layout=Layout(x=8, y=0, w=8, h=6)), LinePlot(title='Episodic Return', x='global_step', y=['charts/episodic_return'], layout=Layout(x=16, y=0, w=8, h=6))], active_runset=0, custom_run_colors={RunsetGroup(runset_name='DQN', keys=(RunsetGroupKey(key='dqn_atari', value='exp_name'),)): '#e84118', RunsetGroup(runset_name='SAC-discrete 0.8', keys=(RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#fbc531', RunsetGroup(runset_name='SAC-discrete 0.88', keys=(RunsetGroupKey(key='sac_atari', value='exp_name'),)): '#00a8ff'})], id='Vmlldzo5MTA1NTc5')" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "report3 = wr.Report(\n", + " PROJECT,\n", + " title=\"Combined blocks report\",\n", + " description=\"This report combines blocks from both Report 1 and Report 2\",\n", + " blocks=[*report1.blocks, *report2.blocks]\n", + ")\n", + "report3.save()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pXt2x1L07NDV" + }, + "source": [ + "## I tried mutating an object in list but it didn't work!\n", + "tl;dr: It should always work if you assign a value to the attribute instead of mutating. If you really need to mutate, do it before assignment.\n", + "\n", + "---\n", + "\n", + "This can happen in a few places that contain lists of wandb objects, e.g.:\n", + "- `report.blocks`\n", + "- `panel_grid.panels`\n", + "- `panel_grid.runsets`" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "id": "0EbcQqOM7NDV" + }, + "outputs": [], + "source": [ + "report = wr.Report(project=PROJECT)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "H0J06T757NDV" + }, + "source": [ + "Good: Assign `b`" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "id": "tgMca01g7NDV" + }, + "outputs": [], + "source": [ + "b = wr.H1(text=[\"Hello\", \" World!\"])\n", + "report.blocks = [b]\n", + "assert b.text == [\"Hello\", \" World!\"]\n", + "assert report.blocks[0].text == [\"Hello\", \" World!\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "uDQ8wSn77NDV" + }, + "source": [ + "Bad: Mutate `b` without reassigning" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "id": "xMX5Xr0x7NDV" + }, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[18], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m b\u001b[38;5;241m.\u001b[39mtext \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSomething\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m New\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m b\u001b[38;5;241m.\u001b[39mtext \u001b[38;5;241m==\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSomething\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m New\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m report\u001b[38;5;241m.\u001b[39mblocks[\u001b[38;5;241m0\u001b[39m]\u001b[38;5;241m.\u001b[39mtext \u001b[38;5;241m==\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m World!\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# This will error!\u001b[39;00m\n", + "\u001b[0;31mAssertionError\u001b[0m: " + ] + } + ], + "source": [ + "b.text = [\"Something\", \" New\"]\n", + "assert b.text == [\"Something\", \" New\"]\n", + "assert report.blocks[0].text == [\"Hello\", \" World!\"]\n", + "\n", + "# This will error!" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KUMkP_9t7NDV" + }, + "source": [ + "Good: Mutate `b` and then reassign it" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Wif3JPMo7NDV" + }, + "outputs": [], + "source": [ + "report.blocks = [b]\n", + "assert b.text == [\"Something\", \" New\"]\n", + "assert report.blocks[0].text == [\"Something\", \" New\"]" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "include_colab_link": true, + "provenance": [], + "toc_visible": true + }, + "kernelspec": { + "display_name": "example_notebooks", + "language": "python", + "name": "example_notebooks" }, - "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.0" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}