Skip to content

Commit

Permalink
chore: lint mb samples (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha-gitg committed Apr 14, 2021
1 parent 40d630e commit be0d7d4
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 31 deletions.
3 changes: 1 addition & 2 deletions samples/model-builder/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

from google.cloud import aiplatform
import pytest


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_create_and_import_dataset_image_sample]
def create_and_import_dataset_image_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# limitations under the License.


import test_constants as constants
import create_and_import_dataset_image_sample

from google.cloud.aiplatform import schema

import create_and_import_dataset_image_sample
import test_constants as constants


def test_create_and_import_dataset_image_sample(
mock_sdk_init, mock_create_image_dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_create_and_import_dataset_text_sample]
def create_and_import_dataset_text_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# limitations under the License.


import test_constants as constants
import create_and_import_dataset_text_sample

from google.cloud.aiplatform import schema

import create_and_import_dataset_text_sample
import test_constants as constants


def test_create_and_import_dataset_text_sample(mock_sdk_init, mock_create_text_dataset):

Expand Down
3 changes: 2 additions & 1 deletion samples/model-builder/create_batch_prediction_job_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional, Sequence, Union
from typing import Sequence, Union

from google.cloud import aiplatform


# [START aiplatform_sdk_create_batch_prediction_job_sample]
def create_batch_prediction_job_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.


import test_constants as constants
import create_batch_prediction_job_sample
import test_constants as constants


def test_create_batch_prediction_job_sample(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_create_training_pipeline_image_classification_sample]
def create_training_pipeline_image_classification_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# limitations under the License.


import pytest
import test_constants as constants
import create_training_pipeline_image_classification_sample
import test_constants as constants


def test_create_training_pipeline_image_classification_sample(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_import_data_text_classification_single_label_sample]
def import_data_text_classification_single_label(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# limitations under the License.


import test_constants as constants
import import_data_text_classification_single_label_sample

from google.cloud.aiplatform import schema

import import_data_text_classification_single_label_sample
import test_constants as constants


def test_import_data_text_classification_single_label_sample(
mock_sdk_init, mock_get_text_dataset, mock_import_text_dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_import_data_text_entity_extraction_sample]
def import_data_text_entity_extraction_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# limitations under the License.


import test_constants as constants
import import_data_text_entity_extraction_sample

from google.cloud.aiplatform import schema

import import_data_text_entity_extraction_sample
import test_constants as constants


def test_import_data_text_entity_extraction_sample(
mock_sdk_init, mock_get_text_dataset, mock_import_text_dataset
Expand All @@ -34,7 +34,9 @@ def test_import_data_text_entity_extraction_sample(
project=constants.PROJECT, location=constants.LOCATION
)

mock_get_text_dataset.assert_called_once_with(constants.DATASET_NAME,)
mock_get_text_dataset.assert_called_once_with(
constants.DATASET_NAME,
)

mock_import_text_dataset.assert_called_once_with(
gcs_source=constants.GCS_SOURCES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_import_data_text_sentiment_analysis_sample]
def import_data_text_sentiment_analysis_sample(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# limitations under the License.


import test_constants as constants
import import_data_text_sentiment_analysis_sample

from google.cloud.aiplatform import schema

import import_data_text_sentiment_analysis_sample
import test_constants as constants


def test_import_data_text_sentiment_analysis_sample(
mock_sdk_init, mock_get_text_dataset, mock_import_text_dataset
Expand All @@ -34,7 +34,9 @@ def test_import_data_text_sentiment_analysis_sample(
project=constants.PROJECT, location=constants.LOCATION
)

mock_get_text_dataset.assert_called_once_with(constants.DATASET_NAME,)
mock_get_text_dataset.assert_called_once_with(
constants.DATASET_NAME,
)

mock_import_text_dataset.assert_called_once_with(
gcs_source=constants.GCS_SOURCES,
Expand Down
3 changes: 2 additions & 1 deletion samples/model-builder/init_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

from typing import Optional

from google.cloud import aiplatform
from google.auth import credentials as auth_credentials
from google.cloud import aiplatform


# [START aiplatform_sdk_init_sample]
def init_sample(
Expand Down
1 change: 0 additions & 1 deletion samples/model-builder/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import nox


# WARNING - WARNING - WARNING - WARNING - WARNING
# WARNING - WARNING - WARNING - WARNING - WARNING
# DO NOT EDIT THIS FILE EVER!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_predict_text_classification_single_label_sample]
def predict_text_classification_single_label_sample(
project, location, endpoint, content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.


import test_constants as constants
import predict_text_classification_single_label_sample
import test_constants as constants


def test_predict_text_classification_single_label_sample(
Expand All @@ -32,4 +32,6 @@ def test_predict_text_classification_single_label_sample(
project=constants.PROJECT, location=constants.LOCATION
)

mock_get_endpoint.assert_called_once_with(constants.ENDPOINT_NAME,)
mock_get_endpoint.assert_called_once_with(
constants.ENDPOINT_NAME,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_predict_text_entity_extraction_sample]
def predict_text_entity_extraction_sample(project, location, endpoint_id, content):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.


import test_constants as constants
import predict_text_entity_extraction_sample
import test_constants as constants


def test_predict_text_entity_extraction_sample(mock_sdk_init, mock_get_endpoint):
Expand All @@ -30,4 +30,6 @@ def test_predict_text_entity_extraction_sample(mock_sdk_init, mock_get_endpoint)
project=constants.PROJECT, location=constants.LOCATION
)

mock_get_endpoint.assert_called_once_with(constants.ENDPOINT_NAME,)
mock_get_endpoint.assert_called_once_with(
constants.ENDPOINT_NAME,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from google.cloud import aiplatform


# [START aiplatform_sdk_predict_text_sentiment_analysis_sample]
def predict_text_sentiment_analysis_sample(project, location, endpoint_id, content):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.


import test_constants as constants
import predict_text_sentiment_analysis_sample
import test_constants as constants


def test_predict_text_sentiment_analysis_sample(mock_sdk_init, mock_get_endpoint):
Expand All @@ -30,4 +30,6 @@ def test_predict_text_sentiment_analysis_sample(mock_sdk_init, mock_get_endpoint
project=constants.PROJECT, location=constants.LOCATION
)

mock_get_endpoint.assert_called_once_with(constants.ENDPOINT_NAME,)
mock_get_endpoint.assert_called_once_with(
constants.ENDPOINT_NAME,
)

0 comments on commit be0d7d4

Please sign in to comment.