AlejandroMorgante commented on code in PR #68479:
URL: https://github.com/apache/airflow/pull/68479#discussion_r3545864077


##########
providers/google/tests/system/google/cloud/vertex_ai/example_vertex_ai_agent_engine.py:
##########
@@ -0,0 +1,205 @@
+#
+# 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.
+
+"""
+Example Airflow Dag for Google Vertex AI Agent Engine operations.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+from datetime import datetime
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+    from vertexai._genai import types as vertexai_types
+
+from airflow.providers.google.cloud.operators.vertex_ai.agent_engine import (
+    CreateAgentEngineOperator,
+    DeleteAgentEngineOperator,
+    GetAgentEngineOperator,
+    RunQueryJobOperator,
+    UpdateAgentEngineOperator,
+)
+
+try:
+    from airflow.sdk import DAG, TriggerRule
+except ImportError:
+    # Compatibility for Airflow < 3.1
+    from airflow.models.dag import DAG  # type: 
ignore[attr-defined,no-redef,assignment]
+    from airflow.utils.trigger_rule import TriggerRule  # type: 
ignore[no-redef,attr-defined]
+
+DAG_ID = "vertex_ai_agent_engine_operations"
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID", "default")
+
+
+def _get_env(name: str, default: str = "") -> str:
+    return os.environ.get(name) or os.environ.get(f"AIRFLOW_VAR_{name}", 
default)
+
+
+def _get_json_env(name: str, default: dict[str, str]) -> dict[str, str]:
+    value = os.environ.get(name)
+    return json.loads(value) if value else default
+
+
+def _get_container_env_vars() -> dict[str, str]:
+    return _get_json_env(
+        "SYSTEM_TESTS_VERTEX_AI_AGENT_ENGINE_CONTAINER_ENV_VARS",
+        {},
+    )
+
+
+LOCATION = _get_env("GCP_REGION", "us-central1")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT") or 
_get_env("GCP_PROJECT_ID", "default")
+CONTAINER_URI = 
os.environ.get("SYSTEM_TESTS_VERTEX_AI_AGENT_ENGINE_CONTAINER_URI") or _get_env(

Review Comment:
   Done! The test now builds the agent container itself with 
CloudBuildCreateBuildOperator (inline build steps, same pattern as 
example_cloud_build.py) into an Artifact  Registry repository scoped to the 
test run, and deletes it in teardown. The query-output GCS bucket is likewise 
created and deleted by the test with 
GCSCreateBucketOperator/GCSDeleteBucketOperator, following the sibling 
vertex_ai system  tests.
   
   Verified end-to-end on a real GCP project. All tasks green and no resources 
left behind; the one-time project prerequisites (APIs + IAM) are documented in 
the Dag docstring.



-- 
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