Skip to content

Commit 728c0cd

Browse files
authored
Merge pull request #642 from BlockScience/0.4.3
0.4.3
2 parents f2884fc + 7a550ae commit 728c0cd

19 files changed

+148
-49
lines changed

docs/1 Overview.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/4 JSON Specification.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/CanonicalExamples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Canonical Examples
33
layout: page
4-
nav_order: 4
4+
nav_order: 7
55
---
66

77
As part of MSML, there are multiple canonical examples which are meant to showcase how the library gets used. The table below describes the features that each one has as well as the level of completion for each.

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: FAQ
33
layout: page
4-
nav_order: 6
4+
nav_order: 9
55
---
66

77
The following are frequently asked questions with regards to MSML.

docs/2 GDS Fundamentals.md renamed to docs/GDS Fundamentals.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: GDS Fundamentals
3+
nav_order: 2
4+
layout: page
5+
---
6+
17
# GDS Fundamentals
28

39
For more information with regards to the GDS fundamentals, one can look at this [repository](https://github.com/BlockScience/GDS-MSML-cadCAD). Below is abbreviated documentation describing the fundamentals of Generalized Dynamical Systems (GDS).

docs/GettingStarted.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
title: Getting Started
3-
nav_order: 2
3+
nav_order: 4
44
layout: page
55
---
66

77
Getting started with your first MSML specification can seem like a daunting task but this short guide will hopefully make it easier.
88

9+
If you want to view the in-depth JSON specification you can find it here [here](./JSON-Specification/README). This is what is passed to MSML to create the specification object.
10+
911
## 1. Review the Concepts
1012

1113
- Within this documentation, you can find specific technical documentation including the background theory and the components under "Technical Documentation"

docs/3 MSML Enhancements.md renamed to docs/MSML Enhancements.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: MSML Enhancements
3+
nav_order: 3
4+
layout: page
5+
---
6+
17
# MSML Enhancements
28

39
MSML provides certain enhancements beyond the generalized blocks and spaces that can be utilized when building out specifications.

docs/Reports.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Reports
3+
layout: page
4+
nav_order: 6
5+
---
6+
7+
MSML has a variety of reports that can be produced in markdown files which can also be converted to PDF.
8+
9+
## PDF Conversion
10+
11+
- To use PDF conversion, a few other things need to be installed
12+
- One must install pandoc, which can be done with "brew install pandoc" on a mac
13+
- Installing pdflatex might be required which can be done with "brew install --cask basictex" on a mac
14+
- If the pdflatex path is not recognized by the system, you may need to pass the path to it. For example, on a mac this would be: pdflatex_path='/Library/TeX/texbin/pdflatex'

docs/TechnicalDocumentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Technical Documentation
33
layout: page
4-
nav_order: 3
4+
nav_order: 5
55
---
66

77
Placeholder for future documentation on all the technical details of MSML

docs/_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ defaults:
1111
values:
1212
layout: "default"
1313

14+
mermaid:
15+
# Version of mermaid library
16+
# Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/
17+
version: "9.1.3"
18+
1419
aux_links:
1520
MSML Repository Repository: https://github.com/BlockScience/MSML

docs/cadCADBuilder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: cadCAD Builder
33
layout: page
4-
nav_order: 5
4+
nav_order: 8
55
---
66

77
MSML provides interfaces for creating cadCAD style models that don't require end users poking around the actual code to use. The idea is that it provides a layer for data scientists to experiment just with toggling starting state and parameters and executing pre-packaged models.

docs/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ Writing mathematical specifications can be a difficult process, especially when
3636

3737
## How does MSML work?
3838

39-
40-
![mermaid](mermaid.png)
39+
```mermaid
40+
graph TD
41+
A[JSON Object \n\n Each spec has a repo for tracking changes \n Must conform to the json specification \n Defines all aspects of the spec including blocks, spaces and actions] -->B[MSML Object \n\n JSON file is parsed, with validations and mappings along the way \n Can show different views on the fly]
42+
B --> C[Report Outputs & Obsidian Directory \n\n Automatically build reports for the full spec or subviews \n Example: all blocks with an effect on variable XYZ\n Also builds an entire Obsidian directory of all components as linked notes]
43+
D[Python Function Implementations \n\n Optional enhancement to actually execute code\n Done for each referenced policy option, mechanism, etc. \n Just needs a function definition for each] --> B
44+
B --> E[Python Wirings & Simulations \n\n MSML can be used to run blocks \n Wirings automatically work to pass between domain/codomains \n Entire simulations can be built up as composed wirings]
45+
```
4146

4247
## MSML in the Engineering Lifecycle
4348

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44
[project]
55
name = "math-spec-mapping"
6-
version = "0.4.2"
6+
version = "0.4.3"
77
authors = [
88
{ name="Sean McOwen", email="[email protected]" },
99
]
@@ -14,7 +14,8 @@ dependencies = [
1414
"pandas>=1.4",
1515
"jsonschema>=4.21.1",
1616
"PyGithub==2.5.0",
17-
"python-dotenv>=1.0.0"
17+
"python-dotenv>=1.0.0",
18+
"pypandoc>=1.15",
1819
]
1920
readme = "README.md"
2021
requires-python = ">=3.7"

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ipython>=7.7.0
33
pandas>=1.4
44
jsonschema>=4.21.1
55
PyGithub==2.5.0
6-
python-dotenv>=1.0.0
6+
python-dotenv>=1.0.0
7+
pypandoc>=1.15
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Advanced Reports
2+
3+
1. Glossary
4+
5+
## Glossary
6+
7+
- An advanced report which just lists out the components and their descripitions.
8+
9+
## Parameter Impact Report
10+
11+
- Given a parameter will show all directly affected blocks and all downstream blocks
12+
- Likely will want to use a mermaid rendering for the blocks impacted
13+
14+
## State Variable Impact Report
15+
16+
- Given a state variable, will map out all the paths to modifying it
17+
- Can do recursive things to figure out what wirings or policies are upstream from it

src/math_spec_mapping/Reports/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .boundary_actions import write_out_boundary_actions
33
from .policies import write_out_policies
44
from .mechanisms import write_out_mechanisms
5-
from .general import load_svg_graphviz
5+
from .general import load_svg_graphviz, convert_markdown_to_pdf
66
from .html import (
77
write_basic_report_full,
88
write_action_chain_reports,
@@ -32,3 +32,4 @@
3232
write_initial_state_variables_tables,
3333
)
3434
from .parameters import write_parameter_table_markdown
35+
from .advanced import write_glossary_report
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from ..Classes import MathSpec
2+
from .state import write_state_section
3+
4+
5+
def write_glossary_report(ms: MathSpec, directory: str) -> None:
6+
"""Function to write a report of each component and its description in MSML
7+
8+
Args:
9+
ms (MathSpec): The mathematical specification object
10+
directory (str): Directory to put reports into
11+
"""
12+
out = "# Glossary\n\n"
13+
14+
out += "## Entities\n\n"
15+
for entity in ms.entities:
16+
if entity == "Global":
17+
continue
18+
entity = ms.entities[entity]
19+
out += "**{}**: {}".format(entity.name, entity.notes)
20+
out += "\n\n"
21+
out += "\n"
22+
23+
out += "## State\n\n"
24+
states = list(ms.state.keys())
25+
states.remove("Global State")
26+
states = ["Global State"] + states
27+
for state in states:
28+
out += "### {}\n\n".format(state)
29+
out += write_state_section(ms.state[state])
30+
out += "\n\n"
31+
out += "\n\n"
32+
33+
for name, component in [
34+
["Types", ms.types],
35+
["Spaces", ms.spaces],
36+
["Boundary Actions", ms.boundary_actions],
37+
["Control Actions", ms.control_actions],
38+
["Policies", ms.policies],
39+
["Mechanisms", ms.mechanisms],
40+
["Wiring", ms.wiring],
41+
["Parameters", ms.parameters.parameter_map],
42+
["Stateful Metrics", ms.stateful_metrics],
43+
["Metrics", ms.metrics],
44+
]:
45+
out += "## {}\n\n".format(name)
46+
for key in component:
47+
if hasattr(component[key], "description"):
48+
desc = component[key].description
49+
else:
50+
desc = component[key].notes
51+
52+
out += "**{}**: {}\n\n".format(key, desc)
53+
out += "\n\n"
54+
55+
path = directory + "/Glossary.md"
56+
with open(path, "w") as f:
57+
f.write(out)

src/math_spec_mapping/Reports/general.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from graphviz import Digraph
22
import os
3+
import pypandoc
34

45

56
def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
@@ -23,7 +24,7 @@ def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
2324
assert "{}.gv".format(graph.name) not in os.listdir(".")
2425

2526
# Render the graph
26-
graph.render(directory=".", format='svg')
27+
graph.render(directory=".", format="svg")
2728

2829
# Read the svg
2930
with open("./{}.gv.svg".format(graph.name), "r") as f:
@@ -35,6 +36,7 @@ def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
3536

3637
return svg
3738

39+
3840
def write_header() -> str:
3941
out = '<p>For explanations of generalized dynamical systems as well as how the mathematical specification library works in detail, please consult the documentation <a href="https://github.com/BlockScience/MSML/tree/main/docs">here</a></p>'
4042
out += "Graph Legend:<br/>"
@@ -43,4 +45,20 @@ def write_header() -> str:
4345
out += "Red Square: Policy<br/>"
4446
out += "Blue Circle: Mechanism<br/>"
4547
out += "Transparent Circle: State Variable"
46-
return out
48+
return out
49+
50+
51+
def convert_markdown_to_pdf(md_path, pdf_path, pdflatex_path=None):
52+
if pdflatex_path:
53+
pypandoc.convert_file(
54+
md_path,
55+
"pdf",
56+
outputfile=pdf_path,
57+
extra_args=["--pdf-engine={}".format(pdflatex_path)],
58+
)
59+
else:
60+
pypandoc.convert_file(
61+
md_path,
62+
"pdf",
63+
outputfile=pdf_path,
64+
)

src/math_spec_mapping/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
write_state_variable_table_markdown,
2929
write_initial_state_variables_tables,
3030
write_parameter_table_markdown,
31+
write_glossary_report,
32+
convert_markdown_to_pdf,
3133
)
3234
from .schema import schema
3335
from .Convenience import (

0 commit comments

Comments
 (0)