google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

Google Cloud AutoMl V1 CreateDataset Error "OperationMetadata hasn't been added to descriptor pool"

Open zarkoET opened this issue 3 years ago • 1 comments

When trying to run this code

use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
use Google\Cloud\AutoMl\V1\TranslationDatasetMetadata;

$config = $this->config->get('automl');
        $autoMlClient = new AutoMlClient(['credentials' => $config['service_account_key']]);
        $formattedParent = $autoMlClient->locationName($config['project_id'], $config['location_id']);
        $dataset = new Dataset([
            'display_name'                 => $datasetName,
            'translation_dataset_metadata' => new TranslationDatasetMetadata([
                'source_language_code' => $sourceLanguage,
                'target_language_code' => $targetLanguage,
            ]),
        ]);


    $operationResponse = $autoMlClient->createDataset($formattedParent, $dataset);
    

I am getting this error: "Error occurred during parsing: Class google.cloud.automl.v1.OperationMetadata hasn't been added to descriptor pool"

The code is creating the dataset but this error prevents me to check if/when the operation is completed

BTW I checked the same code with 'V1beta1' and it works Can someone tell me what is going on?

zarkoET avatar Aug 12 '22 18:08 zarkoET

hi @zarkoET , I tried the following code with latest code in main branch ref and it prints dataset created. Is this not what you intend to achieve?

$PROJECT = 'thXXXXXXXX319';
$REGION = 'us-central1';

require 'vendor/autoload.php';

use Google\Cloud\AutoMl\V1\AutoMlClient;
use Google\Cloud\AutoMl\V1\Dataset;
use Google\Cloud\AutoMl\V1\TranslationDatasetMetadata;

$autoMlClient = new AutoMlClient([
    'credentials' => '/Users/vishwarajanand/XXXXXXX/GOOGLE_APPLICATIONS_CREDENTIALS.json',
]);
$formattedParent = $autoMlClient->locationName($PROJECT, $REGION);
$dataset = new Dataset([
    'display_name' => 'google_cloud_php_issue_5453',
    'translation_dataset_metadata' => new TranslationDatasetMetadata([
        'source_language_code' => 'en',
        'target_language_code' => 'es',
    ]),
]);
$operationResponse = $autoMlClient->createDataset($formattedParent, $dataset);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
    $result = $operationResponse->getResult();
    print("dataset created" . PHP_EOL);
} else {
    $error = $operationResponse->getError();
    print("dataset creation failed" . PHP_EOL);
}

vishwarajanand avatar Aug 30 '22 11:08 vishwarajanand

Closing this issue, because we need more info to proceed on the debugging. Pls feel free to reopen if needed.

vishwarajanand avatar Oct 10 '22 08:10 vishwarajanand