Skip to content
Projects

scope_profiler.astro_site

Astro/Starlight content for a catalogue of profiling runs.

scope-profiler site MANIFEST -o DOCS reads a YAML manifest that lists cases (each a set of profiling files) and writes the pages and chart data of a catalogue into an Astro project, where the site’s own build turns them into a website. Nothing here renders HTML: a page is an MDX file of components plus a JSON data file holding what it shows (the models of :mod:scope_profiler.report_model, the same ones the HTML report is drawn from), and charts are the plot-data JSON the HTML report embeds, drawn in the browser by @scope-profiler/plotly.

The manifest::

title: Profiling catalogue
description: Runs of my code.
base: /my-catalogue # the site's base path: "/" plus the repo name
defaults: {scaling: strong, speedup_x: auto}
cases:
- id: poisson # default: the slug of the title
title: Poisson solver
description: Strong scaling of the solver.
group: Solvers # optional: nests the case in a sidebar group
tags: [cpu, scaling]
scaling: strong # strong, weak, both or none
metadata: minimal # or "all": publish every metadata field
info: {commit: 843a82cd}
runs:
- {path: data/np1.h5, label: 1 rank}
- {path: "data/np*.h5"} # globs, relative to the manifest

Attributes

NameDescription
COMPONENTSNo description.
CONTENT_DIRNo description.
FIGURE_SUFFIXESNo description.
HOTSPOTSNo description.
IMAGE_SUFFIXESNo description.
LANGUAGESNo description.
MARKERNo description.
MAX_CHART_BYTESNo description.
MAX_COPIED_FILE_BYTESNo description.
MAX_SHOWN_FILE_BYTESNo description.
METADATA_KEYSNo description.
PUBLIC_DIRNo description.
REFERENCE_RUNSNo description.
SCALING_CHOICESNo description.

Classes

NameDescription
CaseA set of runs shown together; runs is the latest execution's when it has several.
CodeSpecCode shown at the bottom of a case: a file of the manifest's tree, a link, or both.
ExecutionOne execution of a case that is run again and again (a nightly job): a set of runs.
ManifestThe parsed catalogue manifest.
RunSpecOne profiling file of a case.
SiteErrorThe manifest is invalid, or the site cannot be written.
SiteResultWhat :func:build_site wrote.

Functions

NameDescription
build_siteWrite the catalogue's pages and chart data into the Astro project output.
load_manifestRead and validate a catalogue manifest.
slugifyLower-case text into a URL- and file-name-safe slug.

COMPONENTSattributemodule attribute#

COMPONENTS = Path('src/components/report')

CONTENT_DIRattributemodule attribute#

CONTENT_DIR = Path('src/content/docs/catalogue')

FIGURE_SUFFIXESattributemodule attribute#

FIGURE_SUFFIXES = (*IMAGE_SUFFIXES, '.pdf')

HOTSPOTSattributemodule attribute#

HOTSPOTS = 15

IMAGE_SUFFIXESattributemodule attribute#

IMAGE_SUFFIXES = ('.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg')

LANGUAGESattributemodule attribute#

LANGUAGES = {
  '.py': 'python',
  '.yml': 'yaml',
  '.yaml': 'yaml',
  '.json': 'json',
  '.toml': 'toml',
  '.sh': 'bash',
  '.bash': 'bash',
  '.md': 'markdown',
  '.ini': 'ini',
  '.cfg': 'ini',
  '.c': 'c',
  '.h': 'c',
  '.cpp': 'cpp',
  '.hpp': 'cpp',
  '.f90': 'fortran',
  '.f': 'fortran',
  '.jl': 'julia',
  '.m': 'matlab',
  '.sbatch': 'bash',
  '.slurm': 'bash'
}

MARKERattributemodule attribute#

MARKER = '.scope-profiler-site'

MAX_CHART_BYTESattributemodule attribute#

MAX_CHART_BYTES = 8000000

MAX_COPIED_FILE_BYTESattributemodule attribute#

MAX_COPIED_FILE_BYTES = 20000000

MAX_SHOWN_FILE_BYTESattributemodule attribute#

MAX_SHOWN_FILE_BYTES = 200000

METADATA_KEYSattributemodule attribute#

METADATA_KEYS = (
  'timestamp',
  'platform',
  'chip_information',
  'python_version',
  'scope_profiler_version',
  'omp_num_threads',
  'mpi_size',
  'total_cores',
  'num_nodes'
)

PUBLIC_DIRattributemodule attribute#

PUBLIC_DIR = Path('public/catalogue')

REFERENCE_RUNSattributemodule attribute#

REFERENCE_RUNS = 4

SCALING_CHOICESattributemodule attribute#

SCALING_CHOICES = ('strong', 'weak', 'both', 'none')

Caseclassdataclass#

class Case(id: str, title: str, runs: tuple[RunSpec, ...], description: str = '', group: str | None = None, tags: tuple[str, ...] = (), scaling: str = 'strong', speedup_x: str = 'auto', info: dict = dict(), include: tuple[str, ...] | None = None, exclude: tuple[str, ...] | None = None, ranks: tuple[int, ...] | None = None, charts: bool = True, metadata: str = 'minimal', files: tuple[Path, ...] = (), executions: tuple[Execution, ...] = (), images: tuple[Path, ...] = (), code: tuple[CodeSpec, ...] = ())

