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
- Initialize the token provider using the provided refresh token.
- Set up the H2O MLOps client with the gateway URL and token provider.
- List all projects associated with the user.
- Retrieve the ID of the project you want to delete using the _get_project_idfunction.
- 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
- Retrieve a list of all projects associated with the user.
- Use the _get_project_idfunction to map the names of the projects inPROJECTS_TO_BE_DELETEDto their respective IDs.
- Ensure that every project listed in PROJECTS_TO_BE_DELETEDexists.
- 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
- Submit and view feedback for this page
- Send feedback about H2O MLOps to cloud-feedback@h2o.ai