diff --git a/.github/workflows/README.md b/.github/workflows/README.md
index 7e81ca460c..06c1f5451a 100644
--- a/.github/workflows/README.md
+++ b/.github/workflows/README.md
@@ -67,7 +67,17 @@ When the draft PR is created:
The workflow uses:
- **Python**: 3.11
- **Permissions**: `contents: write`, `pull-requests: write`
-- **Action**: `peter-evans/create-pull-request@v6`
+- **Action**: `peter-evans/create-pull-request@v8`
+
+**Authentication and `docs-code-eval`**
+
+The automatic `GITHUB_TOKEN` is scoped to this repository (`wandb/docs`) only. It does not grant read access to other private repositories in the org, so it cannot replace a PAT for cloning `wandb/docs-code-eval` when that repo is private.
+
+To sync from a **private** `docs-code-eval`, add a repository secret named `DOCS_CODE_EVAL_READ_PAT`: a fine-grained personal access token (or classic PAT) with **Contents** read access to `wandb/docs-code-eval`. The sync script uses it only for `git clone`. If the secret is not set and `docs-code-eval` is public, the workflow clones without a token.
+
+**Clone fails with `could not read Username for 'https://github.com'`**
+
+That usually means Git tried to prompt for credentials (no TTY in Actions) or a credential helper failed. The sync script clears `credential.helper` for the clone and uses HTTPS with `x-access-token` when `DOCS_CODE_EVAL_READ_PAT` is set. If the log shows **anonymous** clone but the repo is private, the secret is missing, misnamed, or not available to this workflow (for example some fork contexts). Re-check the secret name `DOCS_CODE_EVAL_READ_PAT` and that the job log line above the clone says **PAT over HTTPS**.
### Troubleshooting
diff --git a/.github/workflows/sync-code-examples.yml b/.github/workflows/sync-code-examples.yml
index eb7d12c067..0ee50cbb14 100644
--- a/.github/workflows/sync-code-examples.yml
+++ b/.github/workflows/sync-code-examples.yml
@@ -14,14 +14,26 @@ jobs:
- name: Checkout docs repository
uses: actions/checkout@v6
with:
- token: ${{ secrets.GITHUB_TOKEN }}
-
+ # Do not persist GITHUB_TOKEN as http.https://github.com/.extraheader:
+ # a later `git clone` of docs-code-eval would reuse it and often exit 128.
+ persist-credentials: false
+
+ # Do not use actions/checkout for wandb/docs-code-eval. GITHUB_TOKEN is scoped
+ # to this repository only, so the REST get-repository call for another repo returns
+ # Not Found for a private docs-code-eval. Clone in the script instead.
+ #
+ # For a private docs-code-eval, add repository secret DOCS_CODE_EVAL_READ_PAT
+ # (PAT with contents:read on wandb/docs-code-eval). Optional if the eval repo is public.
+
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Run sync script
+ env:
+ DOCS_CODE_EVAL_READ_TOKEN: ${{ secrets.DOCS_CODE_EVAL_READ_PAT }}
+ GIT_TERMINAL_PROMPT: "0"
run: |
chmod +x scripts/sync_code_examples.sh
./scripts/sync_code_examples.sh
diff --git a/models/ref/sdk-coding-cheat-sheet/logging.mdx b/models/ref/sdk-coding-cheat-sheet/logging.mdx
index 1d9786f015..a619cb31c3 100644
--- a/models/ref/sdk-coding-cheat-sheet/logging.mdx
+++ b/models/ref/sdk-coding-cheat-sheet/logging.mdx
@@ -3,30 +3,60 @@ title: Logging
description: Log metrics, hyperparameters, tables, and custom data to W&B.
---
+import LogCsvFiles from '/snippets/en/_includes/code-examples/log_csv_files.mdx';
import LogCustomSummaryMetric from '/snippets/en/_includes/code-examples/log_custom_summary_metric.mdx';
+import LogCustomSummatyMetric from '/snippets/en/_includes/code-examples/log_custom_summaty_metric.mdx';
import LogExistingArtifactLinkCollection from '/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.mdx';
+import LogHistogramPlot from '/snippets/en/_includes/code-examples/log_histogram_plot.mdx';
import LogHyperparameter from '/snippets/en/_includes/code-examples/log_hyperparameter.mdx';
+import LogLinePlot from '/snippets/en/_includes/code-examples/log_line_plot.mdx';
import LogMetric from '/snippets/en/_includes/code-examples/log_metric.mdx';
+import LogScatterPlot from '/snippets/en/_includes/code-examples/log_scatter_plot.mdx';
+import LogSummaryMetric from '/snippets/en/_includes/code-examples/log_summary_metric.mdx';
import LogTable from '/snippets/en/_includes/code-examples/log_table.mdx';
Log metrics, hyperparameters, tables, and custom data to W&B.
+## Log a CSV file to as a table
+
+
+
## Log a custom summary metric
+## Log a custom summary metric
+
+
+
## Download and log an existing artifact from a registry collection
+## Log a histogram plot
+
+
+
## Initialize a run and log hyperparameters
+## Log a line plot
+
+
+
## Initialize a run and log a metric
+## Log a scatter plot
+
+
+
+## Explicitly log a summary metric
+
+
+
## Log a table
diff --git a/models/ref/sdk-coding-cheat-sheet/runs.mdx b/models/ref/sdk-coding-cheat-sheet/runs.mdx
index 210d56e969..222901ffba 100644
--- a/models/ref/sdk-coding-cheat-sheet/runs.mdx
+++ b/models/ref/sdk-coding-cheat-sheet/runs.mdx
@@ -6,6 +6,11 @@ description: Initialize and manage W&B runs to organize your experiments and tra
import ExperimentsCreate from '/snippets/en/_includes/code-examples/experiments_create.mdx';
import RunFork from '/snippets/en/_includes/code-examples/run_fork.mdx';
import RunInit from '/snippets/en/_includes/code-examples/run_init.mdx';
+import RunsAddTags from '/snippets/en/_includes/code-examples/runs_add_tags.mdx';
+import RunsGroup from '/snippets/en/_includes/code-examples/runs_group.mdx';
+import RunsOrganizeByType from '/snippets/en/_includes/code-examples/runs_organize_by_type.mdx';
+import RunsUpdateTag from '/snippets/en/_includes/code-examples/runs_update_tag.mdx';
+import RunsUpdateTagPublicApi from '/snippets/en/_includes/code-examples/runs_update_tag_public_api.mdx';
Initialize and manage W&B runs to organize your experiments and track your work.
@@ -21,3 +26,23 @@ Initialize and manage W&B runs to organize your experiments and track your work.
+## Add one or more tags to a run
+
+
+
+## Add one or more runs to a group
+
+
+
+## Organize runs by their job type
+
+
+
+## Add one or more tags to an active run
+
+
+
+## Add one or more tags to previously saved runs
+
+
+
diff --git a/scripts/sync_code_examples.sh b/scripts/sync_code_examples.sh
index 746907a49a..ab06f6d0b2 100755
--- a/scripts/sync_code_examples.sh
+++ b/scripts/sync_code_examples.sh
@@ -8,19 +8,41 @@ set -e # Exit on error
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOCS_ROOT="$(dirname "$SCRIPT_DIR")"
SUBMODULE_PATH="$DOCS_ROOT/.temp_code_eval"
-EVAL_REPO_URL="https://github.com/wandb/docs-code-eval.git"
echo "🔄 Syncing code examples from docs-code-eval..."
-# Clean up any existing temp submodule
-if [ -d "$SUBMODULE_PATH" ]; then
- echo " Removing existing temporary directory..."
- rm -rf "$SUBMODULE_PATH"
+# Optional: fine-grained or classic PAT with contents:read on wandb/docs-code-eval.
+# Set by CI via secrets (see sync-code-examples workflow). Unset = anonymous clone (public repo only).
+if [ -n "${DOCS_CODE_EVAL_READ_TOKEN:-}" ]; then
+ EVAL_CLONE_URL="https://x-access-token:${DOCS_CODE_EVAL_READ_TOKEN}@github.com/wandb/docs-code-eval.git"
+else
+ EVAL_CLONE_URL="https://github.com/wandb/docs-code-eval.git"
fi
-# Clone the repo (not as submodule, just a temp clone)
-echo " Cloning docs-code-eval repository..."
-git clone --depth 1 "$EVAL_REPO_URL" "$SUBMODULE_PATH" --quiet
+# Prefer an existing .temp_code_eval (e.g. local prep). In CI we clone after docs
+# checkout with persist-credentials false; see sync-code-examples workflow comments.
+if [ -d "$SUBMODULE_PATH/ground_truth" ] && compgen -G "$SUBMODULE_PATH/ground_truth/"*.py > /dev/null; then
+ echo " Using existing docs-code-eval checkout at $SUBMODULE_PATH"
+else
+ if [ -d "$SUBMODULE_PATH" ]; then
+ echo " Removing existing temporary directory..."
+ rm -rf "$SUBMODULE_PATH"
+ fi
+ echo " Cloning docs-code-eval repository..."
+ if [ -n "${DOCS_CODE_EVAL_READ_TOKEN:-}" ]; then
+ echo " (HTTPS with PAT from DOCS_CODE_EVAL_READ_PAT)"
+ else
+ echo " (anonymous HTTPS; set secret DOCS_CODE_EVAL_READ_PAT if the eval repo is private)"
+ fi
+ # - Clear extraheader so a stale Actions token does not override URL credentials.
+ # - credential.helper= stops the runner's helper from prompting (CI has no TTY; you
+ # may otherwise see "could not read Username" / "No such device or address").
+ export GIT_TERMINAL_PROMPT=0
+ git \
+ -c http.https://github.com/.extraheader= \
+ -c credential.helper= \
+ clone --depth 1 "$EVAL_CLONE_URL" "$SUBMODULE_PATH" --quiet
+fi
# Copy Python files and create MDX wrappers
echo " Copying Python code examples and creating MDX wrappers..."
diff --git a/snippets/CodeSnippet.jsx b/snippets/CodeSnippet.jsx
index a3dc8569c1..2b8c8e59a9 100644
--- a/snippets/CodeSnippet.jsx
+++ b/snippets/CodeSnippet.jsx
@@ -12,6 +12,8 @@
* AUTO-GENERATED: Do not edit manually. Run sync_code_examples.sh to regenerate.
*/
+import React from 'react';
+
// Import all MDX-wrapped code examples
import ArtifactAddAlias from '/snippets/en/_includes/code-examples/artifact_add_alias.mdx';
import ArtifactAddAliasExisting from '/snippets/en/_includes/code-examples/artifact_add_alias_existing.mdx';
@@ -28,10 +30,16 @@ import ArtifactUpdate from '/snippets/en/_includes/code-examples/artifact_update
import ArtifactUpdateExisting from '/snippets/en/_includes/code-examples/artifact_update_existing.mdx';
import ArtifactsDownload from '/snippets/en/_includes/code-examples/artifacts_download.mdx';
import ExperimentsCreate from '/snippets/en/_includes/code-examples/experiments_create.mdx';
+import LogCsvFiles from '/snippets/en/_includes/code-examples/log_csv_files.mdx';
import LogCustomSummaryMetric from '/snippets/en/_includes/code-examples/log_custom_summary_metric.mdx';
+import LogCustomSummatyMetric from '/snippets/en/_includes/code-examples/log_custom_summaty_metric.mdx';
import LogExistingArtifactLinkCollection from '/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.mdx';
+import LogHistogramPlot from '/snippets/en/_includes/code-examples/log_histogram_plot.mdx';
import LogHyperparameter from '/snippets/en/_includes/code-examples/log_hyperparameter.mdx';
+import LogLinePlot from '/snippets/en/_includes/code-examples/log_line_plot.mdx';
import LogMetric from '/snippets/en/_includes/code-examples/log_metric.mdx';
+import LogScatterPlot from '/snippets/en/_includes/code-examples/log_scatter_plot.mdx';
+import LogSummaryMetric from '/snippets/en/_includes/code-examples/log_summary_metric.mdx';
import LogTable from '/snippets/en/_includes/code-examples/log_table.mdx';
import RegistryAddAnnotation from '/snippets/en/_includes/code-examples/registry_add_annotation.mdx';
import RegistryCollectionCreate from '/snippets/en/_includes/code-examples/registry_collection_create.mdx';
@@ -41,8 +49,19 @@ import RegistryCreate from '/snippets/en/_includes/code-examples/registry_create
import RegistryDelete from '/snippets/en/_includes/code-examples/registry_delete.mdx';
import RegistryLinkArtifactExisting from '/snippets/en/_includes/code-examples/registry_link_artifact_existing.mdx';
import RegistryUseLinkedArtifact from '/snippets/en/_includes/code-examples/registry_use_linked_artifact.mdx';
+import ResumeRun from '/snippets/en/_includes/code-examples/resume_run.mdx';
+import RewindRun from '/snippets/en/_includes/code-examples/rewind_run.mdx';
import RunFork from '/snippets/en/_includes/code-examples/run_fork.mdx';
import RunInit from '/snippets/en/_includes/code-examples/run_init.mdx';
+import RunsAddTags from '/snippets/en/_includes/code-examples/runs_add_tags.mdx';
+import RunsGroup from '/snippets/en/_includes/code-examples/runs_group.mdx';
+import RunsOrganizeByType from '/snippets/en/_includes/code-examples/runs_organize_by_type.mdx';
+import RunsUpdateTag from '/snippets/en/_includes/code-examples/runs_update_tag.mdx';
+import RunsUpdateTagPublicApi from '/snippets/en/_includes/code-examples/runs_update_tag_public_api.mdx';
+import SweepConfig from '/snippets/en/_includes/code-examples/sweep_config.mdx';
+import SweepCreate from '/snippets/en/_includes/code-examples/sweep_create.mdx';
+import SweepInitialize from '/snippets/en/_includes/code-examples/sweep_initialize.mdx';
+import SweepStart from '/snippets/en/_includes/code-examples/sweep_start.mdx';
// Map filenames to imported content
const snippets = {
@@ -61,10 +80,16 @@ const snippets = {
'artifact_update_existing.py': ArtifactUpdateExisting,
'artifacts_download.py': ArtifactsDownload,
'experiments_create.py': ExperimentsCreate,
+ 'log_csv_files.py': LogCsvFiles,
'log_custom_summary_metric.py': LogCustomSummaryMetric,
+ 'log_custom_summaty_metric.py': LogCustomSummatyMetric,
'log_existing_artifact_link_collection.py': LogExistingArtifactLinkCollection,
+ 'log_histogram_plot.py': LogHistogramPlot,
'log_hyperparameter.py': LogHyperparameter,
+ 'log_line_plot.py': LogLinePlot,
'log_metric.py': LogMetric,
+ 'log_scatter_plot.py': LogScatterPlot,
+ 'log_summary_metric.py': LogSummaryMetric,
'log_table.py': LogTable,
'registry_add_annotation.py': RegistryAddAnnotation,
'registry_collection_create.py': RegistryCollectionCreate,
@@ -74,13 +99,24 @@ const snippets = {
'registry_delete.py': RegistryDelete,
'registry_link_artifact_existing.py': RegistryLinkArtifactExisting,
'registry_use_linked_artifact.py': RegistryUseLinkedArtifact,
+ 'resume_run.py': ResumeRun,
+ 'rewind_run.py': RewindRun,
'run_fork.py': RunFork,
'run_init.py': RunInit,
+ 'runs_add_tags.py': RunsAddTags,
+ 'runs_group.py': RunsGroup,
+ 'runs_organize_by_type.py': RunsOrganizeByType,
+ 'runs_update_tag.py': RunsUpdateTag,
+ 'runs_update_tag_public_api.py': RunsUpdateTagPublicApi,
+ 'sweep_config.py': SweepConfig,
+ 'sweep_create.py': SweepCreate,
+ 'sweep_initialize.py': SweepInitialize,
+ 'sweep_start.py': SweepStart,
};
export const CodeSnippet = ({ file }) => {
const Component = snippets[file];
-
+
if (!Component) {
return (
@@ -88,7 +124,7 @@ export const CodeSnippet = ({ file }) => {
);
}
-
+
return ;
};
diff --git a/snippets/en/_includes/code-examples/artifact_add_alias.py b/snippets/en/_includes/code-examples/artifact_add_alias.py
index 9b30586c69..6e28614160 100644
--- a/snippets/en/_includes/code-examples/artifact_add_alias.py
+++ b/snippets/en/_includes/code-examples/artifact_add_alias.py
@@ -10,4 +10,4 @@
with wandb.init(project="") as run:
# Log the artifact with aliases
- run.log_artifact(artifact, aliases=["", ""])
+ run.log_artifact(artifact, aliases=["", ""])
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_add_alias_existing.py b/snippets/en/_includes/code-examples/artifact_add_alias_existing.py
index aca971d161..26762f5c7f 100644
--- a/snippets/en/_includes/code-examples/artifact_add_alias_existing.py
+++ b/snippets/en/_includes/code-examples/artifact_add_alias_existing.py
@@ -6,4 +6,4 @@
# Retrieve an existing artifact and add an alias to it
artifact = wandb.Api().artifact("entity/project/artifact:version")
artifact.aliases = [""]
-artifact.save()
+artifact.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_add_tag.py b/snippets/en/_includes/code-examples/artifact_add_tag.py
index a09b483109..dbd30f3eef 100644
--- a/snippets/en/_includes/code-examples/artifact_add_tag.py
+++ b/snippets/en/_includes/code-examples/artifact_add_tag.py
@@ -8,4 +8,4 @@
# Log the artifact with tags
with wandb.init(project="") as run:
- run.log_artifact(artifact, tags=["", ""])
+ run.log_artifact(artifact, tags=["", ""])
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_add_tag_existing.py b/snippets/en/_includes/code-examples/artifact_add_tag_existing.py
index 27ce54e713..9cb465a399 100644
--- a/snippets/en/_includes/code-examples/artifact_add_tag_existing.py
+++ b/snippets/en/_includes/code-examples/artifact_add_tag_existing.py
@@ -6,4 +6,4 @@
# Retrieve an existing artifact and add a tag to it
artifact = wandb.Api().artifact("entity/project/artifact:version")
artifact.tags = ["new-tag"]
-artifact.save()
+artifact.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_create.py b/snippets/en/_includes/code-examples/artifact_create.py
index dd489f5e21..92c63b9775 100644
--- a/snippets/en/_includes/code-examples/artifact_create.py
+++ b/snippets/en/_includes/code-examples/artifact_create.py
@@ -21,4 +21,4 @@
# Training and logging code goes here
# Example of logging an artifact
- run.log_artifact(artifact)
+ run.log_artifact(artifact)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_create_track_external.py b/snippets/en/_includes/code-examples/artifact_create_track_external.py
index f49d4c9c17..c14bcbb0a9 100644
--- a/snippets/en/_includes/code-examples/artifact_create_track_external.py
+++ b/snippets/en/_includes/code-examples/artifact_create_track_external.py
@@ -14,4 +14,4 @@
with wandb.init(project="") as run:
# Log the artifact's metadata
- run.log_artifact(artifact)
+ run.log_artifact(artifact)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_delete.py b/snippets/en/_includes/code-examples/artifact_delete.py
index c659730e73..8176d4c167 100644
--- a/snippets/en/_includes/code-examples/artifact_delete.py
+++ b/snippets/en/_includes/code-examples/artifact_delete.py
@@ -16,4 +16,4 @@
# Index the last two characters of the artifact version name (str) that
# consists of the version number
if artifact_version.name[-2:] == "v"+ "":
- artifact_version.delete(delete_aliases=True)
+ artifact_version.delete(delete_aliases=True)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_delete_collection.py b/snippets/en/_includes/code-examples/artifact_delete_collection.py
index 98596788cb..abe9aa9c31 100644
--- a/snippets/en/_includes/code-examples/artifact_delete_collection.py
+++ b/snippets/en/_includes/code-examples/artifact_delete_collection.py
@@ -13,4 +13,4 @@
type_name=""
)
-collection.delete()
+collection.delete()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_download_partial.py b/snippets/en/_includes/code-examples/artifact_download_partial.py
index 5e8902ae8d..3f516199e6 100644
--- a/snippets/en/_includes/code-examples/artifact_download_partial.py
+++ b/snippets/en/_includes/code-examples/artifact_download_partial.py
@@ -9,4 +9,4 @@
artifact = run.use_artifact(":")
# Download a specific file or sub-folder
- artifact.download(path_prefix="") # downloads only the specified file or folder
+ artifact.download(path_prefix="") # downloads only the specified file or folder
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_ttl.py b/snippets/en/_includes/code-examples/artifact_ttl.py
index 8498e0b14c..424f4a3b4e 100644
--- a/snippets/en/_includes/code-examples/artifact_ttl.py
+++ b/snippets/en/_includes/code-examples/artifact_ttl.py
@@ -11,4 +11,4 @@
with wandb.init(project="", entity="") as run:
# Log the artifact with TTL
- run.log_artifact(artifact)
+ run.log_artifact(artifact)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_ttl_existing.py b/snippets/en/_includes/code-examples/artifact_ttl_existing.py
index 11898d901f..a9f270dbe3 100644
--- a/snippets/en/_includes/code-examples/artifact_ttl_existing.py
+++ b/snippets/en/_includes/code-examples/artifact_ttl_existing.py
@@ -14,4 +14,4 @@
artifact.ttl = timedelta(days=365) # Delete in one year
# Save the updated artifact
-artifact.save()
+artifact.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_update.py b/snippets/en/_includes/code-examples/artifact_update.py
index 026c89caa2..ca5606871b 100644
--- a/snippets/en/_includes/code-examples/artifact_update.py
+++ b/snippets/en/_includes/code-examples/artifact_update.py
@@ -12,4 +12,4 @@
# Update the artifact's description
artifact.description = ""
# Save the updated artifact
- artifact.save()
+ artifact.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifact_update_existing.py b/snippets/en/_includes/code-examples/artifact_update_existing.py
index 4e117374ee..5c9a56eb79 100644
--- a/snippets/en/_includes/code-examples/artifact_update_existing.py
+++ b/snippets/en/_includes/code-examples/artifact_update_existing.py
@@ -27,4 +27,4 @@
artifact.aliases = ["replaced"]
# Persist all artifact modifications
-artifact.save()
+artifact.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/artifacts_download.py b/snippets/en/_includes/code-examples/artifacts_download.py
index a7d4d4db00..1a4e83c2eb 100644
--- a/snippets/en/_includes/code-examples/artifacts_download.py
+++ b/snippets/en/_includes/code-examples/artifacts_download.py
@@ -14,4 +14,4 @@
entry = artifact.get_entry("")
# Download the entire artifact
- datadir = artifact.download()
+ datadir = artifact.download()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/experiments_create.py b/snippets/en/_includes/code-examples/experiments_create.py
index 7722d28b9a..b77cf50945 100644
--- a/snippets/en/_includes/code-examples/experiments_create.py
+++ b/snippets/en/_includes/code-examples/experiments_create.py
@@ -9,4 +9,4 @@
# Initialize a W&B run
with wandb.init(project="") as run:
# Experiment code goes here
- pass
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_csv_files.mdx b/snippets/en/_includes/code-examples/log_csv_files.mdx
new file mode 100644
index 0000000000..4be01fbd6a
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_csv_files.mdx
@@ -0,0 +1,24 @@
+```python
+"""
+Log a CSV file to W&B as a table.
+
+Replace:
+- values enclosed in angle brackets with your own
+- .csv in pd.read_csv() with the name of your CSV file
+"""
+
+import wandb
+import pandas as pd
+
+# Read CSV as a DataFrame object (pandas)
+dataframe = pd.read_csv(".csv")
+
+# Convert the DataFrame into a W&B Table
+table = wandb.Table(dataframe=dataframe)
+
+# Start a W&B run to log data
+with wandb.init(project="") as run:
+
+ # Log the table to visualize it in the W&B UI
+ run.log({"": table})
+```
diff --git a/snippets/en/_includes/code-examples/log_csv_files.py b/snippets/en/_includes/code-examples/log_csv_files.py
new file mode 100644
index 0000000000..baf84bdc2a
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_csv_files.py
@@ -0,0 +1,22 @@
+"""
+Log a CSV file to W&B as a table.
+
+Replace:
+- values enclosed in angle brackets with your own
+- .csv in pd.read_csv() with the name of your CSV file
+"""
+
+import wandb
+import pandas as pd
+
+# Read CSV as a DataFrame object (pandas)
+dataframe = pd.read_csv(".csv")
+
+# Convert the DataFrame into a W&B Table
+table = wandb.Table(dataframe=dataframe)
+
+# Start a W&B run to log data
+with wandb.init(project="") as run:
+
+ # Log the table to visualize it in the W&B UI
+ run.log({"": table})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_custom_summaty_metric.mdx b/snippets/en/_includes/code-examples/log_custom_summaty_metric.mdx
new file mode 100644
index 0000000000..2980432c4b
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_custom_summaty_metric.mdx
@@ -0,0 +1,23 @@
+```python
+"""
+Log a custom summary metric to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- and in run.define_metric() with
+ one of "max", "min", "last", "mean", "best", or "none".
+"""
+import wandb
+import random
+
+with wandb.init() as run:
+ # summary_function_a and summary_function_b summary values for metric_name_a
+ run.define_metric(name="", summary="")
+ run.define_metric(name="", summary="")
+
+ for i in range(10):
+ log_dict = {
+ "metric_name_a": random.uniform(0, 1 / (i + 1)),
+ }
+ run.log(log_dict)
+```
diff --git a/snippets/en/_includes/code-examples/log_custom_summaty_metric.py b/snippets/en/_includes/code-examples/log_custom_summaty_metric.py
new file mode 100644
index 0000000000..f54b9b3e6f
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_custom_summaty_metric.py
@@ -0,0 +1,21 @@
+"""
+Log a custom summary metric to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- and in run.define_metric() with
+ one of "max", "min", "last", "mean", "best", or "none".
+"""
+import wandb
+import random
+
+with wandb.init() as run:
+ # summary_function_a and summary_function_b summary values for metric_name_a
+ run.define_metric(name="", summary="")
+ run.define_metric(name="", summary="")
+
+ for i in range(10):
+ log_dict = {
+ "metric_name_a": random.uniform(0, 1 / (i + 1)),
+ }
+ run.log(log_dict)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.py b/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.py
index 8fe3cc01ac..58cbde23a4 100644
--- a/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.py
+++ b/snippets/en/_includes/code-examples/log_existing_artifact_link_collection.py
@@ -17,4 +17,4 @@
registry_model = run.use_artifact(artifact_or_name=artifact_name_registry)
# Download the model to a local directory
- local_model_path = registry_model.download()
+ local_model_path = registry_model.download()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_histogram_plot.mdx b/snippets/en/_includes/code-examples/log_histogram_plot.mdx
new file mode 100644
index 0000000000..ed50f20c8d
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_histogram_plot.mdx
@@ -0,0 +1,25 @@
+```python
+"""
+Log a histogram plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]] , columns=["", ""])
+
+ # Use the table to populate various custom charts
+ histogram = wandb.plot.histogram(table, value='', title='Histogram')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'histogram_1': histogram})
+```
diff --git a/snippets/en/_includes/code-examples/log_histogram_plot.py b/snippets/en/_includes/code-examples/log_histogram_plot.py
new file mode 100644
index 0000000000..b65522c411
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_histogram_plot.py
@@ -0,0 +1,23 @@
+"""
+Log a histogram plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]] , columns=["", ""])
+
+ # Use the table to populate various custom charts
+ histogram = wandb.plot.histogram(table, value='', title='Histogram')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'histogram_1': histogram})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_hyperparameter.py b/snippets/en/_includes/code-examples/log_hyperparameter.py
index 28caa33ac0..bd72386c30 100644
--- a/snippets/en/_includes/code-examples/log_hyperparameter.py
+++ b/snippets/en/_includes/code-examples/log_hyperparameter.py
@@ -9,4 +9,4 @@
with wandb.init(project="", config=config) as run:
# Training and logging code goes here
- pass
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_line_plot.mdx b/snippets/en/_includes/code-examples/log_line_plot.mdx
new file mode 100644
index 0000000000..701aeb17c8
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_line_plot.mdx
@@ -0,0 +1,27 @@
+```python
+"""
+Log a line plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+
+Column names must match the x and y parameters in the `wandb.plot.line()` plotting function.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]], columns=["", ""])
+
+ # Use the table to populate various custom charts
+ line_plot = wandb.plot.line(table, x='', y='', title='')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'': line_plot})
+```
diff --git a/snippets/en/_includes/code-examples/log_line_plot.py b/snippets/en/_includes/code-examples/log_line_plot.py
new file mode 100644
index 0000000000..e085ce1113
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_line_plot.py
@@ -0,0 +1,25 @@
+"""
+Log a line plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+
+Column names must match the x and y parameters in the `wandb.plot.line()` plotting function.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]], columns=["", ""])
+
+ # Use the table to populate various custom charts
+ line_plot = wandb.plot.line(table, x='', y='', title='')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'': line_plot})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_metric.py b/snippets/en/_includes/code-examples/log_metric.py
index ccd33c3cd7..6cadcb8700 100644
--- a/snippets/en/_includes/code-examples/log_metric.py
+++ b/snippets/en/_includes/code-examples/log_metric.py
@@ -5,4 +5,4 @@
# Training and logging code goes here
# Example of logging a metric
- run.log({"accuracy": 0.95})
+ run.log({"accuracy": 0.95})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_scatter_plot.mdx b/snippets/en/_includes/code-examples/log_scatter_plot.mdx
new file mode 100644
index 0000000000..c1a537ce66
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_scatter_plot.mdx
@@ -0,0 +1,27 @@
+```python
+"""
+Log a scatter plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+
+Column names must match the x and y parameters in the `wandb.plot.scatter()` plotting function.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]], columns=["", ""])
+
+ # Use the table to populate various custom charts
+ scatter = wandb.plot.scatter(table, x='', y='', title='')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'scatter_1': scatter})
+```
diff --git a/snippets/en/_includes/code-examples/log_scatter_plot.py b/snippets/en/_includes/code-examples/log_scatter_plot.py
new file mode 100644
index 0000000000..b7e1c89a05
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_scatter_plot.py
@@ -0,0 +1,25 @@
+"""
+Log a scatter plot to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to plot
+
+Pass a 2D row-oriented array of values to data (wandb.Table(data=)), with
+column names specified in the `columns` parameter.
+
+Column names must match the x and y parameters in the `wandb.plot.scatter()` plotting function.
+"""
+import wandb
+
+# Start a new run
+with wandb.init(entity="", project="") as run:
+
+ # Create a table with the columns to plot
+ table = wandb.Table(data=[[1, 2], [2, 3]], columns=["", ""])
+
+ # Use the table to populate various custom charts
+ scatter = wandb.plot.scatter(table, x='', y='', title='')
+
+ # Log custom tables, which will show up in customizable charts in the UI
+ run.log({'scatter_1': scatter})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_summary_metric.mdx b/snippets/en/_includes/code-examples/log_summary_metric.mdx
new file mode 100644
index 0000000000..c3d28ae3a4
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_summary_metric.mdx
@@ -0,0 +1,11 @@
+```python
+"""
+Explicitly log a summary metric to W&B.
+"""
+import wandb
+import random
+
+with wandb.init(project="") as run:
+ # Log a custom summary metric with a random integer value between 1 and 10
+ run.summary[""] = random.randint(1, 10)
+```
diff --git a/snippets/en/_includes/code-examples/log_summary_metric.py b/snippets/en/_includes/code-examples/log_summary_metric.py
new file mode 100644
index 0000000000..9dd4da8cb1
--- /dev/null
+++ b/snippets/en/_includes/code-examples/log_summary_metric.py
@@ -0,0 +1,9 @@
+"""
+Explicitly log a summary metric to W&B.
+"""
+import wandb
+import random
+
+with wandb.init(project="") as run:
+ # Log a custom summary metric with a random integer value between 1 and 10
+ run.summary[""] = random.randint(1, 10)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/log_table.mdx b/snippets/en/_includes/code-examples/log_table.mdx
index 1944e3005c..8d87f9d75c 100644
--- a/snippets/en/_includes/code-examples/log_table.mdx
+++ b/snippets/en/_includes/code-examples/log_table.mdx
@@ -1,18 +1,22 @@
```python
"""
Log a table to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to log
"""
import wandb
# Create a table object with two columns and two rows of data
my_table = wandb.Table(
- columns=["a", "b"],
- data=[["a1", "b1"], ["a2", "b2"]],
+ columns=["", ""],
+ data=[[1, 2], [2, 3]],
log_mode=""
)
# Start a new run
-with wandb.init(project="") as run:
+with wandb.init(entity="", project="") as run:
# Log the table to W&B
run.log({"": my_table})
```
diff --git a/snippets/en/_includes/code-examples/log_table.py b/snippets/en/_includes/code-examples/log_table.py
index 667895d280..0338fff03e 100644
--- a/snippets/en/_includes/code-examples/log_table.py
+++ b/snippets/en/_includes/code-examples/log_table.py
@@ -1,16 +1,20 @@
"""
Log a table to W&B.
+
+Replace:
+- values enclosed in angle brackets with your own
+- [[1, 2], [2, 3]] in wandb.Table(data=) with your own 2D row-oriented array of values to log
"""
import wandb
# Create a table object with two columns and two rows of data
my_table = wandb.Table(
- columns=["a", "b"],
- data=[["a1", "b1"], ["a2", "b2"]],
+ columns=["", ""],
+ data=[[1, 2], [2, 3]],
log_mode=""
)
# Start a new run
-with wandb.init(project="") as run:
+with wandb.init(entity="", project="") as run:
# Log the table to W&B
- run.log({"": my_table})
+ run.log({"": my_table})
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_add_annotation.py b/snippets/en/_includes/code-examples/registry_add_annotation.py
index 38d76be1f7..f0f8444fd5 100644
--- a/snippets/en/_includes/code-examples/registry_add_annotation.py
+++ b/snippets/en/_includes/code-examples/registry_add_annotation.py
@@ -24,4 +24,4 @@
collection.description = ""
# Save the updated collection
-collection.save()
+collection.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_collection_create.py b/snippets/en/_includes/code-examples/registry_collection_create.py
index 0b5d94fd46..6b81f6b08d 100644
--- a/snippets/en/_includes/code-examples/registry_collection_create.py
+++ b/snippets/en/_includes/code-examples/registry_collection_create.py
@@ -14,4 +14,4 @@
with wandb.init(entity = "", project = "") as run:
# Link the artifact to a collection. If the collection does not exist, W&B creates it.
- run.link_artifact(artifact = artifact, target_path = registry_path)
+ run.link_artifact(artifact = artifact, target_path = registry_path)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_collection_tags_add.py b/snippets/en/_includes/code-examples/registry_collection_tags_add.py
index bf002a151a..211374a9d4 100644
--- a/snippets/en/_includes/code-examples/registry_collection_tags_add.py
+++ b/snippets/en/_includes/code-examples/registry_collection_tags_add.py
@@ -18,4 +18,4 @@
)
collection.tags = [""]
-collection.save()
+collection.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_collection_tags_remove.py b/snippets/en/_includes/code-examples/registry_collection_tags_remove.py
index 0666feffa5..1d16f7ac94 100644
--- a/snippets/en/_includes/code-examples/registry_collection_tags_remove.py
+++ b/snippets/en/_includes/code-examples/registry_collection_tags_remove.py
@@ -18,4 +18,4 @@
)
collection.tags.remove("")
-collection.save()
+collection.save()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_create.py b/snippets/en/_includes/code-examples/registry_create.py
index 1974da798e..824ead3467 100644
--- a/snippets/en/_includes/code-examples/registry_create.py
+++ b/snippets/en/_includes/code-examples/registry_create.py
@@ -10,4 +10,4 @@
registry = api.create_registry(
name="",
visibility="", # e.g., "public" or "private"
-)
+)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_delete.py b/snippets/en/_includes/code-examples/registry_delete.py
index 253194325f..04a1a1177e 100644
--- a/snippets/en/_includes/code-examples/registry_delete.py
+++ b/snippets/en/_includes/code-examples/registry_delete.py
@@ -17,4 +17,4 @@
fetched_registry = api.registry("")
# Deleting a registry
-fetched_registry.delete()
+fetched_registry.delete()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_link_artifact_existing.py b/snippets/en/_includes/code-examples/registry_link_artifact_existing.py
index e54c06cf8c..e5d81d91a6 100644
--- a/snippets/en/_includes/code-examples/registry_link_artifact_existing.py
+++ b/snippets/en/_includes/code-examples/registry_link_artifact_existing.py
@@ -15,4 +15,4 @@
# Initialize a run
with wandb.init(entity = "", project = "") as run:
# Link the artifact to a collection. If the collection does not exist, W&B creates it.
- run.link_artifact(artifact = artifact, target_path = target_path)
+ run.link_artifact(artifact = artifact, target_path = target_path)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/registry_use_linked_artifact.py b/snippets/en/_includes/code-examples/registry_use_linked_artifact.py
index 2f193e012e..2f02616ad6 100644
--- a/snippets/en/_includes/code-examples/registry_use_linked_artifact.py
+++ b/snippets/en/_includes/code-examples/registry_use_linked_artifact.py
@@ -16,4 +16,4 @@
api = wandb.Api()
# Retrieve the artifact from the specified registry collection and version
-artifact = api.artifact(name = artifact_name)
+artifact = api.artifact(name = artifact_name)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/resume_run.mdx b/snippets/en/_includes/code-examples/resume_run.mdx
new file mode 100644
index 0000000000..965312cbd3
--- /dev/null
+++ b/snippets/en/_includes/code-examples/resume_run.mdx
@@ -0,0 +1,14 @@
+```python
+"""
+Set resume behaviour for a run if it is paused, stops, or fails.
+
+This is useful for long-running experiments that may be interrupted. See
+reference documentation for wandb.init(resume=) for a list of all resume options.
+"""
+import wandb
+
+# Initialize a W&B run with resume behavior
+with wandb.init(project="", resume="") as run:
+ # Training and logging code goes here
+ pass
+```
diff --git a/snippets/en/_includes/code-examples/resume_run.py b/snippets/en/_includes/code-examples/resume_run.py
new file mode 100644
index 0000000000..dfb7dfa323
--- /dev/null
+++ b/snippets/en/_includes/code-examples/resume_run.py
@@ -0,0 +1,12 @@
+"""
+Set resume behaviour for a run if it is paused, stops, or fails.
+
+This is useful for long-running experiments that may be interrupted. See
+reference documentation for wandb.init(resume=) for a list of all resume options.
+"""
+import wandb
+
+# Initialize a W&B run with resume behavior
+with wandb.init(project="", resume="") as run:
+ # Training and logging code goes here
+ pass
diff --git a/snippets/en/_includes/code-examples/rewind_run.mdx b/snippets/en/_includes/code-examples/rewind_run.mdx
new file mode 100644
index 0000000000..2f3bc82684
--- /dev/null
+++ b/snippets/en/_includes/code-examples/rewind_run.mdx
@@ -0,0 +1,22 @@
+```python
+"""
+Rewind a run to modify the history of a run.
+
+Specify the run ID and step to rewind to with the `resume_from` parameter in `wandb.init()`.
+"""
+import wandb
+import math
+
+# Initialize a run and log some metrics
+with wandb.init(project="", entity="") as run:
+ # Training and logging code goes here
+ pass
+
+run_ID = "" # Replace with run ID of the original run
+step = int("") # Specify the step to rewind to
+
+# Start a new run that resumes from the specified step of the original run
+with wandb.init(project="", entity="", resume_from=f"{run_ID}?_step={step}") as run:
+ # Training and logging code goes here
+ pass
+```
diff --git a/snippets/en/_includes/code-examples/rewind_run.py b/snippets/en/_includes/code-examples/rewind_run.py
new file mode 100644
index 0000000000..2bf63f9272
--- /dev/null
+++ b/snippets/en/_includes/code-examples/rewind_run.py
@@ -0,0 +1,20 @@
+"""
+Rewind a run to modify the history of a run.
+
+Specify the run ID and step to rewind to with the `resume_from` parameter in `wandb.init()`.
+"""
+import wandb
+import math
+
+# Initialize a run and log some metrics
+with wandb.init(project="", entity="") as run:
+ # Training and logging code goes here
+ pass
+
+run_ID = "" # Replace with run ID of the original run
+step = int("") # Specify the step to rewind to
+
+# Start a new run that resumes from the specified step of the original run
+with wandb.init(project="", entity="", resume_from=f"{run_ID}?_step={step}") as run:
+ # Training and logging code goes here
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/run_fork.mdx b/snippets/en/_includes/code-examples/run_fork.mdx
index 81dc1cff6b..f8be1e0da0 100644
--- a/snippets/en/_includes/code-examples/run_fork.mdx
+++ b/snippets/en/_includes/code-examples/run_fork.mdx
@@ -8,7 +8,7 @@ with wandb.init(project="", entity="") as original_run:
# Training and logging code goes here.
pass
-# Fork the run from a specific step
+# Fork the run from a specific step. In this example, we fork from step 200. You can adjust the step number as needed.
with wandb.init(project="",entity="", fork_from=f"{original_run.id}?_step=200") as forked_run:
# Training and logging code goes here.
pass
diff --git a/snippets/en/_includes/code-examples/run_fork.py b/snippets/en/_includes/code-examples/run_fork.py
index 2e1e596b49..3dea07cf49 100644
--- a/snippets/en/_includes/code-examples/run_fork.py
+++ b/snippets/en/_includes/code-examples/run_fork.py
@@ -7,7 +7,7 @@
# Training and logging code goes here.
pass
-# Fork the run from a specific step
+# Fork the run from a specific step. In this example, we fork from step 200. You can adjust the step number as needed.
with wandb.init(project="",entity="", fork_from=f"{original_run.id}?_step=200") as forked_run:
# Training and logging code goes here.
- pass
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/run_init.py b/snippets/en/_includes/code-examples/run_init.py
index ef1a72d588..4fbad1253a 100644
--- a/snippets/en/_includes/code-examples/run_init.py
+++ b/snippets/en/_includes/code-examples/run_init.py
@@ -10,4 +10,4 @@
# Note the usage of `with` statement to ensure proper resource management.
with wandb.init(project="") as run:
# Training and logging code goes here
- pass
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/runs_add_tags.mdx b/snippets/en/_includes/code-examples/runs_add_tags.mdx
new file mode 100644
index 0000000000..1c0c3160ca
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_add_tags.mdx
@@ -0,0 +1,10 @@
+```python
+"""
+Add one or more tags to a run.
+"""
+import wandb
+
+with wandb.init(entity="", project="", tags=["", ""]) as run:
+ # Training and logging code goes here
+ pass
+```
diff --git a/snippets/en/_includes/code-examples/runs_add_tags.py b/snippets/en/_includes/code-examples/runs_add_tags.py
new file mode 100644
index 0000000000..2d8503c7e5
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_add_tags.py
@@ -0,0 +1,8 @@
+"""
+Add one or more tags to a run.
+"""
+import wandb
+
+with wandb.init(entity="", project="", tags=["", ""]) as run:
+ # Training and logging code goes here
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/runs_group.mdx b/snippets/en/_includes/code-examples/runs_group.mdx
new file mode 100644
index 0000000000..00b7cf44e5
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_group.mdx
@@ -0,0 +1,20 @@
+```python
+"""
+Add one or more runs to a group.
+
+Pass the name of your group as an argument to the `group` parameter when you
+initialize a run with `wandb.init(group="")`.
+"""
+import wandb
+
+entity = ""
+project = ""
+
+# The following creates 3 groups of runs, with 3 runs in each group.
+for group in ["", "", ""]: # Replace with your desired group names
+ # Simulate creating three runs for each group.
+ for i in range(3):
+ with wandb.init(entity=entity, project=project, group=group, name=f"{group}_run_{i}") as run:
+ # Training and logging code goes here
+ pass
+```
diff --git a/snippets/en/_includes/code-examples/runs_group.py b/snippets/en/_includes/code-examples/runs_group.py
new file mode 100644
index 0000000000..86017974cb
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_group.py
@@ -0,0 +1,18 @@
+"""
+Add one or more runs to a group.
+
+Pass the name of your group as an argument to the `group` parameter when you
+initialize a run with `wandb.init(group="")`.
+"""
+import wandb
+
+entity = ""
+project = ""
+
+# The following creates 3 groups of runs, with 3 runs in each group.
+for group in ["", "", ""]: # Replace with your desired group names
+ # Simulate creating three runs for each group.
+ for i in range(3):
+ with wandb.init(entity=entity, project=project, group=group, name=f"{group}_run_{i}") as run:
+ # Training and logging code goes here
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/runs_organize_by_type.mdx b/snippets/en/_includes/code-examples/runs_organize_by_type.mdx
new file mode 100644
index 0000000000..386f10b47a
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_organize_by_type.mdx
@@ -0,0 +1,19 @@
+```python
+"""
+Organize runs by their job type.
+
+Add a job type to a run by passing the `job_type` parameter to `wandb.init(job_type="")`.
+"""
+import wandb
+
+entity = ""
+project = ""
+
+# Creates runs and organizes them by job type.
+for job_type in ["", ""]: # Replace with job type names
+ # Simulate creating two runs for each job type.
+ for i in range(2):
+ with wandb.init(entity=entity, project=project, job_type=job_type, name=f"{job_type}_run_{i}") as run:
+ # Training and logging code goes here
+ pass
+```
diff --git a/snippets/en/_includes/code-examples/runs_organize_by_type.py b/snippets/en/_includes/code-examples/runs_organize_by_type.py
new file mode 100644
index 0000000000..5d937e768c
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_organize_by_type.py
@@ -0,0 +1,17 @@
+"""
+Organize runs by their job type.
+
+Add a job type to a run by passing the `job_type` parameter to `wandb.init(job_type="")`.
+"""
+import wandb
+
+entity = ""
+project = ""
+
+# Creates runs and organizes them by job type.
+for job_type in ["", ""]: # Replace with job type names
+ # Simulate creating two runs for each job type.
+ for i in range(2):
+ with wandb.init(entity=entity, project=project, job_type=job_type, name=f"{job_type}_run_{i}") as run:
+ # Training and logging code goes here
+ pass
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/runs_update_tag.mdx b/snippets/en/_includes/code-examples/runs_update_tag.mdx
new file mode 100644
index 0000000000..f57c99eaf5
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_update_tag.mdx
@@ -0,0 +1,16 @@
+```python
+"""
+Add one or more tags to an active run.
+
+A run object's `tags` property is a tuple. To add a new tag to an existing run,
+update the `tags` property with a new tuple that includes the existing tags and the new tag(s).
+"""
+
+import wandb
+
+with wandb.init(entity="", project="", tags=["", ""]) as run:
+ # Training and logging code goes here
+
+ # Add a new tag to the existing tags by creating a new tuple that includes the existing tags and the new tag.
+ run.tags += ("",)
+```
diff --git a/snippets/en/_includes/code-examples/runs_update_tag.py b/snippets/en/_includes/code-examples/runs_update_tag.py
new file mode 100644
index 0000000000..93b2b09d99
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_update_tag.py
@@ -0,0 +1,14 @@
+"""
+Add one or more tags to an active run.
+
+A run object's `tags` property is a tuple. To add a new tag to an existing run,
+update the `tags` property with a new tuple that includes the existing tags and the new tag(s).
+"""
+
+import wandb
+
+with wandb.init(entity="", project="", tags=["", ""]) as run:
+ # Training and logging code goes here
+
+ # Add a new tag to the existing tags by creating a new tuple that includes the existing tags and the new tag.
+ run.tags += ("",)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/runs_update_tag_public_api.mdx b/snippets/en/_includes/code-examples/runs_update_tag_public_api.mdx
new file mode 100644
index 0000000000..8176eff714
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_update_tag_public_api.mdx
@@ -0,0 +1,23 @@
+```python
+"""
+Add one or more tags to previously saved runs.
+
+Use the Public API to update tags on stored data after the run has finished or
+when you are working outside the run process.
+
+To add a new tag to a run, update the "tags"
+property with a new list that includes the existing tags and the new tag(s).
+The run's path consists of entity/project/run_id
+After updating the tags, call the run's `update()` method to save the changes.
+"""
+import wandb
+
+entity = ""
+project = ""
+run_id = "" # Replace with the ID of the run you want to update
+
+# Path consists of entity/project/run_id
+with wandb.Api().run(f"{entity}/{project}/{run_id}") as run:
+ run.tags.append("")
+ run.update()
+```
diff --git a/snippets/en/_includes/code-examples/runs_update_tag_public_api.py b/snippets/en/_includes/code-examples/runs_update_tag_public_api.py
new file mode 100644
index 0000000000..0187de462f
--- /dev/null
+++ b/snippets/en/_includes/code-examples/runs_update_tag_public_api.py
@@ -0,0 +1,21 @@
+"""
+Add one or more tags to previously saved runs.
+
+Use the Public API to update tags on stored data after the run has finished or
+when you are working outside the run process.
+
+To add a new tag to a run, update the "tags"
+property with a new list that includes the existing tags and the new tag(s).
+The run's path consists of entity/project/run_id
+After updating the tags, call the run's `update()` method to save the changes.
+"""
+import wandb
+
+entity = ""
+project = ""
+run_id = "" # Replace with the ID of the run you want to update
+
+# Path consists of entity/project/run_id
+with wandb.Api().run(f"{entity}/{project}/{run_id}") as run:
+ run.tags.append("")
+ run.update()
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/sweep_config.mdx b/snippets/en/_includes/code-examples/sweep_config.mdx
new file mode 100644
index 0000000000..3710483ad9
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_config.mdx
@@ -0,0 +1,103 @@
+```python
+"""
+Example sweep configuration for W&B Sweeps.
+
+sweep_configuration is an example of a single nested sweep configuration
+sweep_configuration_nested is an example of a double nested sweep configuration
+
+Replace:
+- values enclosed in angle brackets with your own
+- integer values, float values, and lists of values with your own hyperparameter search space
+"""
+
+sweep_configuration = {
+ "program": "",
+ "name": "",
+ "method": "",
+ "metric": {
+ "name": "",
+ "goal": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "search_constraint_1": 0.0001,
+ "search_constraint_2": 0.1
+ },
+ "hyperparameter_2": {
+ "values": [16, 32, 64]
+ },
+ "hyperparameter_3": {
+ "values": [5, 10, 15]
+ },
+ "hyperparameter_4": {
+ "values": ["value_1", "value_2"]
+ },
+ },
+}
+
+## Double nested sweep configuration example
+sweep_configuration_nested = {
+ "program": "",
+ "name": "",
+ "method": "",
+ "metric": {
+ "name": "",
+ "goal": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "values": ["", ""]
+ },
+ "hyperparameter_2": {
+ "values": [128, 256, 512]
+ },
+ "hyperparameter_3": {
+ "values": [0.3, 0.4, 0.5]
+ },
+ "hyperparameter_4": {
+ "value": 1
+ },
+ "hyperparameter_5": {
+ "distribution": "",
+ "search_constraint_1": 0,
+ "search_constraint_2": 0.1
+ },
+ "nested_category_1": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.0,
+ "search_constraint_2": 0.9
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.0001, 0.0005, 0.001]
+ }
+ }
+ },
+ "nested_category_2": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.0,
+ "search_constraint_2": 0.9
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.1, 0.2, 0.3]
+ }
+ }
+ },
+ "nested_category_3": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.5,
+ "search_constraint_2": 0.7
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.2, 0.3, 0.4]
+ }
+ }
+ }
+ }
+}
+```
diff --git a/snippets/en/_includes/code-examples/sweep_config.py b/snippets/en/_includes/code-examples/sweep_config.py
new file mode 100644
index 0000000000..1a0e9d54c2
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_config.py
@@ -0,0 +1,101 @@
+"""
+Example sweep configuration for W&B Sweeps.
+
+sweep_configuration is an example of a single nested sweep configuration
+sweep_configuration_nested is an example of a double nested sweep configuration
+
+Replace:
+- values enclosed in angle brackets with your own
+- integer values, float values, and lists of values with your own hyperparameter search space
+"""
+
+sweep_configuration = {
+ "program": "",
+ "name": "",
+ "method": "",
+ "metric": {
+ "name": "",
+ "goal": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "search_constraint_1": 0.0001,
+ "search_constraint_2": 0.1
+ },
+ "hyperparameter_2": {
+ "values": [16, 32, 64]
+ },
+ "hyperparameter_3": {
+ "values": [5, 10, 15]
+ },
+ "hyperparameter_4": {
+ "values": ["value_1", "value_2"]
+ },
+ },
+}
+
+## Double nested sweep configuration example
+sweep_configuration_nested = {
+ "program": "",
+ "name": "",
+ "method": "",
+ "metric": {
+ "name": "",
+ "goal": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "values": ["", ""]
+ },
+ "hyperparameter_2": {
+ "values": [128, 256, 512]
+ },
+ "hyperparameter_3": {
+ "values": [0.3, 0.4, 0.5]
+ },
+ "hyperparameter_4": {
+ "value": 1
+ },
+ "hyperparameter_5": {
+ "distribution": "",
+ "search_constraint_1": 0,
+ "search_constraint_2": 0.1
+ },
+ "nested_category_1": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.0,
+ "search_constraint_2": 0.9
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.0001, 0.0005, 0.001]
+ }
+ }
+ },
+ "nested_category_2": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.0,
+ "search_constraint_2": 0.9
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.1, 0.2, 0.3]
+ }
+ }
+ },
+ "nested_category_3": {
+ "parameters": {
+ "nested_hyperparameter_1": {
+ "distribution": "",
+ "search_constraint_1": 0.5,
+ "search_constraint_2": 0.7
+ },
+ "nested_hyperparameter_2": {
+ "values": [0.2, 0.3, 0.4]
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/sweep_create.mdx b/snippets/en/_includes/code-examples/sweep_create.mdx
new file mode 100644
index 0000000000..a783b5743a
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_create.mdx
@@ -0,0 +1,73 @@
+```python
+"""
+Define a sweep config, initialize, and start W&B Sweep.
+
+sweep_configuration is a single nested sweep configuration. See sweep_config.py
+for an example of a double nested sweep configuration.
+"""
+import wandb
+import numpy as np
+import random
+import argparse
+
+def train_one_epoch(epoch, lr, batch_size):
+ acc = 0.25 + ((epoch / 30) + (random.random() / 10))
+ loss = 0.2 + (1 - ((epoch - 1) / 10 + random.random() / 5))
+ return acc, loss
+
+def evaluate_one_epoch(epoch):
+ acc = 0.1 + ((epoch / 20) + (random.random() / 10))
+ loss = 0.25 + (1 - ((epoch - 1) / 10 + random.random() / 6))
+ return acc, loss
+
+def main(args=None):
+ # When called by sweep agent, args will be None,
+ # so we use the project from sweep config
+ project = args.project if args else None
+
+ with wandb.init(project=project) as run:
+ # Fetches the hyperparameter values from `wandb.Run.config` object
+ lr = run.config["lr"]
+ batch_size = run.config["batch_size"]
+ epochs = run.config["epochs"]
+
+ # Execute the training loop and log the performance values to W&B
+ for epoch in np.arange(1, epochs):
+ train_acc, train_loss = train_one_epoch(epoch, lr, batch_size)
+ val_acc, val_loss = evaluate_one_epoch(epoch)
+ run.log(
+ {
+ "epoch": epoch,
+ "train_acc": train_acc,
+ "train_loss": train_loss,
+ "val_acc": val_acc, # Metric optimized
+ "val_loss": val_loss,
+ }
+ )
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--project", type=str, default="sweep-example", help="W&B project name")
+ args = parser.parse_args()
+
+ # Define a sweep config dictionary
+ sweep_configuration = {
+ "method": "random",
+ "name": "sweep",
+ "metric": {
+ "goal": "maximize",
+ "name": "val_acc"
+ },
+ "parameters": {
+ "batch_size": {"values": [16, 32, 64]},
+ "epochs": {"values": [5, 10, 15]},
+ "lr": {"max": 0.1, "min": 0.0001},
+ },
+ }
+
+ # Initialize the sweep by passing in the config dictionary
+ sweep_id = wandb.sweep(sweep=sweep_configuration, project=args.project)
+
+ # Start the sweep job
+ wandb.agent(sweep_id, function=main, count=2)
+```
diff --git a/snippets/en/_includes/code-examples/sweep_create.py b/snippets/en/_includes/code-examples/sweep_create.py
new file mode 100644
index 0000000000..9f9558918b
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_create.py
@@ -0,0 +1,71 @@
+"""
+Define a sweep config, initialize, and start W&B Sweep.
+
+sweep_configuration is a single nested sweep configuration. See sweep_config.py
+for an example of a double nested sweep configuration.
+"""
+import wandb
+import numpy as np
+import random
+import argparse
+
+def train_one_epoch(epoch, lr, batch_size):
+ acc = 0.25 + ((epoch / 30) + (random.random() / 10))
+ loss = 0.2 + (1 - ((epoch - 1) / 10 + random.random() / 5))
+ return acc, loss
+
+def evaluate_one_epoch(epoch):
+ acc = 0.1 + ((epoch / 20) + (random.random() / 10))
+ loss = 0.25 + (1 - ((epoch - 1) / 10 + random.random() / 6))
+ return acc, loss
+
+def main(args=None):
+ # When called by sweep agent, args will be None,
+ # so we use the project from sweep config
+ project = args.project if args else None
+
+ with wandb.init(project=project) as run:
+ # Fetches the hyperparameter values from `wandb.Run.config` object
+ lr = run.config["lr"]
+ batch_size = run.config["batch_size"]
+ epochs = run.config["epochs"]
+
+ # Execute the training loop and log the performance values to W&B
+ for epoch in np.arange(1, epochs):
+ train_acc, train_loss = train_one_epoch(epoch, lr, batch_size)
+ val_acc, val_loss = evaluate_one_epoch(epoch)
+ run.log(
+ {
+ "epoch": epoch,
+ "train_acc": train_acc,
+ "train_loss": train_loss,
+ "val_acc": val_acc, # Metric optimized
+ "val_loss": val_loss,
+ }
+ )
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--project", type=str, default="sweep-example", help="W&B project name")
+ args = parser.parse_args()
+
+ # Define a sweep config dictionary
+ sweep_configuration = {
+ "method": "random",
+ "name": "sweep",
+ "metric": {
+ "goal": "maximize",
+ "name": "val_acc"
+ },
+ "parameters": {
+ "batch_size": {"values": [16, 32, 64]},
+ "epochs": {"values": [5, 10, 15]},
+ "lr": {"max": 0.1, "min": 0.0001},
+ },
+ }
+
+ # Initialize the sweep by passing in the config dictionary
+ sweep_id = wandb.sweep(sweep=sweep_configuration, project=args.project)
+
+ # Start the sweep job
+ wandb.agent(sweep_id, function=main, count=2)
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/sweep_initialize.mdx b/snippets/en/_includes/code-examples/sweep_initialize.mdx
new file mode 100644
index 0000000000..14ea6e380d
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_initialize.mdx
@@ -0,0 +1,37 @@
+```python
+"""
+Initialize a W&B Sweep.
+
+Replace:
+- values enclosed in angle brackets with your own
+- sweep_configuration with your own sweep configuration dictionary. See
+ sweep_config.py for examples of single nested and double nested sweep
+ configurations.
+"""
+
+import wandb
+
+# Example sweep configuration
+sweep_configuration = {
+ "method": "",
+ "name": "",
+ "metric": {
+ "goal": "",
+ "name": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "values": [16, 32, 64]
+ },
+ "hyperparameter_2": {
+ "values": [5, 10, 15]
+ },
+ "hyperparameter_3": {
+ "search_constraint_1": 0.1,
+ "search_constraint_2": 0.0001
+ },
+ },
+}
+
+sweep_id = wandb.sweep(sweep=sweep_configuration, project="")
+```
diff --git a/snippets/en/_includes/code-examples/sweep_initialize.py b/snippets/en/_includes/code-examples/sweep_initialize.py
new file mode 100644
index 0000000000..e1f1c42dbe
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_initialize.py
@@ -0,0 +1,35 @@
+"""
+Initialize a W&B Sweep.
+
+Replace:
+- values enclosed in angle brackets with your own
+- sweep_configuration with your own sweep configuration dictionary. See
+ sweep_config.py for examples of single nested and double nested sweep
+ configurations.
+"""
+
+import wandb
+
+# Example sweep configuration
+sweep_configuration = {
+ "method": "",
+ "name": "",
+ "metric": {
+ "goal": "",
+ "name": ""
+ },
+ "parameters": {
+ "hyperparameter_1": {
+ "values": [16, 32, 64]
+ },
+ "hyperparameter_2": {
+ "values": [5, 10, 15]
+ },
+ "hyperparameter_3": {
+ "search_constraint_1": 0.1,
+ "search_constraint_2": 0.0001
+ },
+ },
+}
+
+sweep_id = wandb.sweep(sweep=sweep_configuration, project="")
\ No newline at end of file
diff --git a/snippets/en/_includes/code-examples/sweep_start.mdx b/snippets/en/_includes/code-examples/sweep_start.mdx
new file mode 100644
index 0000000000..e8692f8abc
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_start.mdx
@@ -0,0 +1,17 @@
+```python
+"""
+Start a sweep job to run a sweep agent.
+
+Replace:
+- values enclosed in angle brackets with your own
+- sweep_id with the ID of your sweep, which is returned when you initialize a sweep.
+ See sweep_initialize.py for an example of how to initialize a sweep and get
+ the sweep_id.
+- count with the number of runs you want to execute in your sweep
+"""
+
+import wandb
+
+sweep_id, count = "", 10
+wandb.agent(sweep_id, count=count)
+```
diff --git a/snippets/en/_includes/code-examples/sweep_start.py b/snippets/en/_includes/code-examples/sweep_start.py
new file mode 100644
index 0000000000..b6f57bcf83
--- /dev/null
+++ b/snippets/en/_includes/code-examples/sweep_start.py
@@ -0,0 +1,15 @@
+"""
+Start a sweep job to run a sweep agent.
+
+Replace:
+- values enclosed in angle brackets with your own
+- sweep_id with the ID of your sweep, which is returned when you initialize a sweep.
+ See sweep_initialize.py for an example of how to initialize a sweep and get
+ the sweep_id.
+- count with the number of runs you want to execute in your sweep
+"""
+
+import wandb
+
+sweep_id, count = "", 10
+wandb.agent(sweep_id, count=count)
\ No newline at end of file