Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/dvsim/cli/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import click

from dvsim.instrumentation.report.profile import RenderProfile


@click.group()
@click.version_option(version("dvsim"))
Expand Down Expand Up @@ -62,7 +64,7 @@ def dashboard_gen(json_path: Path, output_dir: Path, base_url: str | None) -> No

@cli.group()
def report() -> None:
"""Reporting helper commands."""
"""Reporting helper commands.""" # noqa: D401


@report.command("gen")
Expand Down Expand Up @@ -91,5 +93,28 @@ def report_gen(json_path: Path, output_dir: Path) -> None:
)


@report.command(
"instrumentation", short_help="Generate an instrumentation report from existing metrics."
)
@click.argument(
"json_path",
type=click.Path(exists=True, file_okay=True, dir_okay=False, path_type=Path),
)
@click.argument("output_dir", type=click.Path(file_okay=False, dir_okay=True, path_type=Path))
@click.option(
"--profile",
type=click.Choice([e.value for e in RenderProfile], case_sensitive=False),
help="Set the rendering profile to control the detail vs. report optimization",
)
def instrumentation_report_gen(json_path: Path, output_dir: Path, profile: str | None) -> None:
"""Generate an instrumentation report from an existing metrics JSON."""
from dvsim.instrumentation.records import InstrumentationResults # noqa: PLC0415
from dvsim.instrumentation.runtime import gen_html_report # noqa: PLC0415

render_profile = None if profile is None else RenderProfile(profile)
results = InstrumentationResults.model_validate_json(json_path.read_text(encoding="utf-8"))
gen_html_report(results, profile=render_profile, outdir=output_dir)


if __name__ == "__main__":
sys.exit(cli())
3 changes: 2 additions & 1 deletion src/dvsim/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
from pathlib import Path

from dvsim.flow.factory import make_cfg
from dvsim.instrumentation import InstrumentationFactory, set_instrumentation
from dvsim.instrumentation.factory import InstrumentationFactory
from dvsim.instrumentation.runtime import set_instrumentation
from dvsim.job.deploy import RunTest
from dvsim.launcher.base import Launcher
from dvsim.launcher.lsf import LsfLauncher
Expand Down
2 changes: 1 addition & 1 deletion src/dvsim/flow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import hjson

from dvsim import instrumentation
import dvsim.instrumentation.runtime as instrumentation
from dvsim.flow.hjson import set_target_attribute
from dvsim.job.data import CompletedJobStatus, JobSpec, WorkspaceConfig
from dvsim.job.status import JobStatus
Expand Down
33 changes: 0 additions & 33 deletions src/dvsim/instrumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,3 @@
# SPDX-License-Identifier: Apache-2.0

"""DVSim Scheduler Instrumentation."""

from dvsim.instrumentation.base import InstrumentationAggregator, SchedulerInstrumentation
from dvsim.instrumentation.factory import InstrumentationFactory
from dvsim.instrumentation.records import (
InstrumentationMetrics,
InstrumentationResults,
JobMetrics,
SchedulerMetrics,
)
from dvsim.instrumentation.runtime import (
flush,
gen_html_report,
get,
get_report,
set_instrumentation,
set_report_path,
)

__all__ = (
"InstrumentationAggregator",
"InstrumentationFactory",
"InstrumentationMetrics",
"InstrumentationResults",
"JobMetrics",
"SchedulerInstrumentation",
"SchedulerMetrics",
"flush",
"gen_html_report",
"get",
"get_report",
"set_instrumentation",
"set_report_path",
)
14 changes: 0 additions & 14 deletions src/dvsim/instrumentation/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,3 @@
# SPDX-License-Identifier: Apache-2.0

"""DVSim Scheduler Instrumentation report."""

from dvsim.instrumentation.report.base import (
InstrumentationVisualizer,
RenderProfile,
render_html_report,
)
from dvsim.instrumentation.report.registry import ReportVisualizationRegistry

