pymetrix-guide 0.1.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .pytest_tmp/
6
+ .venv/
7
+ build/
8
+ dist/
9
+ .ipynb_checkpoints/
10
+ hs_err_pid*.log
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Geoffrey Heenan
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.5
2
+ Name: pymetrix-guide
3
+ Version: 0.1.0a1
4
+ Summary: Guided case studies for pymetrix: follow a workflow step by step in the desktop app, with each step checked
5
+ Project-URL: Homepage, https://github.com/GeoffHeenan/pymetrix
6
+ Project-URL: Source, https://github.com/GeoffHeenan/pymetrix/tree/main/packages/pymetrix-guide
7
+ Project-URL: Issues, https://github.com/GeoffHeenan/pymetrix/issues
8
+ Project-URL: Changelog, https://github.com/GeoffHeenan/pymetrix/blob/main/CHANGELOG.md
9
+ Author: Geoffrey Heenan
10
+ License-Expression: BSD-3-Clause
11
+ License-File: LICENSE
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: pymetrix>=0.1.0a10
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=9.0.3; extra == 'test'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # pymetrix-guide
19
+
20
+ Guided case studies for pymetrix, as a plugin: a trainee follows a workflow step by step in the desktop app,
21
+ through the app's real dialogs, and each step is checked as they go. Experimental.
22
+
23
+ ```bash
24
+ pip install -e packages/pymetrix-guide # from the repository (not on PyPI yet)
25
+ ```
26
+
27
+ Once installed, the app has a **Guide** panel (View → Guide). It lists the case studies in the loaded course
28
+ material: the plugin's own, folders added with **Help → Course material…** or `PYMETRIX_COURSES`, courses
29
+ published as packages, and the courses saved with the open project. For the chosen case study it shows:
30
+
31
+ - its summary under the title, and its introduction first: a page for each `##` section before the first step
32
+ (for Lab 3, an overview of the forecast workflow, how the app keeps the record, this scenario, and how to use the
33
+ guide);
34
+ - one step at a time: its text, why it is done and what to look for in its result, and progress
35
+ ("Stage: Judgement — step 8 of 19 · 7 done"), with the stages of the workflow as a strip, the current one in bold;
36
+ - **Open…**: the step's dialog, filled in. The trainee looks at it, changes it or not, and presses OK;
37
+ - **Show me**: runs the step as written;
38
+ - a tick on each step whose check passes. Ticks follow the history, so **Undo** takes one back and **Redo** gives it
39
+ again;
40
+ - **Back** and **Next**, through the introduction and then the steps, and **Start over**: the introduction's first
41
+ page, and the case study's demo project again;
42
+ - for a case study that starts from a demo project (`demo:`), an offer to open it while another project is open.
43
+ The demo opens as with **File → Open demo project…**: the app asks to save unsaved work first.
44
+
45
+ The steps are ordinary steps of the session: the History, **File → Export script**, the saved project and the
46
+ lab book (`pymetrix-labbook`) all record them. The guide keeps no record of its own.
47
+
48
+ The plugin ships Lab 3 of the example course, the quarterly forecast round (`examples/course/03_forecast_round`), as
49
+ its first case study: an introduction of four pages, then 19 steps in seven stages, from loading the data to the
50
+ report. It is a course in the `pymetrix.courses`
51
+ group, *Case studies (pymetrix-guide)*, so it is in the help as well.
52
+
53
+ ## The format
54
+
55
+ A case study is a Markdown file in a course folder. Narrative text goes between fenced blocks whose info string is
56
+ `pymetrix-step`:
57
+
58
+ ````markdown
59
+ ---
60
+ title: Lecture 1, guided. A consumption function
61
+ summary: A dynamic consumption function and its long-run propensity # optional
62
+ stages: [Data, Model, Interpret] # optional: the workflow's stages, in order
63
+ demo: consumption # optional: the demo project it starts from
64
+ level: introductory # optional
65
+ course: ECON 101 # the usual course front matter
66
+ links: [commands/FitEquation]
67
+ ---
68
+
69
+ # A consumption function
70
+
71
+ ## Overview
72
+
73
+ The workflow in general, in the setting of the example: the first page of the introduction.
74
+
75
+ ## This scenario
76
+
77
+ The data, the model and why, what is compared: the second page.
78
+
79
+ ---
80
+
81
+ Text before a step is that step's text: what to do.
82
+
83
+ ```pymetrix-step
84
+ title: Fit the consumption function
85
+ stage: Model
86
+ command: FitEquation
87
+ settings: {formula: "c ~ y + c[-1]", name: fit}
88
+ check: object fit is FittedEquation
89
+ why: The dynamic version: consumption adjusts to income over time.
90
+ look: The coefficient on c[-1]: the larger it is, the slower the adjustment.
91
+ ```
92
+
93
+ Text after the last step closes the case study: a recap, and where to go next.
94
+ ````
95
+
96
+ ### The introduction
97
+
98
+ When the text before the first step has `##` headings, it is the introduction: one page per `##` section, shown
99
+ before step 1 (text before the first `##`, other than the `#` title, is a page "Introduction"). The first step's
100
+ own text follows a line `---`, after a blank line, below the last section; without it the first step has no text
101
+ of its own. Without any `##` heading, the text before the first step is that step's text, as in earlier versions.
102
+
103
+ ### Front matter
104
+
105
+ | Key | Meaning |
106
+ |---|---|
107
+ | `title` | The case study's title in the panel (else its first `#` heading, else the file name). |
108
+ | `summary` | One line, shown under the title when the case study is chosen. |
109
+ | `stages` | The stages of the workflow, in order (`[Data, Model, Judgement]`): the panel's strip. Else the steps' own stages, in order. |
110
+ | `demo` | A demo project it starts from (`pymetrix.demos()`): the panel offers to open it, and Start over opens it again. |
111
+ | `level` | Free text, e.g. introductory. |
112
+ | `course`, `links`, `references` | As for any course note (see pymetrix's guide, "Help and course material"). |
113
+
114
+ ### A step
115
+
116
+ | Key | Meaning |
117
+ |---|---|
118
+ | `title` | Required. The step's name in the list. |
119
+ | `stage` | The stage of the workflow it belongs to; a step without one is in the stage of the step before. |
120
+ | `command` | A dialog's class name, as in the registry (`pymetrix.commands.COMMANDS`): `FitEquation`, `GenerateSeries`, `FitVAR`… |
121
+ | `settings` | The dialog's fields: `{field: value, ...}` on one line, or indented `field: value` lines below `settings:`. Values are text (quoted when they hold a comma, colon or brace), numbers, `true` or `false`. A number given for a text field is used as text. |
122
+ | `check` | What ticks the step (below). Without one the step never ticks; the trainee presses Next. |
123
+ | `why` | Its purpose, in a sentence: shown as "Why this step". |
124
+ | `look` | What to look at in its result, in a sentence: shown as "What to look for". |
125
+
126
+ A step needs a `command`, a `check` or both. Lines starting with `#` are comments.
127
+
128
+ ### Checks
129
+
130
+ A check is a declarative condition, never code. The grammar is:
131
+
132
+ | Check | Passes when |
133
+ |---|---|
134
+ | `object NAME exists` | an object called NAME is in the workspace |
135
+ | `object NAME is TYPE` | ... and its class, or a class it derives from, is called TYPE (`FittedEquation`, `Dataset`, `ForecastRound`) |
136
+ | `series NAME in DATASET` | the dataset DATASET has a series NAME |
137
+ | `step DIALOG ran` | a step of that dialog is in the history and ran without error (for steps that change an object in place) |
138
+ | `step DIALOG ran on NAME` | ... and read or wrote NAME |
139
+
140
+ Join conditions with `and`: `series ly in data and series lc in data`.
141
+
142
+ ### Checking a case study
143
+
144
+ A block that cannot be read is left out and reported with its line: in the panel, under the case study's name,
145
+ and by `check_case_study`, which raises on any problem. What would make it better is a warning
146
+ (`CaseStudyWarning`, and `study.warnings`), never an error: no introduction, a step with neither text nor `why`,
147
+ a stage not in `stages`, or a step with no stage when others have one.
148
+
149
+ ```python
150
+ from pymetrix_guide import check_case_study, read
151
+
152
+ check_case_study("my_course/week1_guided.md") # CaseStudyError: week1_guided.md: line 23: 'len(data) > 3' is not a check ...
153
+ study = read("my_course/week1_guided.md") # study.intro, study.steps, study.stages, study.problems, study.warnings
154
+ ```
155
+
156
+ It checks that each dialog exists, that the settings are its fields and that it can be built from them, and each
157
+ check against the grammar. `pymetrix.testing.check_course(folder)` checks the folder as course material.
158
+
159
+ ## Limits
160
+
161
+ - The panel opens a case study's demo through the app's interface (`AppInterface.open_demo`, extension API 1.7):
162
+ the app asks to save unsaved work first, and the trainee can cancel. With an older pymetrix (API 1.6 or earlier) the
163
+ panel says where to find the demo instead (**File → Open demo project…**, **File → Reload demo project**).
164
+ - Checks look at the workspace and the history, not at values: "the coefficient is about 0.9" is not a check.
165
+ - A step that writes files (Save round, Export report) writes them where the app's working folder is.
166
+
167
+ BSD-3-Clause.
@@ -0,0 +1,150 @@
1
+ # pymetrix-guide
2
+
3
+ Guided case studies for pymetrix, as a plugin: a trainee follows a workflow step by step in the desktop app,
4
+ through the app's real dialogs, and each step is checked as they go. Experimental.
5
+
6
+ ```bash
7
+ pip install -e packages/pymetrix-guide # from the repository (not on PyPI yet)
8
+ ```
9
+
10
+ Once installed, the app has a **Guide** panel (View → Guide). It lists the case studies in the loaded course
11
+ material: the plugin's own, folders added with **Help → Course material…** or `PYMETRIX_COURSES`, courses
12
+ published as packages, and the courses saved with the open project. For the chosen case study it shows:
13
+
14
+ - its summary under the title, and its introduction first: a page for each `##` section before the first step
15
+ (for Lab 3, an overview of the forecast workflow, how the app keeps the record, this scenario, and how to use the
16
+ guide);
17
+ - one step at a time: its text, why it is done and what to look for in its result, and progress
18
+ ("Stage: Judgement — step 8 of 19 · 7 done"), with the stages of the workflow as a strip, the current one in bold;
19
+ - **Open…**: the step's dialog, filled in. The trainee looks at it, changes it or not, and presses OK;
20
+ - **Show me**: runs the step as written;
21
+ - a tick on each step whose check passes. Ticks follow the history, so **Undo** takes one back and **Redo** gives it
22
+ again;
23
+ - **Back** and **Next**, through the introduction and then the steps, and **Start over**: the introduction's first
24
+ page, and the case study's demo project again;
25
+ - for a case study that starts from a demo project (`demo:`), an offer to open it while another project is open.
26
+ The demo opens as with **File → Open demo project…**: the app asks to save unsaved work first.
27
+
28
+ The steps are ordinary steps of the session: the History, **File → Export script**, the saved project and the
29
+ lab book (`pymetrix-labbook`) all record them. The guide keeps no record of its own.
30
+
31
+ The plugin ships Lab 3 of the example course, the quarterly forecast round (`examples/course/03_forecast_round`), as
32
+ its first case study: an introduction of four pages, then 19 steps in seven stages, from loading the data to the
33
+ report. It is a course in the `pymetrix.courses`
34
+ group, *Case studies (pymetrix-guide)*, so it is in the help as well.
35
+
36
+ ## The format
37
+
38
+ A case study is a Markdown file in a course folder. Narrative text goes between fenced blocks whose info string is
39
+ `pymetrix-step`:
40
+
41
+ ````markdown
42
+ ---
43
+ title: Lecture 1, guided. A consumption function
44
+ summary: A dynamic consumption function and its long-run propensity # optional
45
+ stages: [Data, Model, Interpret] # optional: the workflow's stages, in order
46
+ demo: consumption # optional: the demo project it starts from
47
+ level: introductory # optional
48
+ course: ECON 101 # the usual course front matter
49
+ links: [commands/FitEquation]
50
+ ---
51
+
52
+ # A consumption function
53
+
54
+ ## Overview
55
+
56
+ The workflow in general, in the setting of the example: the first page of the introduction.
57
+
58
+ ## This scenario
59
+
60
+ The data, the model and why, what is compared: the second page.
61
+
62
+ ---
63
+
64
+ Text before a step is that step's text: what to do.
65
+
66
+ ```pymetrix-step
67
+ title: Fit the consumption function
68
+ stage: Model
69
+ command: FitEquation
70
+ settings: {formula: "c ~ y + c[-1]", name: fit}
71
+ check: object fit is FittedEquation
72
+ why: The dynamic version: consumption adjusts to income over time.
73
+ look: The coefficient on c[-1]: the larger it is, the slower the adjustment.
74
+ ```
75
+
76
+ Text after the last step closes the case study: a recap, and where to go next.
77
+ ````
78
+
79
+ ### The introduction
80
+
81
+ When the text before the first step has `##` headings, it is the introduction: one page per `##` section, shown
82
+ before step 1 (text before the first `##`, other than the `#` title, is a page "Introduction"). The first step's
83
+ own text follows a line `---`, after a blank line, below the last section; without it the first step has no text
84
+ of its own. Without any `##` heading, the text before the first step is that step's text, as in earlier versions.
85
+
86
+ ### Front matter
87
+
88
+ | Key | Meaning |
89
+ |---|---|
90
+ | `title` | The case study's title in the panel (else its first `#` heading, else the file name). |
91
+ | `summary` | One line, shown under the title when the case study is chosen. |
92
+ | `stages` | The stages of the workflow, in order (`[Data, Model, Judgement]`): the panel's strip. Else the steps' own stages, in order. |
93
+ | `demo` | A demo project it starts from (`pymetrix.demos()`): the panel offers to open it, and Start over opens it again. |
94
+ | `level` | Free text, e.g. introductory. |
95
+ | `course`, `links`, `references` | As for any course note (see pymetrix's guide, "Help and course material"). |
96
+
97
+ ### A step
98
+
99
+ | Key | Meaning |
100
+ |---|---|
101
+ | `title` | Required. The step's name in the list. |
102
+ | `stage` | The stage of the workflow it belongs to; a step without one is in the stage of the step before. |
103
+ | `command` | A dialog's class name, as in the registry (`pymetrix.commands.COMMANDS`): `FitEquation`, `GenerateSeries`, `FitVAR`… |
104
+ | `settings` | The dialog's fields: `{field: value, ...}` on one line, or indented `field: value` lines below `settings:`. Values are text (quoted when they hold a comma, colon or brace), numbers, `true` or `false`. A number given for a text field is used as text. |
105
+ | `check` | What ticks the step (below). Without one the step never ticks; the trainee presses Next. |
106
+ | `why` | Its purpose, in a sentence: shown as "Why this step". |
107
+ | `look` | What to look at in its result, in a sentence: shown as "What to look for". |
108
+
109
+ A step needs a `command`, a `check` or both. Lines starting with `#` are comments.
110
+
111
+ ### Checks
112
+
113
+ A check is a declarative condition, never code. The grammar is:
114
+
115
+ | Check | Passes when |
116
+ |---|---|
117
+ | `object NAME exists` | an object called NAME is in the workspace |
118
+ | `object NAME is TYPE` | ... and its class, or a class it derives from, is called TYPE (`FittedEquation`, `Dataset`, `ForecastRound`) |
119
+ | `series NAME in DATASET` | the dataset DATASET has a series NAME |
120
+ | `step DIALOG ran` | a step of that dialog is in the history and ran without error (for steps that change an object in place) |
121
+ | `step DIALOG ran on NAME` | ... and read or wrote NAME |
122
+
123
+ Join conditions with `and`: `series ly in data and series lc in data`.
124
+
125
+ ### Checking a case study
126
+
127
+ A block that cannot be read is left out and reported with its line: in the panel, under the case study's name,
128
+ and by `check_case_study`, which raises on any problem. What would make it better is a warning
129
+ (`CaseStudyWarning`, and `study.warnings`), never an error: no introduction, a step with neither text nor `why`,
130
+ a stage not in `stages`, or a step with no stage when others have one.
131
+
132
+ ```python
133
+ from pymetrix_guide import check_case_study, read
134
+
135
+ check_case_study("my_course/week1_guided.md") # CaseStudyError: week1_guided.md: line 23: 'len(data) > 3' is not a check ...
136
+ study = read("my_course/week1_guided.md") # study.intro, study.steps, study.stages, study.problems, study.warnings
137
+ ```
138
+
139
+ It checks that each dialog exists, that the settings are its fields and that it can be built from them, and each
140
+ check against the grammar. `pymetrix.testing.check_course(folder)` checks the folder as course material.
141
+
142
+ ## Limits
143
+
144
+ - The panel opens a case study's demo through the app's interface (`AppInterface.open_demo`, extension API 1.7):
145
+ the app asks to save unsaved work first, and the trainee can cancel. With an older pymetrix (API 1.6 or earlier) the
146
+ panel says where to find the demo instead (**File → Open demo project…**, **File → Reload demo project**).
147
+ - Checks look at the workspace and the history, not at values: "the coefficient is about 0.9" is not a check.
148
+ - A step that writes files (Save round, Export report) writes them where the app's working folder is.
149
+
150
+ BSD-3-Clause.
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pymetrix-guide"
7
+ dynamic = ["version"]
8
+ description = "Guided case studies for pymetrix: follow a workflow step by step in the desktop app, with each step checked"
9
+ readme = "README.md"
10
+ license = "BSD-3-Clause"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ authors = [{ name = "Geoffrey Heenan" }]
14
+ dependencies = ["pymetrix>=0.1.0a10"] # with the extension API 1.5 (panels, courses); 1.7 opens demos from the panel
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/GeoffHeenan/pymetrix"
18
+ Source = "https://github.com/GeoffHeenan/pymetrix/tree/main/packages/pymetrix-guide"
19
+ Issues = "https://github.com/GeoffHeenan/pymetrix/issues"
20
+ Changelog = "https://github.com/GeoffHeenan/pymetrix/blob/main/CHANGELOG.md"
21
+
22
+ [project.optional-dependencies]
23
+ test = ["pytest>=9.0.3"]
24
+
25
+ # the Guide panel, and the case studies it ships as a course; it describes itself as a plugin too
26
+ [project.entry-points."pymetrix.plugins"]
27
+ guide = "pymetrix_guide:register"
28
+ [project.entry-points."pymetrix.panels"]
29
+ guide = "pymetrix_guide:register"
30
+ [project.entry-points."pymetrix.courses"]
31
+ guide = "pymetrix_guide:load_courses"
32
+
33
+ [tool.hatch.version]
34
+ path = "src/pymetrix_guide/_version.py"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/pymetrix_guide"]
@@ -0,0 +1,109 @@
1
+ """Guided case studies for pymetrix (``pymetrix-guide``): a trainee follows a workflow step by step in the desktop
2
+ app, through the real dialogs, and each step is checked as they go.
3
+
4
+ A case study is a Markdown file in a course folder with fenced ``pymetrix-step`` blocks (``casestudy``): each names
5
+ a dialog, its settings and a declarative check (``checks``), and ``##`` sections before the first step make its
6
+ introduction. The **Guide** panel (View → Guide) lists the case studies in the loaded courses, shows the
7
+ introduction and then one step at a time, with the stage of the workflow it belongs to, opens the step's dialog
8
+ filled in (**Open…**) or runs it (**Show me**), and ticks the step when its check passes. The steps are ordinary recorded steps, so the script, the
9
+ project and a lab book capture the trainee's work; the guide keeps no record of its own.
10
+
11
+ The plugin ships Lab 3 of the example course, the quarterly forecast round, as its first case study (a course in
12
+ the ``pymetrix.courses`` group, so it is in the help too).
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import re
18
+ from pathlib import Path
19
+
20
+ from ._version import __version__
21
+ from pymetrix.extension import PluginInfo
22
+
23
+ PLUGIN = PluginInfo(
24
+ name="pymetrix-guide",
25
+ version=__version__,
26
+ api="1.5", # the oldest it works with: from 1.7 the panel opens a case study's demo (AppInterface.open_demo)
27
+ license="BSD-3-Clause",
28
+ maintainer="Geoffrey Heenan",
29
+ description="Guided case studies: follow a workflow step by step in the desktop app, with each step checked",
30
+ )
31
+
32
+ from .casestudy import ( # noqa: E402
33
+ CaseStudy,
34
+ CaseStudyError,
35
+ CaseStudyWarning,
36
+ IntroPage,
37
+ Step,
38
+ build_command,
39
+ check_case_study,
40
+ parse,
41
+ read,
42
+ )
43
+ from .checks import Check, CheckError, parse_check # noqa: E402
44
+
45
+ _STEP_FENCE = re.compile(r"^\s*(`{3,}|~{3,})\s*pymetrix-step\s*$", re.MULTILINE)
46
+ COURSES = Path(__file__).resolve().parent / "courses"
47
+ _registered = False
48
+
49
+
50
+ def register() -> None:
51
+ """The entry point: register the Guide panel (once). Qt is imported only when the app builds the panel."""
52
+ global _registered
53
+ if _registered:
54
+ return
55
+ from pymetrix.extension import AppPanel, plugin_context, register as add
56
+
57
+ def create(app): # noqa: ANN001, ANN202 - an AppInterface; returns a QWidget
58
+ from .app import create_panel
59
+
60
+ return create_panel(app)
61
+
62
+ with plugin_context(PLUGIN):
63
+ add("panels", AppPanel("Guide", create, area="right"), name="guide")
64
+ _registered = True
65
+
66
+
67
+ def course_folders() -> list[Path]:
68
+ """The course folders the plugin ships (each a course of case studies)."""
69
+ return sorted(p for p in COURSES.iterdir() if p.is_dir())
70
+
71
+
72
+ def load_courses() -> None:
73
+ """The ``pymetrix.courses`` entry point: the plugin's case studies, as course material in the help."""
74
+ from pymetrix import help as pymetrix_help
75
+
76
+ for folder in course_folders():
77
+ pymetrix_help.load_course(folder)
78
+
79
+
80
+ def case_studies(session: object = None) -> list[CaseStudy]:
81
+ """The case studies found: the plugin's own, those in the loaded courses (Help → Course material…, or a
82
+ ``pymetrix.courses`` package) and those in the session's project courses. A Markdown note is a case study when it
83
+ has a ``pymetrix-step`` block."""
84
+ from pymetrix import help as pymetrix_help
85
+
86
+ folders = [*course_folders(), *(c.path for c in pymetrix_help.courses())]
87
+ folders += [Path(f) for f in getattr(session, "courses", []) or []]
88
+ seen: set[Path] = set()
89
+ found = []
90
+ for folder in folders:
91
+ folder = Path(folder).resolve()
92
+ if not folder.is_dir():
93
+ continue
94
+ for file in sorted(folder.rglob("*.md")):
95
+ file = file.resolve()
96
+ if file in seen or ".ipynb_checkpoints" in file.parts:
97
+ continue
98
+ seen.add(file)
99
+ try:
100
+ text = file.read_text(encoding="utf-8")
101
+ except OSError:
102
+ continue
103
+ if _STEP_FENCE.search(text):
104
+ found.append(parse(text, file))
105
+ return found
106
+
107
+
108
+ __all__ = ["PLUGIN", "COURSES", "CaseStudy", "CaseStudyError", "CaseStudyWarning", "Check", "CheckError", "IntroPage", "Step",
109
+ "build_command", "case_studies", "check_case_study", "course_folders", "load_courses", "parse", "parse_check", "read", "register"]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0a1"