Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
*sponge_log.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
10 changes: 0 additions & 10 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
Expand Down
96 changes: 80 additions & 16 deletions .kokoro/test-samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The default test runner for samples.
#
# For periodic builds, we rewinds the repo to the latest release, and
# run test-samples-impl.sh.

# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
Expand All @@ -28,19 +24,87 @@ cd github/python-aiplatform

# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
# preserving the test runner implementation.
cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh"
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
echo "Now we rewind the repo back to the latest release..."
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
git checkout $LATEST_RELEASE
echo "The current head is: "
echo $(git rev-parse --verify HEAD)
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
# move back the test runner implementation if there's no file.
if [ ! -f .kokoro/test-samples-impl.sh ]; then
cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh
fi
fi

exec .kokoro/test-samples-impl.sh
# Exit early if samples directory doesn't exist
if [ ! -d "./samples" ]; then
echo "No tests run. `./samples` not found"
exit 0
fi

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Debug: show build environment
env | grep KOKORO

# Install nox
python3.6 -m pip install --upgrade --quiet nox

# Use secrets acessor service account to get secrets
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
gcloud auth activate-service-account \
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
--project="cloud-devrel-kokoro-resources"
fi

# This script will create 3 files:
# - testing/test-env.sh
# - testing/service-account.json
# - testing/client-secrets.json
./scripts/decrypt-secrets.sh

source ./testing/test-env.sh
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json

# For cloud-run session, we activate the service account for gcloud sdk.
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"

export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json

echo -e "\n******************** TESTING PROJECTS ********************"

# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all requirements.txt in the samples directory (may break on whitespace).
for file in samples/**/requirements.txt; do
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
cd "$file"

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Use nox to execute the tests for the project.
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a periodic build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
else
echo -e "\n Testing completed.\n"
fi

done
cd "$ROOT"

# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}

exit "$RTN"
22 changes: 4 additions & 18 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::

$ nox -s unit-2.7
$ nox -s unit-3.8
$ nox -s unit-3.7
$ ...

- Args to pytest can be passed through the nox command separated by a `--`. For
example, to run a single test::

$ nox -s unit-3.8 -- -k <name of test>

.. note::

The unit tests and system tests are described in the
Expand All @@ -98,12 +93,8 @@ On Debian/Ubuntu::
************
Coding Style
************
- We use the automatic code formatter ``black``. You can run it using
the nox session ``blacken``. This will eliminate many lint errors. Run via::

$ nox -s blacken

- PEP8 compliance is required, with exceptions defined in the linter configuration.
- PEP8 compliance, with exceptions defined in the linter configuration.
If you have ``nox`` installed, you can test that you have not introduced
any non-compliant code via::

Expand Down Expand Up @@ -142,18 +133,13 @@ Running System Tests

- To run system tests, you can execute::

# Run all system tests
$ nox -s system-3.8
$ nox -s system-3.7
$ nox -s system-2.7

# Run a single system test
$ nox -s system-3.8 -- -k <name of test>


.. note::

System tests are only configured to run under Python 2.7 and
Python 3.8. For expediency, we do not run them in older versions
Python 3.7. For expediency, we do not run them in older versions
of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
recursive-include google *.json *.proto py.typed
recursive-include google *.json *.proto
recursive-include tests *
global-exclude *.py[co]
global-exclude __pycache__

# Exclude scripts for samples readmegen
prune scripts/readme-gen
prune scripts/readme-gen
1 change: 0 additions & 1 deletion docs/aiplatform_v1beta1/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Services for Google Cloud Aiplatform v1beta1 API
pipeline_service
prediction_service
specialist_pool_service
vizier_service
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
AutoMlImageSegmentationInputs,
AutoMlImageSegmentationMetadata,
)
from .export_evaluated_data_items_config import ExportEvaluatedDataItemsConfig
from .automl_tables import (
AutoMlTables,
AutoMlTablesInputs,
Expand Down Expand Up @@ -59,7 +60,6 @@
AutoMlVideoObjectTracking,
AutoMlVideoObjectTrackingInputs,
)
from .export_evaluated_data_items_config import ExportEvaluatedDataItemsConfig

