Skip to content

Commit c98ddd3

Browse files
committed
Slightly reformat the input documentation
1 parent ef7d5f2 commit c98ddd3

19 files changed

Lines changed: 45 additions & 56 deletions

.vscode/extensions.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"editorconfig.editorconfig",
66
"esbenp.prettier-vscode",
77
"davidanson.vscode-markdownlint",
8-
"samuelcolvin.jinjahtml"
8+
"samuelcolvin.jinjahtml",
9+
"ms-python.python",
10+
"charliermarsh.ruff"
911
]
1012
}

docs/generate_input_format_doc.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,12 @@
2121
}
2222

2323

24-
@dataclass
25-
class Notes:
26-
description: str | None
27-
table: str | None
28-
29-
3024
@dataclass
3125
class File:
3226
name: str
3327
description: str
3428
table: str
35-
notes: Notes | None
29+
notes: str | None
3630

3731

3832
@dataclass
@@ -61,17 +55,16 @@ def load_file(path: Path) -> File:
6155
data = yaml.safe_load(f)
6256

6357
try:
64-
table, notes_table = fields2table(data["fields"])
58+
table = fields2table(data["fields"])
6559
except KeyError:
6660
print(f"MISSING VALUE IN {path}")
6761
raise
6862

6963
name = f"{path.stem}.csv"
70-
title = add_full_stop(data["title"])
71-
if desc := data.get("description", None):
72-
desc = add_full_stop(desc)
73-
notes = Notes(desc, notes_table) if desc or notes_table else None
74-
return File(name, title, table, notes)
64+
desc = add_full_stop(data["description"])
65+
if note := data.get("notes", None):
66+
note = add_full_stop(note)
67+
return File(name, desc, table, note)
7568

7669

7770
def add_full_stop(s: str) -> str:
@@ -84,28 +77,18 @@ def add_full_stop(s: str) -> str:
8477

8578
def fields2table(fields: list[dict[str, str]]) -> tuple[str, str | None]:
8679
data = []
87-
notes = []
8880
for f in fields:
89-
row = {"Field": f"`{f['name']}`", "Description": f["title"]}
90-
data.append(row)
91-
92-
if desc := f.get("description", ""):
93-
# MarkdownTable can't handle newlines, so replace with HTML equivalent
94-
desc = desc.replace("\n\n", "<br /><br />").replace("\n", " ")
95-
row = {"Field": f"`{f['name']}`", "Notes": desc}
96-
notes.append(row)
97-
98-
data = [
99-
{
81+
# MarkdownTable can't handle newlines, so replace with HTML equivalent
82+
desc = f.get("description", "")
83+
desc = desc.replace("\n\n", "<br /><br />").replace("\n", " ")
84+
row = {
10085
"Field": f"`{f['name']}`",
10186
"Description": f["title"],
87+
"Notes": desc,
10288
}
103-
for f in fields
104-
]
105-
89+
data.append(row)
10690
table = str(MarkdownTable.from_dicts(data))
107-
notes_table = str(MarkdownTable.from_dicts(notes)) if notes else None
108-
return table, notes_table
91+
return table
10992

11093

11194
if __name__ == "__main__":

docs/input_format.md.jinja

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ This file contains information about the input file format for MUSE 2.0.
2626
(such as a requirement that the value is >=0 etc.). -#}
2727
{%- if file.notes %}
2828
#### Notes
29-
{% if file.notes.description %}
30-
{{ file.notes.description }}{% endif %}
31-
{% if file.notes.table %}
32-
{{ file.notes.table }}{% endif -%}
29+
{{ file.notes }}
3330
{%- endif %}
31+
3432
{% endfor -%}
33+
3534
{% endfor %}

schemas/input/agent_commodity_portions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
title: Commodity demand portions for agents
21
description: |
32
Portions of commodity demand for which agents are responsible.
43
4+
notes: |
55
If an entry is specified for one agent and commodity, there must be entries covering all milestone
66
years. For each agent listed in this file, the total portions for each region/commodity/year
77
combination must sum to one. In addition, there must be entries for every SVD and SED commodity

schemas/input/agent_cost_limits.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
title: Agent cost limits
21
description: |
32
Limits on expenditure for agents.
43
4+
notes: |
55
If cost limits are provided for an agent, they must be present for all years.
66
77
fields:

schemas/input/agent_objectives.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
title: Agent objectives
21
description: |
32
Describes the agents' objectives.
43
4+
notes: |
55
Every agent must have one objective for each milestone year. If the weighted sum decision rule is
66
in use, the `decision_weight` value must be provided, otherwise it must be omitted. If the lexico
77
decision rule is in use, the `decision_lexico_order` value must be provided, otherwise it must be

schemas/input/agent_search_space.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
title: Agent search space
21
description: |
32
Defines the processes in which an agent will invest for given parameters.
43
4+
notes: |
55
If entries are missing for any combination of agent, commodity or milestone year, then it is
66
assumed that all processes can be considered in this case.
77

schemas/input/agents.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
title: Main agents file
21
description: Describes agents in the system
32
fields:
43
- name: id

schemas/input/assets.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
title: Main assets file
21
description: Defines assets in the system
32

43
fields:

schemas/input/commodities.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
title: Main commodities file
21
description: |
2+
Describes commodities in the system.
3+
4+
notes: |
35
Every SED (supply equals demand) commodity must have both producer and consumer processes for
46
every region and milestone year. Every SVD (service demand) commodity must have a producer for
57
every region and milestone year.

0 commit comments

Comments
 (0)