Merged
Show file tree
Hide file tree
Changes from 1 commit
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
PrevPrevious commit
Next Next commit
feat: Migrate sample and sample tests - Batch 4 of 5 (#14)
* chore: release 0.2.0

* Init samples and sample tests - Batch 4

* Address reviewer comments - 4 of 5

* Revert Changelog to 

* Update tabular + GAPIC namespace (B4/5)

* Sync with private repo (4/5)

* wrapped line

* add explanation to test

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply..com>
Co-authored-by: Bu Sun Kim <[email protected]>
Co-authored-by: Ariana Bray <[email protected]>
  • Loading branch information
4 people authoredNov 12, 2020
commit e1e3d1902b4b4f906cd3ac5ee62614a1d6eb9557
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
# Copyright 2020 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.

# [START aiplatform_get_model_evaluation_video_classification_sample]
from google.cloud import aiplatform


def get_model_evaluation_video_classification_sample(
project: str, model_id: str, evaluation_id: str, location: str = "us-central1"
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
name = client.model_evaluation_path(
project=project, location=location, model=model_id, evaluation=evaluation_id
)
response = client.get_model_evaluation(name=name)
print("response:", response)


# [END aiplatform_get_model_evaluation_video_classification_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
# Copyright 2020 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.

# [START aiplatform_get_training_pipeline_sample]
from google.cloud import aiplatform


def get_training_pipeline_sample(
project: str, training_pipeline_id: str, location: str = "us-central1"
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.PipelineServiceClient(client_options=client_options)
name = client.training_pipeline_path(
project=project, location=location, training_pipeline=training_pipeline_id
)
response = client.get_training_pipeline(name=name)
print("response:", response)


# [END aiplatform_get_training_pipeline_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
# Copyright 2020 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.

# [START aiplatform_import_data_image_classification_single_label_sample]
from google.cloud import aiplatform


def import_data_image_classification_single_label_sample(
project: str,
dataset_id: str,
gcs_source_uri: str,
location: str = "us-central1",
timeout: int = 1800,
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.DatasetServiceClient(client_options=client_options)
import_configs = [
{
"gcs_source": {"uris": [gcs_source_uri]},
"import_schema_uri": "gs://google-cloud-aiplatform/schema/dataset/ioformat/image_classification_single_label_io_format_1.0.0.yaml",
}
]
name = client.dataset_path(project=project, location=location, dataset=dataset_id)
response = client.import_data(name=name, import_configs=import_configs)
print("Long running operation:", response.operation.name)
import_data_response = response.result(timeout=timeout)
print("import_data_response:", import_data_response)


# [END aiplatform_import_data_image_classification_single_label_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
# Copyright 2020 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.

# [START aiplatform_import_data_image_object_detection_sample]
from google.cloud import aiplatform


def import_data_image_object_detection_sample(
project: str,
dataset_id: str,
gcs_source_uri: str,
location: str = "us-central1",
timeout: int = 1800,
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.DatasetServiceClient(client_options=client_options)
import_configs = [
{
"gcs_source": {"uris": [gcs_source_uri]},
"import_schema_uri": "gs://google-cloud-aiplatform/schema/dataset/ioformat/image_bounding_box_io_format_1.0.0.yaml",
}
]
name = client.dataset_path(project=project, location=location, dataset=dataset_id)
response = client.import_data(name=name, import_configs=import_configs)
print("Long running operation:", response.operation.name)
import_data_response = response.result(timeout=timeout)
print("import_data_response:", import_data_response)


# [END aiplatform_import_data_image_object_detection_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
# Copyright 2020 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.

# [START aiplatform_import_data_sample]
from google.cloud import aiplatform


def import_data_sample(
project: str,
dataset_id: str,
gcs_source_uri: str,
import_schema_uri: str,
location: str = "us-central1",
timeout: int = 1800,
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.DatasetServiceClient(client_options=client_options)
# Here we use only one import config with one source
import_configs = [
{
"gcs_source": {"uris": [gcs_source_uri]},
"import_schema_uri": import_schema_uri,
}
]
name = client.dataset_path(project=project, location=location, dataset=dataset_id)
response = client.import_data(name=name, import_configs=import_configs)
print("Long running operation:", response.operation.name)
import_data_response = response.result(timeout=timeout)
print("import_data_response:", import_data_response)


# [END aiplatform_import_data_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2020 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.

# [START aiplatform_import_data_text_entity_extraction_sample]
from google.cloud import aiplatform


def import_data_text_entity_extraction_sample(
project: str,
dataset_id: str,
gcs_source_uri: str,
location: str = "us-central1",
timeout: int = 1800,
):
client_options = {"api_endpoint": "us-central1-aiplatform.googleapis.com"}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.DatasetServiceClient(client_options=client_options)
import_schema_uri = ("gs://google-cloud-aiplatform/schema/dataset/ioformat/"
"text_extraction_io_format_1.0.0.yaml"
)
import_configs = [
{
"gcs_source": {"uris": [gcs_source_uri]},
"import_schema_uri": import_schema_uri,
}
]
name = client.dataset_path(project=project, location=location, dataset=dataset_id)
response = client.import_data(name=name, import_configs=import_configs)
print("Long running operation:", response.operation.name)
import_data_response = response.result(timeout=timeout)
print("import_data_response:", import_data_response)


# [END aiplatform_import_data_text_entity_extraction_sample]
Loading