Skip to content

Instantly share code, notes, and snippets.

@jaanli
Created February 21, 2024 20:04
Show Gist options
  • Save jaanli/7bca5425a0f21d1e27cd618e9692460a to your computer and use it in GitHub Desktop.
Save jaanli/7bca5425a0f21d1e27cd618e9692460a to your computer and use it in GitHub Desktop.
Delete Weights and Biases (wandb.ai) projects automatically. Use with `WANDB_EMAIL="myemail" WANDB_PASSWORD="mypassword" npx playwright test automatically_delete_wandb.ai_projects.test.js
import { test, expect } from '@playwright/test';
test('Delete W&B Projects', async ({ page }) => {
// Navigate to the login page and log in
await page.goto('https://wandb.ai/login');
await page.getByPlaceholder('name@work-email.com').fill(process.env.WANDB_EMAIL);
await page.getByPlaceholder('your password').fill(process.env.WANDB_PASSWORD);
await page.click('text=Log In');
// Wait for navigation to ensure login is complete
await page.waitForNavigation();
// Assuming the script correctly navigates to the projects page after login
await page.goto('https://wandb.ai/myorg/projects');
const projectNames = [
"project1",
"project2",
];
for (const projectName of projectNames) {
try {
// Navigate directly to the project page to avoid having to find it in the list
await page.goto(`https://wandb.ai/myorg/${projectName}`);
// Right-click might not be necessary if the delete option is directly accessible
await page.getByText('Settings').click();
await page.getByText('Danger Zone').click();
await page.getByText('Delete this project').click();
// Fill the confirmation input with the project name, adapt selector as needed
await page.getByPlaceholder('Confirm project name').fill(projectName);
await page.getByRole('button', { name: 'Delete' }).click();
// Wait for confirmation that the project has been deleted
// This might require adapting based on the actual page behavior after deletion
await page.waitForSelector('text=Project deleted', { timeout: 5000 });
} catch (error) {
console.log(`Error deleting project ${projectName}:`, error.message);
// Break out of the loop on error to avoid further errors
break;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment