Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AiPlatform] add DatasetVersion and dataset version RPCs to DatasetService #6672

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified AiPlatform/metadata/V1/DatasetService.php
Binary file not shown.
37 changes: 37 additions & 0 deletions AiPlatform/metadata/V1/DatasetVersion.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions AiPlatform/metadata/V1/MachineResources.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified AiPlatform/metadata/V1/ModelMonitoring.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_DatasetService_CreateDatasetVersion_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\DatasetServiceClient;
use Google\Cloud\AIPlatform\V1\CreateDatasetVersionRequest;
use Google\Cloud\AIPlatform\V1\DatasetVersion;
use Google\Rpc\Status;

/**
* Create a version from a Dataset.
*
* @param string $formattedParent The name of the Dataset resource.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}`
* Please see {@see DatasetServiceClient::datasetName()} for help formatting this field.
*/
function create_dataset_version_sample(string $formattedParent): void
{
// Create a client.
$datasetServiceClient = new DatasetServiceClient();

// Prepare the request message.
$datasetVersion = new DatasetVersion();
$request = (new CreateDatasetVersionRequest())
->setParent($formattedParent)
->setDatasetVersion($datasetVersion);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $datasetServiceClient->createDatasetVersion($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var DatasetVersion $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = DatasetServiceClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');

create_dataset_version_sample($formattedParent);
}
// [END aiplatform_v1_generated_DatasetService_CreateDatasetVersion_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_DatasetService_DeleteDatasetVersion_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\DatasetServiceClient;
use Google\Cloud\AIPlatform\V1\DeleteDatasetVersionRequest;
use Google\Rpc\Status;

/**
* Deletes a Dataset version.
*
* @param string $formattedName The resource name of the Dataset version to delete.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}`
* Please see {@see DatasetServiceClient::datasetVersionName()} for help formatting this field.
*/
function delete_dataset_version_sample(string $formattedName): void
{
// Create a client.
$datasetServiceClient = new DatasetServiceClient();

// Prepare the request message.
$request = (new DeleteDatasetVersionRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $datasetServiceClient->deleteDatasetVersion($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = DatasetServiceClient::datasetVersionName(
'[PROJECT]',
'[LOCATION]',
'[DATASET]',
'[DATASET_VERSION]'
);

delete_dataset_version_sample($formattedName);
}
// [END aiplatform_v1_generated_DatasetService_DeleteDatasetVersion_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_DatasetService_GetDatasetVersion_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\DatasetServiceClient;
use Google\Cloud\AIPlatform\V1\DatasetVersion;
use Google\Cloud\AIPlatform\V1\GetDatasetVersionRequest;

/**
* Gets a Dataset version.
*
* @param string $formattedName The resource name of the Dataset version to delete.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}`
* Please see {@see DatasetServiceClient::datasetVersionName()} for help formatting this field.
*/
function get_dataset_version_sample(string $formattedName): void
{
// Create a client.
$datasetServiceClient = new DatasetServiceClient();

// Prepare the request message.
$request = (new GetDatasetVersionRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var DatasetVersion $response */
$response = $datasetServiceClient->getDatasetVersion($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = DatasetServiceClient::datasetVersionName(
'[PROJECT]',
'[LOCATION]',
'[DATASET]',
'[DATASET_VERSION]'
);

get_dataset_version_sample($formattedName);
}
// [END aiplatform_v1_generated_DatasetService_GetDatasetVersion_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START aiplatform_v1_generated_DatasetService_ListDatasetVersions_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AIPlatform\V1\Client\DatasetServiceClient;
use Google\Cloud\AIPlatform\V1\DatasetVersion;
use Google\Cloud\AIPlatform\V1\ListDatasetVersionsRequest;

/**
* Lists DatasetVersions in a Dataset.
*
* @param string $formattedParent The resource name of the Dataset to list DatasetVersions from.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}`
* Please see {@see DatasetServiceClient::datasetName()} for help formatting this field.
*/
function list_dataset_versions_sample(string $formattedParent): void
{
// Create a client.
$datasetServiceClient = new DatasetServiceClient();

// Prepare the request message.
$request = (new ListDatasetVersionsRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $datasetServiceClient->listDatasetVersions($request);

/** @var DatasetVersion $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = DatasetServiceClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]');

list_dataset_versions_sample($formattedParent);
}
// [END aiplatform_v1_generated_DatasetService_ListDatasetVersions_sync]
Loading