How to manage wandb projects
Quick answer
Use the
wandb Python SDK to create and manage projects by initializing runs with specific project names. Organize experiments by grouping runs under these projects and use the wandb.Api() to list, update, or delete projects programmatically.PREREQUISITES
Python 3.8+pip install wandbwandb account (free tier available)wandb login or set WANDB_API_KEY environment variable
Setup
Install the wandb Python package and authenticate your account to start managing projects.
pip install wandb
wandb login Step by step
This example shows how to create a new project by initializing a run with a project name, log metrics, and then use the wandb.Api() to list all projects in your account.
import os
import wandb
# Initialize a new run in a specific project
run = wandb.init(project="my-sample-project", entity="your-wandb-username")
# Log some metrics
for epoch in range(3):
wandb.log({"epoch": epoch, "accuracy": 0.8 + epoch * 0.05})
run.finish()
# Use wandb API to list projects
api = wandb.Api()
projects = api.projects(entity="your-wandb-username")
print("Projects in your account:")
for project in projects:
print(f"- {project.name} (id: {project.id})") output
Projects in your account: - my-sample-project (id: 1234567) - another-project (id: 7654321)
Common variations
You can manage projects asynchronously or use the wandb.Api() to update project descriptions or delete projects. Also, you can organize runs by tags or groups within projects for better experiment management.
import wandb
api = wandb.Api()
# Update project description
project = api.project(entity="your-wandb-username", project="my-sample-project")
project.update(description="Updated project description for clarity.")
# Delete a project (use with caution)
# api.delete_project(entity="your-wandb-username", project="my-sample-project") Troubleshooting
- If you see authentication errors, ensure your
WANDB_API_KEYis set correctly or runwandb login. - If projects do not appear, verify the
entityparameter matches your wandb username or team name. - For permission issues, check your wandb account roles and access rights.
Key Takeaways
- Use
wandb.init(project=...)to create and organize runs under projects. - Leverage
wandb.Api()to programmatically list, update, or delete projects. - Always authenticate properly with
wandb loginorWANDB_API_KEYenvironment variable. - Organize experiments further with tags and groups inside projects for clarity.
- Check entity names carefully to avoid missing projects or permission errors.