Skip to content

Commit 829e0f6

Browse files
sasha-gitgcopybara-github
authored andcommitted
docs: change init sample to use vertexai
PiperOrigin-RevId: 656432815
1 parent c9d5280 commit 829e0f6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

samples/model-builder/conftest.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from unittest.mock import MagicMock, patch
15+
from unittest.mock import MagicMock
16+
from unittest.mock import patch
1617

1718
from google.cloud import aiplatform
19+
import vertexai
1820
from vertexai.resources import preview as preview_resources
1921
import pytest
2022

@@ -25,6 +27,12 @@ def mock_sdk_init():
2527
yield mock
2628

2729

30+
@pytest.fixture
31+
def mock_vertexai_init():
32+
with patch.object(vertexai, "init") as mock:
33+
yield mock
34+
35+
2836
"""
2937
----------------------------------------------------------------------------
3038
Dataset Fixtures

samples/model-builder/init_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def init_sample(
2828
service_account: Optional[str] = None,
2929
):
3030

31-
from google.cloud import aiplatform
31+
import vertexai
3232

33-
aiplatform.init(
33+
vertexai.init(
3434
project=project,
3535
location=location,
3636
experiment=experiment,

samples/model-builder/init_sample_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import test_constants as constants
1818

1919

20-
def test_init_sample(mock_sdk_init):
20+
def test_init_sample(mock_vertexai_init):
2121

2222
init_sample.init_sample(
2323
project=constants.PROJECT,
@@ -29,7 +29,7 @@ def test_init_sample(mock_sdk_init):
2929
service_account=constants.SERVICE_ACCOUNT,
3030
)
3131

32-
mock_sdk_init.assert_called_once_with(
32+
mock_vertexai_init.assert_called_once_with(
3333
project=constants.PROJECT,
3434
location=constants.LOCATION_EUROPE,
3535
experiment=constants.EXPERIMENT_NAME,

0 commit comments

Comments
 (0)