__all__ = (
"InstrumentationVisualizer",
"RenderProfile",
"ReportVisualizationRegistry",
"render_html_report",
)
13 changes: 2 additions & 11 deletions src/dvsim/instrumentation/report/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""DVSim scheduler instrumentation reporting & visualizations."""

from collections.abc import Iterable, Mapping, Sequence
from enum import Enum
from pathlib import Path
from typing import Any, Protocol, TypeVar

Expand All @@ -14,8 +13,8 @@
import plotly.offline
from typing_extensions import Self

from dvsim.instrumentation import InstrumentationResults
from dvsim.instrumentation.records import JobInstrumentationMetadata
from dvsim.instrumentation.records import InstrumentationResults, JobInstrumentationMetadata
from dvsim.instrumentation.report.profile import RenderProfile
from dvsim.logging import log
from dvsim.report.artifacts import ReportArtifacts, render_static_content
from dvsim.templates.render import render_template
Expand Down Expand Up @@ -46,14 +45,6 @@
}


class RenderProfile(Enum):
"""Levels of visualization rendering detail, which impact report size & responsiveness."""

NORMAL = "normal"
HIGH = "high"
FULL = "full"


class InstrumentationVisualizer(Protocol):
"""Builder & renderer for HTML instrumentation visualizations."""

Expand Down
3 changes: 1 addition & 2 deletions src/dvsim/instrumentation/report/breakdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import plotly.graph_objects as go
from plotly.subplots import make_subplots

from dvsim.instrumentation import InstrumentationResults
from dvsim.instrumentation.records import JobInstrumentationResults
from dvsim.instrumentation.records import InstrumentationResults, JobInstrumentationResults
from dvsim.instrumentation.report.base import (
DEFAULT_VISUALIZATION_HEIGHT_PX,
PLOTLY_TIMING_AXIS_CONFIG,
Expand Down
4 changes: 2 additions & 2 deletions src/dvsim/instrumentation/report/longest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
import plotly.graph_objects as go
from typing_extensions import Self

from dvsim.instrumentation import InstrumentationResults
from dvsim.instrumentation.records import (
ConcreteJobTimingMetrics,
InstrumentationResults,
JobInstrumentationMetadata,
JobInstrumentationResults,
)
from dvsim.instrumentation.report.base import (
DEFAULT_VISUALIZATION_HEIGHT_PX,
PLOTLY_TIMING_AXIS_CONFIG,
InstrumentationVisualizer,
RenderProfile,
get_default_color_map,
make_job_metadata_hover,
render_plotly_figure,
)
from dvsim.instrumentation.report.profile import RenderProfile
from dvsim.job.status import JobStatus
from dvsim.logging import log
from dvsim.utils import format_time_metric, ordinal_suffix
Expand Down
15 changes: 15 additions & 0 deletions src/dvsim/instrumentation/report/profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""DVSim scheduler instrumentation reporting rendering profiles/levels."""

from enum import Enum


class RenderProfile(Enum):
"""Levels of visualization rendering detail, which impact report size & responsiveness."""

NORMAL = "normal"
HIGH = "high"
FULL = "full"
3 changes: 2 additions & 1 deletion src/dvsim/instrumentation/report/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from typing import ClassVar

from dvsim.instrumentation.report.base import InstrumentationVisualizer, RenderProfile
from dvsim.instrumentation.report.base import InstrumentationVisualizer
from dvsim.instrumentation.report.breakdown import BlockVariantBreakdown, ToolBreakdown
from dvsim.instrumentation.report.longest import (
LongestByBlockChart,
Expand All @@ -15,6 +15,7 @@
LongestTestsByBlockChart,
LongestTestsByToolChart,
)
from dvsim.instrumentation.report.profile import RenderProfile
from dvsim.instrumentation.report.timelines import ParallelismChart, TimelineBarChart
from dvsim.instrumentation.report.usage import ToolUsageLineGraph

Expand Down
5 changes: 2 additions & 3 deletions src/dvsim/instrumentation/report/timelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
from matplotlib.ticker import MaxNLocator
from typing_extensions import Self, override

from dvsim.instrumentation import InstrumentationResults
from dvsim.instrumentation.records import ConcreteJobTimingMetrics
from dvsim.instrumentation.records import ConcreteJobTimingMetrics, InstrumentationResults
from dvsim.instrumentation.report.base import (
DEFAULT_VISUALIZATION_HEIGHT_PX,
PLOTLY_TIMING_AXIS_CONFIG,
InstrumentationVisualizer,
RenderProfile,
get_default_color_map,
make_job_metadata_hover,
render_plotly_figure,
)
from dvsim.instrumentation.report.profile import RenderProfile
from dvsim.logging import log
from dvsim.utils import format_time_as_hms as format_time
from dvsim.utils import format_time_metric
Expand Down
7 changes: 5 additions & 2 deletions src/dvsim/instrumentation/report/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import plotly.graph_objects as go
from plotly.graph_objs import Figure

from dvsim.instrumentation import InstrumentationResults
from dvsim.instrumentation.records import ConcreteJobTimingMetrics, JobInstrumentationResults
from dvsim.instrumentation.records import (
ConcreteJobTimingMetrics,
InstrumentationResults,
JobInstrumentationResults,
)
from dvsim.instrumentation.report.base import (
DEFAULT_VISUALIZATION_HEIGHT_PX,
PLOTLY_TIMING_AXIS_CONFIG,
Expand Down
8 changes: 3 additions & 5 deletions src/dvsim/instrumentation/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
from pathlib import Path

from dvsim.instrumentation.base import InstrumentationAggregator, InstrumentationResults
from dvsim.instrumentation.report import (
RenderProfile,
ReportVisualizationRegistry,
render_html_report,
)
from dvsim.instrumentation.report.base import render_html_report
from dvsim.instrumentation.report.profile import RenderProfile
from dvsim.instrumentation.report.registry import ReportVisualizationRegistry
from dvsim.logging import log

__all__ = (
Expand Down
2 changes: 1 addition & 1 deletion src/dvsim/scheduler/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from collections.abc import Iterable

from dvsim import instrumentation
import dvsim.instrumentation.runtime as instrumentation
from dvsim.job.data import CompletedJobStatus, JobSpec
from dvsim.runtime.backend import RuntimeBackend
from dvsim.runtime.fake import FakePolicy, FakeRuntimeBackend
Expand Down
Loading