

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Descrizione di un set di dati (SDK)
<a name="md-describing-dataset-sdk"></a>

È possibile utilizzare l'API `DescribeDataset` per ottenere informazioni su un set di dati.

**Per descrivere un set di dati (SDK)**

1. Se non l'hai già fatto, installa e configura il AWS CLI e il AWS SDKs. Per ulteriori informazioni, consulta [Passaggio 4: configura e AWS CLI AWS SDKs](su-awscli-sdk.md).

1. Usa il seguente codice di esempio per descrivere un set di dati.

------
#### [ AWS CLI ]

   Modifica il valore di `dataset-arn` nell’ARN del set di dati che desideri descrivere.

   ```
   aws rekognition describe-dataset --dataset-arn dataset_arn \
     --profile custom-labels-access
   ```

------
#### [ Python ]

   Usa il seguente codice. Fornisci i seguenti parametri di riga di comando:
   + dataset\$1arn — l'ARN del set di dati da descrivere.

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   """
   Purpose
   Shows how to describe an Amazon Rekognition Custom Labels dataset.
   """
   
   import argparse
   import logging
   import boto3
   
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def describe_dataset(rek_client, dataset_arn):
       """
       Describes an Amazon Rekognition Custom Labels dataset.
       :param rek_client: The Amazon Rekognition Custom Labels Boto3 client.
       :param dataset_arn: The ARN of the dataset that you want to describe.
   
       """
   
       try:
           # Describe the dataset
           logger.info("Describing dataset %s", dataset_arn)
   
           dataset = rek_client.describe_dataset(DatasetArn=dataset_arn)
   
           description = dataset['DatasetDescription']
   
           print(f"Created: {str(description['CreationTimestamp'])}")
           print(f"Updated: {str(description['LastUpdatedTimestamp'])}")
           print(f"Status: {description['Status']}")
           print(f"Status message: {description['StatusMessage']}")
           print(f"Status code: {description['StatusMessageCode']}")
           print("Stats:")
           print(
               f"\tLabeled entries: {description['DatasetStats']['LabeledEntries']}")
           print(
               f"\tTotal entries: {description['DatasetStats']['TotalEntries']}")
           print(f"\tTotal labels: {description['DatasetStats']['TotalLabels']}")
   
       except ClientError as err:
           logger.exception("Couldn't describe dataset: %s",
                            err.response['Error']['Message'])
           raise
   
   
   def add_arguments(parser):
       """
       Adds command line arguments to the parser.
       :param parser: The command line parser.
       """
   
       parser.add_argument(
           "dataset_arn", help="The ARN of the dataset that you want to describe."
       )
   
   
   def main():
   
       logging.basicConfig(level=logging.INFO,
                           format="%(levelname)s: %(message)s")
   
       try:
   
           # Get command line arguments.
           parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
           add_arguments(parser)
           args = parser.parse_args()
   
           print(f"Describing dataset {args.dataset_arn}")
   
           # Describe the dataset.
           session = boto3.Session(profile_name='custom-labels-access')
           rekognition_client = session.client("rekognition")
   
           describe_dataset(rekognition_client, args.dataset_arn)
   
           print(f"Finished describing dataset: {args.dataset_arn}")
   
       except ClientError as err:
           error_message=f"Problem describing dataset: {err}"
           logger.exception(error_message)
           print(error_message)
       except Exception as err:
           error_message = f"Problem describing dataset: {err}"
           logger.exception(error_message)
           print(error_message)
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ Java V2 ]
   + dataset\$1arn — l'ARN del set di dati da descrivere.

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   
   import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
   import software.amazon.awssdk.regions.Region;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.DatasetDescription;
   import software.amazon.awssdk.services.rekognition.model.DatasetStats;
   import software.amazon.awssdk.services.rekognition.model.DescribeDatasetRequest;
   import software.amazon.awssdk.services.rekognition.model.DescribeDatasetResponse;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   import java.util.logging.Level;
   import java.util.logging.Logger;
   
   public class DescribeDataset {
   
       public static final Logger logger = Logger.getLogger(DescribeDataset.class.getName());
   
       public static void describeMyDataset(RekognitionClient rekClient, String datasetArn) {
   
           try {
   
               DescribeDatasetRequest describeDatasetRequest = DescribeDatasetRequest.builder().datasetArn(datasetArn)
                       .build();
               DescribeDatasetResponse describeDatasetResponse = rekClient.describeDataset(describeDatasetRequest);
   
               DatasetDescription datasetDescription = describeDatasetResponse.datasetDescription();
               DatasetStats datasetStats = datasetDescription.datasetStats();
   
               System.out.println("ARN: " + datasetArn);
               System.out.println("Created: " + datasetDescription.creationTimestamp().toString());
               System.out.println("Updated: " + datasetDescription.lastUpdatedTimestamp().toString());
               System.out.println("Status: " + datasetDescription.statusAsString());
               System.out.println("Message: " + datasetDescription.statusMessage());
               System.out.println("Total Labels: " + datasetStats.totalLabels().toString());
               System.out.println("Total entries: " + datasetStats.totalEntries().toString());
               System.out.println("Entries with labels: " + datasetStats.labeledEntries().toString());
               System.out.println("Entries with at least 1 error: " + datasetStats.errorEntries().toString());
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               throw rekError;
           }
   
       }
   
       public static void main(String[] args) {
   
           final String USAGE = "\n" + "Usage: " + "<dataset_arn>\n\n" + "Where:\n"
                   + "   dataset_arn - The ARN of the dataset that you want to describe.\n\n";
   
           if (args.length != 1) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           String datasetArn = args[0];
   
           try {
   
               // Get the Rekognition client.
               RekognitionClient rekClient = RekognitionClient.builder()
               .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
               .region(Region.US_WEST_2)
               .build();
   
                // Describe the dataset.
               describeMyDataset(rekClient, datasetArn);
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------