Skip to content

Commit 0566093

Browse files
committed
Fix model source code parsing
1 parent 66d3434 commit 0566093

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ad.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def run_ad(args):
9696
def get_model_definition(model_key):
9797
"""Get the model definition from the Julia script."""
9898
lines = []
99+
submodels = []
99100
record = False
100101
with open("models.jl", "r") as file:
101102
for line in file:
@@ -104,8 +105,14 @@ def get_model_definition(model_key):
104105
record = True
105106
if record:
106107
lines.append(line)
107-
if record and line.strip() == "end":
108-
break
108+
109+
if "to_submodel" in line:
110+
submodel_name = line.split("to_submodel(")[1].split("(")[0]
111+
submodels.append(submodel_name)
112+
if line == "end":
113+
break
114+
for submodel in submodels:
115+
lines = [get_model_definition(submodel), *lines]
109116
return "<br>".join(lines)
110117

111118

0 commit comments

Comments
 (0)