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 2020/10/03 13:07:50 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #11257: Improve code quality of SLA mechanism in SchedulerJob

turbaszek commented on a change in pull request #11257:
URL: https://github.com/apache/airflow/pull/11257#discussion_r499146538



##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -453,21 +453,19 @@ def manage_slas(self, dag: DAG, session: Session = None) -> None:
             notification_sent = False
             if dag.sla_miss_callback:
                 # Execute the alert callback
-                self.log.info(' --------------> ABOUT TO CALL SLA MISS CALL BACK ')
+                self.log.info('Calling SLA miss callback')
                 try:
                     dag.sla_miss_callback(dag, task_list, blocking_task_list, slas,
                                           blocking_tis)
                     notification_sent = True
                 except Exception:  # pylint: disable=broad-except
-                    self.log.exception("Could not call sla_miss_callback for DAG %s",
-                                       dag.dag_id)
-            email_content = """\
+                    self.log.exception("Could not call sla_miss_callback for DAG %s", dag.dag_id)
+            email_content = f"""\
             Here's a list of tasks that missed their SLAs:
             <pre><code>{task_list}\n<code></pre>
             Blocking tasks:
-            <pre><code>{blocking_task_list}\n{bug}<code></pre>
-            """.format(task_list=task_list, blocking_task_list=blocking_task_list,
-                       bug=asciiart.bug)
+            <pre><code>{blocking_task_list}<code></pre>
+            """

Review comment:
       I'm wondering if we should remove the indentation for this string:
   ```
   In [1]: x = """\
      ...:             Here's a list of tasks that missed their SLAs:
      ...:             <pre><code>{task_list}\n<code></pre>
      ...:             Blocking tasks:
      ...:             <pre><code>{blocking_task_list}\n{bug}<code></pre>
      ...:             """
   
   In [2]:
   
   In [2]: print(x)
               Here's a list of tasks that missed their SLAs:
               <pre><code>{task_list}
   <code></pre>
               Blocking tasks:
               <pre><code>{blocking_task_list}
   {bug}<code></pre>
   ```




----------------------------------------------------------------
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:
users@infra.apache.org