francescomucio commented on code in PR #25509:
URL: https://github.com/apache/airflow/pull/25509#discussion_r937819635


##########
airflow/models/dag.py:
##########
@@ -522,17 +522,35 @@ def __init__(
         self.has_on_success_callback = self.on_success_callback is not None
         self.has_on_failure_callback = self.on_failure_callback is not None
 
-        self.doc_md = doc_md
-
         self._access_control = 
DAG._upgrade_outdated_dag_access_control(access_control)
         self.is_paused_upon_creation = is_paused_upon_creation
 
         self.jinja_environment_kwargs = jinja_environment_kwargs
         self.render_template_as_native_obj = render_template_as_native_obj
+
+        self.doc_md = self.get_doc_md(doc_md)
+
         self.tags = tags or []
         self._task_group = TaskGroup.create_root(self)
         self.validate_schedule_and_params()
 
+    def get_doc_md(self, doc_md: str) -> str:
+        if doc_md is None:
+            return doc_md
+
+        env = self.get_template_env(force_sandboxed=False)
+
+        if not doc_md.endswith('.md'):
+            template = jinja2.Template(doc_md)
+        else:
+            # template = env.loader.get_source(env, doc_md)[0]
+            template = env.get_template(doc_md)
+
+        return template.render()
+
+        return template.render()
+        # return pathlib.Path(doc_md).read_text() if pathlib.Path(str(doc_md 
or '')).is_file() else doc_md

Review Comment:
   removed as well



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