Skip to main content
Version: v0.64.0

Delete project

This page describes how to delete or batch delete projects with the H2O MLOps Python client.

Constants

  • MLOPS_API_URL: The URL endpoint for the MLOps Gateway component.
  • TOKEN_ENDPOINT_URL: The token endpoint URL of the Identity Provider (IDP). A Keycloak example is provided.
  • REFRESH_TOKEN: The user's refresh token for authentication.
  • CLIENT_ID: The client ID for authentication.
  • PROJECT_NAME: The name of the project that you want to delete.

Batch deletion-specific constants

  • PROJECTS_TO_BE_DELETED: List of project names you want to delete.

Functions

  • _get_project_id(projects): Returns the ID of the project specified in PROJECT_NAME.

Workflow

  1. Initialize the token provider using the provided refresh token.
  2. Set up the H2O MLOps client with the gateway URL and token provider.
  3. List all projects associated with the user.
  4. Retrieve the ID of the project you want to delete using the _get_project_id function.
  5. Delete the project using its ID.

Sample script: Delete project

    # List MLOps Projects for the user.
prj: mlops.StorageProject
projects: mlops.StorageListProjectsResponse = mlops_client.storage.project.list_projects(
mlops.StorageListProjectsRequest()
)

# Get the Project ID.
try:
prj = _get_project_id(projects.project)
except LookupError:
# Error if a project is not found.
raise ValueError("There is no project with the given name.")

# Delete the Project.
mlops_client.storage.project.delete_project(
mlops.StorageDeleteProjectRequest(project_id=prj.id)
)

Batch deletion workflow

  1. Retrieve a list of all projects associated with the user.
  2. Use the _get_project_id function to map the names of the projects in PROJECTS_TO_BE_DELETED to their respective IDs.
  3. Ensure that every project listed in PROJECTS_TO_BE_DELETED exists.
  4. Delete the projects based on their mapped IDs.

Sample script: Batch delete projects

    # List MLOps Projects for the user.

projects: mlops.StorageListProjectsResponse = mlops_client.storage.project.list_projects(
mlops.StorageListProjectsRequest()
)

prjs = _get_project_id(projects.project)
if len(prjs) != len(PROJECTS_TO_BE_DELETED):
raise ValueError("Some projects are not present")


deleted_projects_response: mlops.StorageBatchDeleteProjectResponse = mlops_client.storage.project.batch_delete_project(
mlops.StorageBatchDeleteProjectRequest(project_ids=prjs)
)

Feedback