A set of runs shown together; runs is the latest execution’s when it has several.

chartsattributeclass attributeinstance attribute#

charts: bool = True

codeattributeclass attributeinstance attribute#

code: tuple[CodeSpec, ...] = ()

descriptionattributeclass attributeinstance attribute#

description: str = ''

excludeattributeclass attributeinstance attribute#

exclude: tuple[str, ...] | None = None

executionsattributeclass attributeinstance attribute#

executions: tuple[Execution, ...] = ()

filesattributeclass attributeinstance attribute#

files: tuple[Path, ...] = ()

groupattributeclass attributeinstance attribute#

group: str | None = None

idattributeinstance attribute#

id: str

imagesattributeclass attributeinstance attribute#

images: tuple[Path, ...] = ()

includeattributeclass attributeinstance attribute#

include: tuple[str, ...] | None = None

infoattributeclass attributeinstance attribute#

info: dict = field(default_factory=dict)

metadataattributeclass attributeinstance attribute#

metadata: str = 'minimal'

ranksattributeclass attributeinstance attribute#

ranks: tuple[int, ...] | None = None

runsattributeinstance attribute#

runs: tuple[RunSpec, ...]

scalingattributeclass attributeinstance attribute#

scaling: str = 'strong'

speedup_xattributeclass attributeinstance attribute#

speedup_x: str = 'auto'

tagsattributeclass attributeinstance attribute#

tags: tuple[str, ...] = ()

titleattributeinstance attribute#

title: str

CodeSpecclassdataclass#

class CodeSpec(path: Path | None = None, url: str | None = None, label: str | None = None)

Code shown at the bottom of a case: a file of the manifest’s tree, a link, or both.

labelattributeclass attributeinstance attribute#

label: str | None = None

pathattributeclass attributeinstance attribute#

path: Path | None = None

urlattributeclass attributeinstance attribute#

url: str | None = None

Executionclassdataclass#

class Execution(id: str, label: str, runs: tuple[RunSpec, ...], date: str | None = None, info: dict = dict())

One execution of a case that is run again and again (a nightly job): a set of runs.

dateattributeclass attributeinstance attribute#

date: str | None = None

idattributeinstance attribute#

id: str

infoattributeclass attributeinstance attribute#

info: dict = field(default_factory=dict)

labelattributeinstance attribute#

label: str

runsattributeinstance attribute#

runs: tuple[RunSpec, ...]

Manifestclassdataclass#

class Manifest(title: str, cases: tuple[Case, ...], description: str = '', base: str | None = None)

The parsed catalogue manifest.

baseattributeclass attributeinstance attribute#

base: str | None = None

casesattributeinstance attribute#

cases: tuple[Case, ...]

descriptionattributeclass attributeinstance attribute#

description: str = ''

titleattributeinstance attribute#

title: str

RunSpecclassdataclass#

class RunSpec(path: Path, label: str | None = None, files: tuple[Path, ...] = (), images: tuple[Path, ...] = ())

One profiling file of a case.

filesattributeclass attributeinstance attribute#

files: tuple[Path, ...] = ()

imagesattributeclass attributeinstance attribute#

images: tuple[Path, ...] = ()

labelattributeclass attributeinstance attribute#

label: str | None = None

pathattributeinstance attribute#

path: Path

SiteErrorclass#

class SiteError(ValueError)

Bases: ValueError

The manifest is invalid, or the site cannot be written.

SiteResultclassdataclass#

class SiteResult(files: list[Path], cases: int, runs: int, notes: list[str] = list())

What :func:build_site wrote.

casesattributeinstance attribute#

cases: int

filesattributeinstance attribute#

files: list[Path]

notesattributeclass attributeinstance attribute#

notes: list[str] = field(default_factory=list)

runsattributeinstance attribute#

runs: int

build_sitefunction#

def build_site(manifest: Manifest, output: str | Path = 'docs', *, base: str | None = None, charts: bool = True, clean: bool = True) -> SiteResult

Write the catalogue’s pages and chart data into the Astro project output.

Pages go to src/content/docs/catalogue (an MDX file and a JSON data file per page) and chart data to public/catalogue; both are replaced on every run, but only when a previous run wrote them (clean=False writes into them as they are).

base is the site’s base path (/repo on GitHub Pages), which the links between pages need; it defaults to the manifest’s base. Raises :class:SiteError without one, for runs that cannot be read, and for charts=True without scope-profiler[pproc].

load_manifestfunction#

def load_manifest(path: str | Path) -> Manifest

Read and validate a catalogue manifest.

Run paths are resolved against the manifest’s directory and globs are expanded (in natural order, so np2 precedes np10). Every error names the case and field it comes from.

slugifyfunction#

def slugify(text: str) -> str

Lower-case text into a URL- and file-name-safe slug.