kaxil commented on a change in pull request #10677:
URL: https://github.com/apache/airflow/pull/10677#discussion_r483145506



##########
File path: airflow/cli/commands/dag_command.py
##########
@@ -378,6 +380,48 @@ def dag_list_dag_runs(args, dag=None):
     print(table)
 
 
+@cli_utils.action_logging
+def generate_pod_yaml(args):
+    """Generates yaml files for each task in the DAG. Used for testing output 
of KubernetesExecutor"""
+
+    from airflow.executors.kubernetes_executor import 
AirflowKubernetesScheduler, KubeConfig
+    from airflow.kubernetes import pod_generator
+    from airflow.kubernetes.pod_generator import PodGenerator
+    from airflow.kubernetes.worker_configuration import WorkerConfiguration
+    from airflow.settings import pod_mutation_hook
+    from airflow.utils import timezone
+    execution_date = args.exec_date or timezone.utcnow()
+    dag = get_dag(subdir=args.subdir, dag_id=args.dag_id)
+    yaml_output_path = args.output_path or "/tmp/airflow_generated_yaml/"
+    kube_config = KubeConfig()
+    for task in dag.tasks:
+        ti = TaskInstance(task, execution_date)
+        pod = PodGenerator.construct_pod(
+            dag_id=args.dag_id,
+            task_id=ti.task_id,
+            pod_id=AirflowKubernetesScheduler._create_pod_id(  # pylint: 
disable=W0212
+                args.dag_id, ti.task_id),
+            try_number=ti.try_number,
+            date=ti.execution_date,
+            command=ti.command_as_list(),
+            kube_executor_config=PodGenerator.from_obj(ti.executor_config),
+            worker_uuid="worker-config",
+            namespace=kube_config.executor_namespace,
+            worker_config=WorkerConfiguration(kube_config=kube_config).as_pod()
+        )
+        pod_mutation_hook(pod)
+
+        from kubernetes.client.api_client import ApiClient

Review comment:
       It can be at Line 392, it will still be inside the function




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to