Skip to content

pymetrix-guide

A plugin: a separate package

pymetrix-guide is a first-party plugin, installed on its own:

python -m pip install --pre pymetrix-guide

Guided case studies for pymetrix: follow a workflow step by step in the desktop app, with each step checked.

The names pymetrix_guide exports (its __all__), with their full documentation. Import them from the plugin: from pymetrix_guide import .... The plugin's README says more.

Public names

build_command

build_command(name: str, settings: dict[str, Any] | None = None) -> Any

The dialog command name (a class name in the registry) with settings; CaseStudyError says what is wrong (no such dialog, a field it does not have, one it needs).

case_studies

case_studies(session: object = None) -> list[CaseStudy]

The case studies found: the plugin's own, those in the loaded courses (Help → Course material…, or a pymetrix.courses package) and those in the session's project courses. A Markdown note is a case study when it has a pymetrix-step block.

CaseStudy dataclass

CaseStudy(title: str, steps: tuple[Step, ...], demo: str = '', level: str = '', closing: str = '', path: Path | None = None, problems: tuple[str, ...] = (), meta: dict[str, Any] = dict(), intro: tuple[IntroPage, ...] = (), summary: str = '', stages: tuple[str, ...] = (), warnings: tuple[str, ...] = (), files: tuple[tuple[Path, str], ...] = (), course: str = '')

CaseStudyError

Bases: ValueError

A case study with problems: each line N: what.

CaseStudyWarning

Bases: UserWarning

What a case study could do better (check_case_study): no introduction, a step with no text.

Check dataclass

Check(conditions: tuple[Condition, ...], text: str = '')

Every condition holds.

check_case_study

check_case_study(path: str | Path) -> CaseStudy

Read a case study and raise CaseStudyError listing its problems, if any: for a lecturer, before handing it out. What it could do better (no introduction, a step with no text) is said as a CaseStudyWarning each.

CheckError

Bases: ValueError

A check that is not in the grammar.

course_folders

course_folders() -> list[Path]

The course folders the plugin ships (each a course of case studies).

COURSES module-attribute

COURSES = Path(__file__).resolve().parent / 'courses'

IntroPage dataclass

IntroPage(title: str, text: str = '')

A page of the introduction, shown before step 1: a ## section before the first step.

load_courses

load_courses() -> None

The pymetrix.courses entry point: the plugin's case studies, as course material in the help.

parse

parse(text: str, path: str | Path | None = None) -> CaseStudy

A case study from its Markdown. Bad blocks are left out and reported (problems), with their line.

parse_check

parse_check(text: str) -> Check

A check from its text; CheckError says what the grammar allows.

read

read(path: str | Path) -> CaseStudy

A case study from its file.

Step dataclass

Step(title: str, text: str = '', command: str = '', settings: dict[str, Any] = dict(), check: Check | None = None, line: int = 0, stage: str = '', why: str = '', look: str = '')

One step: its narrative (Markdown), title, dialog and settings, and the check that ticks it.

walkthroughs

walkthroughs() -> list[CaseStudy]

Every task page that is a walkthrough, as a case study, in the pages' order ([] with a pymetrix that has none). A page whose walkthrough cannot be made is a case study with that problem, so the panel says so.

Plugin plumbing

What pymetrix's plugin loader reads (PLUGIN, register) and the plugin's version.

PLUGIN module-attribute

PLUGIN = PluginInfo(name='pymetrix-guide', version=__version__, api='1.5', license='BSD-3-Clause', maintainer='Geoffrey Heenan', description='Guided case studies: follow a workflow step by step in the desktop app, with each step checked')

register

register() -> None

The entry point: register the Guide panel (once). Qt is imported only when the app builds the panel.