def sla_miss_report():
    """Embed all the resultant output datframes within html format and send the email report to the intented recipients."""

    sla_run_detail, serialized_dags_slas = retrieve_metadata()
    daily_slamiss_pct_last7days = sla_daily_miss(sla_run_detail)
    observations_hourly_reccomendations, sla_miss_percent_past_day_hourly = sla_hourly_miss(sla_run_detail)
    daily_weeklytrend_observations_loop, dag_sla_miss_trend, dag_sla_miss_pct_filtered = sla_dag_miss(
        sla_run_detail, serialized_dags_slas)

    new_line = '\n'
    print(f"""
------------------- START OF REPORT -------------------
{EMAIL_SUBJECT}

Daily SLA Misses
{new_line.join(map(str, daily_weeklytrend_observations_loop))}

{daily_slamiss_pct_last7days.to_markdown(index=False)}

Hourly SLA Misses
{new_line.join(map(str, observations_hourly_reccomendations))}

{sla_miss_percent_past_day_hourly.to_markdown(index=False)}

DAG SLA Misses
{new_line.join(map(str, dag_sla_miss_trend))}

{dag_sla_miss_pct_filtered.to_markdown(index=False)}

------------------- END OF REPORT -------------------
    """)

    daily_weeklytrend_observations_loop = "".join([f"<li>{item}</li>" for item in daily_weeklytrend_observations_loop])
    observations_hourly_reccomendations = "".join([f"<li>{item}</li>" for item in observations_hourly_reccomendations])
    dag_sla_miss_trend = "".join([f"<li>{item}</li>" for item in dag_sla_miss_trend])

    short_timeframe_print = f'<b>Short</b>: {SHORT_TIMEFRAME_IN_DAYS}d ({short_timeframe_start_date.strftime("%b %d")} - {(today - timedelta(days=1)).strftime("%b %d")})'
    medium_timeframe_print = f'<b>Medium</b>: {MEDIUM_TIMEFRAME_IN_DAYS}d ({medium_timeframe_start_date.strftime("%b %d")} - {(today - timedelta(days=1)).strftime("%b %d")})'
    long_timeframe_print = f'<b>Long</b>: {LONG_TIMEFRAME_IN_DAYS}d ({long_timeframe_start_date.strftime("%b %d")} - {(today - timedelta(days=1)).strftime("%b %d")})'
    timeframe_prints = f'{short_timeframe_print} | {medium_timeframe_print} | {long_timeframe_print}'

    html_content = f"""\
    <html>
    <head>
    <style>
    table {{
    font-family: Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
    }}

    td, th {{
    border: 1px solid #ddd;
    padding: 8px;
    }}

    th {{
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: left;
    background-color: #154360;
    color: white;
    }}

    td {{
    text-align: left;
    background-color: #EBF5FB;
    }}
    </style>
    </head>
    <body>
    The following timeframes are used to generate this report. To change them, update the [SHORT, MEDIUM, LONG]_TIMEFRAME_IN_DAYS variables in airflow-sla-miss-report.py.
    <br></br><br></br>
    {timeframe_prints}

    <h2>Daily SLA Misses</h2>
    <p>Daily breakdown of SLA misses and the <b>worst offenders</b> over the past {LONG_TIMEFRAME_IN_DAYS} day(s).</p>
    {daily_weeklytrend_observations_loop}
    {daily_slamiss_pct_last7days.to_html(index=False)}


    <h2>Hourly SLA Misses</h2>
    <p>Hourly breakdown of tasks missing their SLAs and the worst offenders over the past {SHORT_TIMEFRAME_IN_DAYS} day(s). Useful for identifying <b>scheduling bottlenecks</b>.</p>
    {observations_hourly_reccomendations}
    {sla_miss_percent_past_day_hourly.to_html(index=False)}

    <h2>DAG SLA Misses</h2>
    <p>Task level breakdown showcasing the SLA miss percentage & average execution time over the past {SHORT_TIMEFRAME_IN_DAYS}, {MEDIUM_TIMEFRAME_IN_DAYS}, and {LONG_TIMEFRAME_IN_DAYS} day(s). Useful for <b>identifying trends and updating defined SLAs</b> to meet actual exectution times.</p>
    {dag_sla_miss_trend}
    {dag_sla_miss_pct_filtered.to_html(index=False)}

    </body>
    </html>
    """
    if EMAIL_ADDRESSES:
        send_email(to=EMAIL_ADDRESSES, subject=EMAIL_SUBJECT, html_content=html_content)
Embed all the resultant output datframes within html format and send the email report to the intented recipients.
sla-miss-report/airflow-sla-miss-report.py