Skip to content

Instantly share code, notes, and snippets.

@heaths
Created April 3, 2023 21:32
Show Gist options
  • Save heaths/d0811074857421a6ee2f86fb93bb7582 to your computer and use it in GitHub Desktop.
Save heaths/d0811074857421a6ee2f86fb93bb7582 to your computer and use it in GitHub Desktop.
Simple script to clean up test projects for CLU and QA
azure-identity==1.12.0
azure-ai-language-conversations==1.0.0
azure-ai-language-questionanswering==1.1.0
#!/bin/env python3
import argparse
import os
from azure.core.credentials import AzureKeyCredential
def rm_clu_projects(force):
from azure.ai.language.conversations.authoring import ConversationAuthoringClient
endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"]
key = os.environ["AZURE_CONVERSATIONS_KEY"]
client = ConversationAuthoringClient(endpoint, AzureKeyCredential(key))
for project in client.list_projects():
project_name = project["projectName"]
if project_name.startswith("TestProject") or project_name.startswith("net-conv-") or project_name.startswith("test_project"):
if force:
print(f"Deleting {project_name}")
client.begin_delete_project(project_name)
else:
print(f"Would delete {project_name}")
def rm_qa_projects(force):
from azure.ai.language.questionanswering.authoring import AuthoringClient
endpoint = os.environ["AZURE_QUESTIONANSWERING_ENDPOINT"]
key = os.environ["AZURE_QUESTIONANSWERING_KEY"]
client = AuthoringClient(endpoint, AzureKeyCredential(key))
for project in client.list_projects():
project_name = project["projectName"]
if project_name.startswith("TestProject") or project_name.startswith("net-conv-") or project_name.startswith("test_project"):
if force:
print(f"Deleting {project_name}")
client.begin_delete_project(project_name)
else:
print(f"Would delete {project_name}")
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Delete CLU and QA projects')
parser.add_argument('--force', action=argparse.BooleanOptionalAction)
args = parser.parse_args()
rm_clu_projects(args.force)
rm_qa_projects(args.force)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment