2323from typing import TYPE_CHECKING , ClassVar , Final
2424
2525from airflow .sdk .coordinators ._dag_importer import CoordinatorDagImporter
26- from airflow .sdk .coordinators .java ._jar_manifest import read_main_attributes
26+ from airflow .sdk .coordinators .java ._jar_manifest import DAG_CODE , MAIN_CLASS , read_main_attributes
2727from airflow .sdk .importers .base import DagSourceCode
2828
2929if TYPE_CHECKING :
3030 from airflow .sdk .coordinators .java .coordinator import JavaCoordinator
3131 from airflow .sdk .importers .base import DagDefinition
3232
33- _DAG_CODE_ATTRIBUTE : Final = "airflow-java-sdk-dag-code"
3433_MAX_SOURCE_BYTES : Final = 1024 * 1024
3534_NO_SOURCE : Final = (
3635 "// This JAR embeds no Dag source. Build it with the Airflow Java SDK Gradle plugin, or set\n "
3736 "// airflowBundle.dagSource, to show the source here.\n "
3837)
39- _SOURCE_TOO_LARGE : Final = (
40- f"// The Dag source this JAR embeds is over { _MAX_SOURCE_BYTES } bytes, so it is not shown.\n "
41- )
38+ _SOURCE_TOO_LARGE : Final = "// The Dag source this JAR embeds is over 1 MiB, so it is not shown.\n "
4239
4340
4441class JavaDagImporter (CoordinatorDagImporter ):
@@ -65,7 +62,7 @@ def might_contain_dag(self, definition: DagDefinition, safe_mode: bool) -> bool:
6562 attributes = read_main_attributes (zf ) or {}
6663 except (OSError , zipfile .BadZipFile ):
6764 return True
68- if not (main_class := attributes .get ("main-class" )):
65+ if not (main_class := attributes .get (MAIN_CLASS )):
6966 return False
7067 return not self .coordinator .main_class or main_class == self .coordinator .main_class
7168
@@ -81,7 +78,7 @@ def get_source_code(self, definition: DagDefinition) -> DagSourceCode:
8178
8279
8380def _find_source_entry (zf : zipfile .ZipFile ) -> zipfile .ZipInfo | None :
84- if not (entry := (read_main_attributes (zf ) or {}).get (_DAG_CODE_ATTRIBUTE )):
81+ if not (entry := (read_main_attributes (zf ) or {}).get (DAG_CODE )):
8582 return None
8683 try :
8784 return zf .getinfo (entry )
0 commit comments