Skip to content

Commit

Permalink
docs: change init sample to use vertexai
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 656432815
  • Loading branch information
sasha-gitg authored and copybara-github committed Jul 26, 2024
1 parent c9d5280 commit 829e0f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion samples/model-builder/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from unittest.mock import MagicMock, patch
from unittest.mock import MagicMock
from unittest.mock import patch

from google.cloud import aiplatform
import vertexai
from vertexai.resources import preview as preview_resources
import pytest

Expand All @@ -25,6 +27,12 @@ def mock_sdk_init():
yield mock


@pytest.fixture
def mock_vertexai_init():
with patch.object(vertexai, "init") as mock:
yield mock


"""
----------------------------------------------------------------------------
Dataset Fixtures
Expand Down
4 changes: 2 additions & 2 deletions samples/model-builder/init_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def init_sample(
service_account: Optional[str] = None,
):

from google.cloud import aiplatform
import vertexai

aiplatform.init(
vertexai.init(
project=project,
location=location,
experiment=experiment,
Expand Down
4 changes: 2 additions & 2 deletions samples/model-builder/init_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import test_constants as constants


def test_init_sample(mock_sdk_init):
def test_init_sample(mock_vertexai_init):

init_sample.init_sample(
project=constants.PROJECT,
Expand All @@ -29,7 +29,7 @@ def test_init_sample(mock_sdk_init):
service_account=constants.SERVICE_ACCOUNT,
)

mock_sdk_init.assert_called_once_with(
mock_vertexai_init.assert_called_once_with(
project=constants.PROJECT,
location=constants.LOCATION_EUROPE,
experiment=constants.EXPERIMENT_NAME,
Expand Down

0 comments on commit 829e0f6

Please sign in to comment.