jrmccluskey commented on code in PR #27091:
URL: https://github.com/apache/beam/pull/27091#discussion_r1240335170


##########
sdks/python/apache_beam/ml/inference/vertex_ai_inference.py:
##########
@@ -0,0 +1,178 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import logging
+import time
+from typing import Any
+from typing import Dict
+from typing import Iterable
+from typing import Optional
+from typing import Sequence
+
+from google.api_core.exceptions import ClientError
+from google.api_core.exceptions import TooManyRequests
+from google.cloud import aiplatform
+
+from apache_beam.io.components.adaptive_throttler import AdaptiveThrottler
+from apache_beam.metrics.metric import Metrics
+from apache_beam.ml.inference import utils
+from apache_beam.ml.inference.base import ModelHandler
+from apache_beam.ml.inference.base import PredictionResult
+from apache_beam.utils import retry
+
+MSEC_TO_SEC = 1000
+
+LOGGER = logging.getLogger("VertexAIModelHandlerJSON")
+
+# pylint: disable=line-too-long
+
+
+class VertexAIModelHandlerJSON(ModelHandler[Any,
+                                            PredictionResult,
+                                            aiplatform.Endpoint]):
+  def __init__(
+      self,
+      endpoint_id: str,
+      project: str,
+      location: str,
+      experiment: Optional[str] = None,
+      **kwargs):
+    """Implementation of the ModelHandler interface for Vertex AI.
+    **NOTE:** This API and its implementation are under development and
+    do not provide backward compatibility guarantees.
+    Unlike other ModelHandler implementations, this does not load the model
+    being used onto the worker and instead makes remote queries to a
+    Vertex AI endpoint. In that way it functions more like a mid-pipeline
+    IO. At present this implementation only supports public endpoints with
+    a maximum request size of 1.5 MB and is lacking error handling related
+    to potentially overwhelming the Vertex AI service and should be used
+    with this in mind.

Review Comment:
   Ah, old carryover from the POC. Removed that part of the comment.



##########
sdks/python/apache_beam/examples/inference/vertex_ai_image_classification.py:
##########
@@ -0,0 +1,158 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+""" A sample pipeline using the RunInference API to classify images of flowers.
+This pipeline reads an already-processes representation of an image of
+sunflowers and sends it to a deployed Vertex AI model endpoint, then
+returns the predictions from the classifier model. The model and image
+are from the Hello Image Data Vertex AI tutorial (see
+https://cloud.google.com/vertex-ai/docs/tutorials/image-recognition-custom
+for more information.)
+"""

Review Comment:
   +1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to