tardunge commented on code in PR #63938:
URL: https://github.com/apache/airflow/pull/63938#discussion_r3147429591


##########
providers/cncf/kubernetes/tests/system/cncf/kubernetes/example_ray.py:
##########
@@ -0,0 +1,125 @@
+#
+# 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 DAG using RayKubernetesOperator to submit a RayJob on Kubernetes.
+
+KubeRay operator is required to be installed on the Kubernetes cluster.
+https://docs.ray.io/en/latest/cluster/kubernetes/getting-started.html
+"""
+
+from __future__ import annotations
+
+from datetime import datetime
+
+from airflow import DAG
+
+# [START import_module]
+from airflow.providers.cncf.kubernetes.operators.ray import 
RayKubernetesOperator
+
+# [END import_module]
+
+with DAG(
+    dag_id="example_ray_kubernetes",
+    schedule=None,
+    start_date=datetime(2024, 1, 1),
+    catchup=False,
+    tags=["example", "ray", "kubernetes"],
+) as dag:
+    # [START howto_operator_ray_kubernetes_template_spec]
+    ray_job_template_spec = RayKubernetesOperator(
+        task_id="ray_job_template_spec",
+        template_spec={
+            "apiVersion": "ray.io/v1",
+            "kind": "RayJob",
+            "metadata": {"name": "ray-job-example"},
+            "spec": {
+                "entrypoint": "python -c 'import ray; ray.init(); 
print(ray.cluster_resources())'",
+                "rayClusterSpec": {
+                    "headGroupSpec": {
+                        "rayStartParams": {"dashboard-host": "0.0.0.0"},
+                        "template": {
+                            "spec": {
+                                "containers": [
+                                    {
+                                        "name": "ray-head",
+                                        "image": "rayproject/ray:2.9.0",
+                                        "resources": {
+                                            "limits": {"cpu": "1", "memory": 
"2Gi"},
+                                            "requests": {"cpu": "500m", 
"memory": "1Gi"},
+                                        },
+                                    }
+                                ]
+                            }
+                        },
+                    },
+                },
+            },
+        },
+        namespace="default",
+        kubernetes_conn_id="kubernetes_default",
+        startup_timeout_seconds=300,
+        job_timeout_seconds=600,
+        delete_on_termination=True,
+    )
+    # [END howto_operator_ray_kubernetes_template_spec]
+
+    # [START howto_operator_ray_kubernetes_yaml]
+    ray_job_yaml = RayKubernetesOperator(
+        task_id="ray_job_yaml",
+        application_file="example_ray_job.yaml",
+        namespace="default",
+        kubernetes_conn_id="kubernetes_default",
+        delete_on_termination=True,
+    )

Review Comment:
   Fixed in 0407a93f — added example_ray_job.yaml and switched application_file 
to an absolute path via Path(__file__).parent.



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