You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/12/09 12:22:42 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #20165: Log filename template records

uranusjr commented on a change in pull request #20165:
URL: https://github.com/apache/airflow/pull/20165#discussion_r765737767



##########
File path: airflow/models/dagrun.py
##########
@@ -931,3 +945,13 @@ def schedule_tis(self, schedulable_tis: Iterable[TI], session: Session = NEW_SES
             )
 
         return count
+
+    @provide_session
+    def get_log_filename_template(self, *, session: Session = NEW_SESSION) -> Optional[str]:
+        if self.log_filename_id is None:  # DagRun created before LogFilename introduction.
+            template = session.query(LogFilename.template).order_by(LogFilename.id).limit(1).scalar()
+        else:
+            template = session.query(LogFilename.template).filter_by(id=self.log_filename_id).one_or_none()
+        if template is not None:
+            return template
+        return airflow_conf.get("logging", "LOG_FILENAME_TEMPLATE")

Review comment:
       I’m not sure if setting up a relationship (for caching) is worthwile. Maybe?




-- 
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: commits-unsubscribe@airflow.apache.org

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