__all__ = (
"AutoMlImageClassification",
Expand All @@ -71,6 +71,7 @@
"AutoMlImageSegmentation",
"AutoMlImageSegmentationInputs",
"AutoMlImageSegmentationMetadata",
"ExportEvaluatedDataItemsConfig",
"AutoMlTables",
"AutoMlTablesInputs",
"AutoMlTablesMetadata",
Expand All @@ -86,5 +87,4 @@
"AutoMlVideoClassificationInputs",
"AutoMlVideoObjectTracking",
"AutoMlVideoObjectTrackingInputs",
"ExportEvaluatedDataItemsConfig",
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class VideoActionRecognitionPredictionInstance(proto.Message):
Expressed as a number of seconds as measured
from the start of the video, with "s" appended
at the end. Fractions are allowed, up to a
microsecond precision, and "inf" or "Infinity"
is allowed, which means the end of the video.
microsecond precision, and "Infinity" is
allowed, which means the end of the video.
"""

content = proto.Field(proto.STRING, number=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class VideoClassificationPredictionInstance(proto.Message):
Expressed as a number of seconds as measured
from the start of the video, with "s" appended
at the end. Fractions are allowed, up to a
microsecond precision, and "inf" or "Infinity"
is allowed, which means the end of the video.
microsecond precision, and "Infinity" is
allowed, which means the end of the video.
"""

content = proto.Field(proto.STRING, number=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class VideoObjectTrackingPredictionInstance(proto.Message):
Expressed as a number of seconds as measured
from the start of the video, with "s" appended
at the end. Fractions are allowed, up to a
microsecond precision, and "inf" or "Infinity"
is allowed, which means the end of the video.
microsecond precision, and "Infinity" is
allowed, which means the end of the video.
"""

content = proto.Field(proto.STRING, number=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
from google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_sentiment import (
TextSentimentPredictionResult,
)
from google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.time_series_forecasting import (
TimeSeriesForecastingPredictionResult,
)
from google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_action_recognition import (
VideoActionRecognitionPredictionResult,
)
Expand All @@ -54,6 +57,7 @@
"TabularRegressionPredictionResult",
"TextExtractionPredictionResult",
"TextSentimentPredictionResult",
"TimeSeriesForecastingPredictionResult",
"VideoActionRecognitionPredictionResult",
"VideoClassificationPredictionResult",
"VideoObjectTrackingPredictionResult",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .types.tabular_regression import TabularRegressionPredictionResult
from .types.text_extraction import TextExtractionPredictionResult
from .types.text_sentiment import TextSentimentPredictionResult
from .types.time_series_forecasting import TimeSeriesForecastingPredictionResult
from .types.video_action_recognition import VideoActionRecognitionPredictionResult
from .types.video_classification import VideoClassificationPredictionResult
from .types.video_object_tracking import VideoObjectTrackingPredictionResult
Expand All @@ -34,6 +35,7 @@
"TabularRegressionPredictionResult",
"TextExtractionPredictionResult",
"TextSentimentPredictionResult",
"TimeSeriesForecastingPredictionResult",
"VideoActionRecognitionPredictionResult",
"VideoClassificationPredictionResult",
"VideoObjectTrackingPredictionResult",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .tabular_regression import TabularRegressionPredictionResult
from .text_extraction import TextExtractionPredictionResult
from .text_sentiment import TextSentimentPredictionResult
from .time_series_forecasting import TimeSeriesForecastingPredictionResult
from .video_action_recognition import VideoActionRecognitionPredictionResult
from .video_classification import VideoClassificationPredictionResult
from .video_object_tracking import VideoObjectTrackingPredictionResult
Expand All @@ -34,6 +35,7 @@
"TabularRegressionPredictionResult",
"TextExtractionPredictionResult",
"TextSentimentPredictionResult",
"TimeSeriesForecastingPredictionResult",
"VideoActionRecognitionPredictionResult",
"VideoClassificationPredictionResult",
"VideoObjectTrackingPredictionResult",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ImageSegmentationPredictionResult(proto.Message):
r"""Prediction output format for Image Segmentation.

Attributes:
category_mask (str):
category_mask (bytes):
A PNG image where each pixel in the mask
represents the category in which the pixel in
the original image was predicted to belong to.
Expand All @@ -39,7 +39,7 @@ class ImageSegmentationPredictionResult(proto.Message):
likely category and if none of the categories
reach the confidence threshold, the pixel will
be marked as background.
confidence_mask (str):
confidence_mask (bytes):
A one channel image which is encoded as an
8bit lossless PNG. The size of the image will be
the same as the original image. For a specific
Expand All @@ -49,9 +49,9 @@ class ImageSegmentationPredictionResult(proto.Message):
confidence and white means complete confidence.
"""

category_mask = proto.Field(proto.STRING, number=1)
category_mask = proto.Field(proto.BYTES, number=1)

confidence_mask = proto.Field(proto.STRING, number=2)
confidence_mask = proto.Field(proto.BYTES, number=2)


__all__ = tuple(sorted(__protobuf__.manifest))
Loading