Se usó la API de Cloud Translation para traducir esta página.
Switch to English

Enumera modelos

Crear una lista de modelos existentes

Muestra de código


 * Demonstrates using the AutoML client to list all models.
 * @param projectId the Id of the project.
 * @param computeRegion the Region name.
 * @param filter the filter expression.
 * @throws IOException on Input/Output errors.
public static void listModels(String projectId, String computeRegion, String filter)
    throws IOException {
  // Instantiates a client
  try (AutoMlClient client = AutoMlClient.create()) {

    // A resource that represents Google Cloud Platform location.
    LocationName projectLocation = LocationName.of(projectId, computeRegion);

    // Create list models request.
    ListModelsRequest listModlesRequest =

    // List all the models available in the region by applying filter.
    System.out.println("List of models:");
    for (Model model : client.listModels(listModlesRequest).iterateAll()) {
      // Display the model information.
      System.out.println(String.format("Model name: %s", model.getName()));
              "Model id: %s", model.getName().split("/")[model.getName().split("/").length - 1]));
      System.out.println(String.format("Model display name: %s", model.getDisplayName()));
      System.out.println("Model create time:");
      System.out.println(String.format("\tseconds: %s", model.getCreateTime().getSeconds()));
      System.out.println(String.format("\tnanos: %s", model.getCreateTime().getNanos()));
      System.out.println(String.format("Model deployment state: %s", model.getDeploymentState()));


    # TODO(developer): Uncomment and set the following variables
    # project_id = 'PROJECT_ID_HERE'
    # compute_region = 'COMPUTE_REGION_HERE'
    # filter_ = 'DATASET_ID_HERE'

    from import automl_v1beta1 as automl

    client = automl.AutoMlClient()

    # A resource that represents Google Cloud Platform location.
    project_location = f"projects/{project_id}/locations/{compute_region}"

    # List all the models available in the region by applying filter.
    request = automl.ListModelsRequest(parent=project_location, filter=filter_)
    response = client.list_models(request=request)

    print("List of models:")
    for model in response:
        # Display the model information.
        if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
            deployment_state = "deployed"
            deployment_state = "undeployed"

        print("Model name: {}".format(
        print("Model id: {}".format("/")[-1]))
        print("Model display name: {}".format(model.display_name))
        print("Model create time: {}".format(model.create_time))
        print("Model deployment state: {}".format(deployment_state))