Search code examples
google-cloud-automl

Does deleting an AutoML Vision dataset also delete the model?


I'm creating models in Google's AutoML Vision Image Classification service. When deploying new models, I want to delete their predecessors.

In the console, deleting the trained model does not delete the dataset. However, deleting the dataset appears to delete the model. When deleting a model, the following warning is shown: Your model will be removed from Google Cloud, and any API queries to this model will no longer work. When deleting a dataset, this warning is shown: Your dataset will be removed from Google Cloud, including all label data. Your images on Cloud Storage (GCS) will not be affected.. Again, there is no indication that deleting the dataset also deletes the model. It makes sense that it appeared to have done so when I tested it, given how the dataset and model are tied together in the console, but I cannot find any documentation regarding this.

When using the client APIs, such as NodeJS, the documentation shows both how to delete a dataset and how to delete a model. However, there does not seem to be any indication of whether or not deleting the dataset also deletes the model.

Google's docs on managing datasets and managing models also do not specify whether or not deleting the dataset also deletes the model.

When using the client APIs, do I only have to delete the dataset, or do I have to both delete the dataset and the model?

I'm inclined to believe that the model does get deleted with the dataset- but I'd like to make sure that this is truly the case.


Solution

  • EDIT: This answer was made with the v1beta1 API, before the release of the v1 API. I believe this answer is no longer true with the v1 API.

    I've now tested this with the NodeJS client library and can confirm that the deleteDataset method does delete both the dataset and its corresponding model.

    const formattedParent = automl.locationPath('foobar', 'us-central1');
    
    // List Datasets
    const datasetsA = await automl.listDatasets({parent: formattedParent})
    console.log(`BEFORE Datasets: ${JSON.stringify(datasetsA, null, 4)}`)
    
    // List Models
    const modelsA = await automl.listModels({parent: formattedParent})
    console.log(`BEFORE Models: ${JSON.stringify(modelsA, null, 4)}`)
    
    // Delete Dataset
    const formattedName = automl.datasetPath('foobar', 'us-central1', 'barbaz')
    const [operation, initialApiResponse] = await automl.deleteDataset({name: formattedName})
    const responses = await operation.promise()
    const result = responses[0]
    const metadata = responses[1]
    const finalApiResponse = responses[2]
    console.log(`result: ${JSON.stringify(result, null, 4)}`)
    console.log(`metadata: ${JSON.stringify(metadata, null, 4)}`)
    console.log(`finalApiResponse: ${JSON.stringify(finalApiResponse, null, 4)}`)
    
    // List Datasets
    const datasetsB = await automl.listDatasets({parent: formattedParent})
    console.log(`AFTER Datasets: ${JSON.stringify(datasetsB, null, 4)}`)
    
    // List Models
    const modelsB = await automl.listModels({parent: formattedParent})
    console.log(`AFTER Models: ${JSON.stringify(modelsB, null, 4)}`)
    

    The output to console confirms that the model no longer exists after the delete LRO completes.