From 5f0b4e892924747c455a305b15f973161f355d97 Mon Sep 17 00:00:00 2001 From: Jiri Pavela Date: Wed, 25 Sep 2024 18:58:50 +0200 Subject: [PATCH] Add perun version and timestamp to diff views --- perun/templates/diff_view_datatables.html.jinja2 | 6 ++++++ perun/templates/diff_view_flamegraph.html.jinja2 | 6 ++++++ perun/templates/diff_view_report.html.jinja2 | 6 ++++++ perun/templates/diff_view_sankey.html.jinja2 | 6 ++++++ perun/view_diff/datatables/run.py | 4 ++++ perun/view_diff/flamegraph/run.py | 4 ++++ perun/view_diff/report/run.py | 4 ++++ perun/view_diff/sankey/run.py | 4 ++++ 8 files changed, 40 insertions(+) diff --git a/perun/templates/diff_view_datatables.html.jinja2 b/perun/templates/diff_view_datatables.html.jinja2 index d3514c33..f60c2992 100755 --- a/perun/templates/diff_view_datatables.html.jinja2 +++ b/perun/templates/diff_view_datatables.html.jinja2 @@ -24,6 +24,9 @@ .right { float: right; } + .header-center { + text-align: center; + } .column-head { border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; @@ -83,6 +86,9 @@ +

Diff View Generated by Perun v{{ perun_version }}

+

{{ timestamp }}

+

{{ lhs_tag }}

{{ profile_overview.overview_table('toggleSpecificationCollapse', 'left-specification-info', lhs_header, "Profile Specification") }} diff --git a/perun/templates/diff_view_flamegraph.html.jinja2 b/perun/templates/diff_view_flamegraph.html.jinja2 index e7483ea5..c3818948 100755 --- a/perun/templates/diff_view_flamegraph.html.jinja2 +++ b/perun/templates/diff_view_flamegraph.html.jinja2 @@ -31,6 +31,9 @@ .right { float: right; } + .header-center { + text-align: center; + } .column-head { border-bottom: 1px solid #ddd; text-align: center; @@ -97,6 +100,9 @@ +

Diff View Generated by Perun v{{ perun_version }}

+

{{ timestamp }}

+

{{ lhs_tag }}

{{ profile_overview.overview_table('toggleSpecificationCollapse', 'left-specification-info', lhs_header, "Profile Specification") }} diff --git a/perun/templates/diff_view_report.html.jinja2 b/perun/templates/diff_view_report.html.jinja2 index 158a3efc..5f1c265d 100755 --- a/perun/templates/diff_view_report.html.jinja2 +++ b/perun/templates/diff_view_report.html.jinja2 @@ -36,6 +36,9 @@ .help { font-size: 8pt; } + .header-center { + text-align: center; + } .column-head { border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; @@ -173,6 +176,9 @@ +

Diff View Generated by Perun v{{ perun_version }}

+

{{ timestamp }}

+

{{ lhs_tag }}

{{ profile_overview.overview_table('toggleSpecificationCollapse', 'left-specification-info', lhs_header, "Profile Specification") }} diff --git a/perun/templates/diff_view_sankey.html.jinja2 b/perun/templates/diff_view_sankey.html.jinja2 index d5226dd8..b4ee476a 100755 --- a/perun/templates/diff_view_sankey.html.jinja2 +++ b/perun/templates/diff_view_sankey.html.jinja2 @@ -31,6 +31,9 @@ margin: 0 1%; justify-content: center; } + .header-center { + text-align: center; + } .column-head { border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; @@ -81,6 +84,9 @@ +

Diff View Generated by Perun v{{ perun_version }}

+

{{ timestamp }}

+

{{ lhs_tag }}

{{ profile_overview.overview_table('toggleSpecificationCollapse', 'left-specification-info', lhs_header, "Profile Specification") }} diff --git a/perun/view_diff/datatables/run.py b/perun/view_diff/datatables/run.py index 9878f990..ddece8d8 100755 --- a/perun/view_diff/datatables/run.py +++ b/perun/view_diff/datatables/run.py @@ -4,12 +4,14 @@ # Standard Imports from dataclasses import dataclass +from datetime import datetime, timezone from typing import Any # Third-Party Imports import click # Perun Imports +import perun from perun.templates import factory as templates from perun.utils import log from perun.utils.common import diff_kit, traces_kit @@ -211,6 +213,8 @@ def generate_html_report(lhs_profile: Profile, rhs_profile: Profile, **kwargs: A lhs_header, rhs_header = diff_kit.generate_headers(lhs_profile, rhs_profile) template = templates.get_template("diff_view_datatables.html.jinja2") content = template.render( + perun_version=perun.__version__, + timestamp=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + " UTC", lhs_tag="Baseline (base)", lhs_columns=columns, lhs_data=lhs_data, diff --git a/perun/view_diff/flamegraph/run.py b/perun/view_diff/flamegraph/run.py index 41340608..df5c9e7b 100755 --- a/perun/view_diff/flamegraph/run.py +++ b/perun/view_diff/flamegraph/run.py @@ -4,6 +4,7 @@ # Standard Imports from collections import defaultdict +from datetime import datetime, timezone from subprocess import CalledProcessError from typing import Any, Optional import re @@ -12,6 +13,7 @@ import click # Perun Imports +import perun from perun.templates import factory as templates from perun.utils import log, mapping from perun.utils.common import common_kit, diff_kit @@ -261,6 +263,8 @@ def generate_flamegraph_difference( template = templates.get_template("diff_view_flamegraph.html.jinja2") content = template.render( flamegraphs=flamegraphs, + perun_version=perun.__version__, + timestamp=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + " UTC", lhs_header=lhs_header, lhs_tag="Baseline (base)", lhs_top=table_run.get_top_n_records(lhs_profile, top_n=10, aggregated_key=data_type), diff --git a/perun/view_diff/report/run.py b/perun/view_diff/report/run.py index 1efdac65..725be79d 100755 --- a/perun/view_diff/report/run.py +++ b/perun/view_diff/report/run.py @@ -18,6 +18,7 @@ import array from collections import defaultdict from dataclasses import dataclass +from datetime import datetime, timezone from operator import itemgetter import sys from typing import Any, Literal, Type, Callable @@ -26,6 +27,7 @@ import click # Perun Imports +import perun from perun.logic import config from perun.profile import convert, stats as profile_stats from perun.profile.factory import Profile @@ -748,6 +750,8 @@ def generate_report(lhs_profile: Profile, rhs_profile: Profile, **kwargs: Any) - template = templates.get_template("diff_view_report.html.jinja2", filters=env_filters) content = template.render( title="Differences of profiles (with sankey)", + perun_version=perun.__version__, + timestamp=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + " UTC", lhs_tag="Baseline (base)", lhs_header=lhs_header, lhs_stats=lhs_diff_stats, diff --git a/perun/view_diff/sankey/run.py b/perun/view_diff/sankey/run.py index ffe0204c..f6f4d5e0 100755 --- a/perun/view_diff/sankey/run.py +++ b/perun/view_diff/sankey/run.py @@ -17,12 +17,14 @@ # Standard Imports from collections import defaultdict from dataclasses import dataclass +from datetime import datetime, timezone from typing import Any, Literal # Third-Party Imports import click # Perun Imports +import perun from perun.templates import factory as templates from perun.profile import convert from perun.profile.factory import Profile @@ -532,6 +534,8 @@ def generate_sankey_difference(lhs_profile: Profile, rhs_profile: Profile, **kwa template = templates.get_template("diff_view_sankey.html.jinja2") content = template.render( title="Differences of profiles (with sankey)", + perun_version=perun.__version__, + timestamp=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + " UTC", lhs_tag="Baseline (base)", lhs_header=lhs_header, rhs_tag="Target (tgt)",