Skip to content

Commit 52656ca

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
docs: add a sample for create_tensorboard.
PiperOrigin-RevId: 493376367
1 parent f8e5842 commit 52656ca

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

samples/model-builder/conftest.py

+13
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,19 @@ def mock_create_batch_prediction_job():
393393
yield mock
394394

395395

396+
"""
397+
----------------------------------------------------------------------------
398+
Tensorboard Fixtures
399+
----------------------------------------------------------------------------
400+
"""
401+
402+
403+
@pytest.fixture
404+
def mock_create_tensorboard():
405+
with patch.object(aiplatform.tensorboard.Tensorboard, "create") as mock:
406+
yield mock
407+
408+
396409
"""
397410
----------------------------------------------------------------------------
398411
Endpoint Fixtures
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from google.cloud import aiplatform
16+
17+
18+
# [START aiplatform_sdk_create_tensorboard_sample]
19+
def create_tensorboard_sample(
20+
project: str,
21+
display_name: str,
22+
location: str,
23+
):
24+
aiplatform.init(project=project, location=location)
25+
26+
tensorboard = aiplatform.tensorboard.Tensorboard.create(
27+
display_name=display_name,
28+
project=project,
29+
location=location,
30+
)
31+
32+
print(tensorboard.display_name)
33+
print(tensorboard.resource_name)
34+
return tensorboard
35+
36+
37+
# [END aiplatform_sdk_create_tensorboard_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
import create_tensorboard_sample
17+
import test_constants as constants
18+
19+
20+
def test_create_tensorboard_sample(mock_sdk_init, mock_create_tensorboard):
21+
22+
create_tensorboard_sample.create_tensorboard_sample(
23+
project=constants.PROJECT,
24+
display_name=constants.DISPLAY_NAME,
25+
location=constants.LOCATION,
26+
)
27+
28+
mock_sdk_init.assert_called_once_with(
29+
project=constants.PROJECT, location=constants.LOCATION
30+
)
31+
32+
mock_create_tensorboard.assert_called_once_with(
33+
display_name=constants.DISPLAY_NAME,
34+
project=constants.PROJECT,
35+
location=constants.LOCATION,
36+
)

0 commit comments

Comments
 (0)