Skip to content

Commit ed435e2

Browse files
committed
Added the ability to execute models from python scripts or interpreter without use of the pylems shell script
1 parent 52ffdca commit ed435e2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lems/run.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,25 @@ def process_args():
4141

4242
return parser.parse_args()
4343

44-
def main():
44+
def run(file_path,include_dirs=[],dlems=False,nogui=False):
45+
"""
46+
Function for running from a script or shell.
47+
"""
48+
import argparse
49+
args = argparse.Namespace()
50+
args.lems_file = file_path
51+
args.I = include_dirs
52+
args.dlems = dlems
53+
args.nogui = nogui
54+
main(args=args)
55+
56+
def main(args=None):
4557
"""
4658
Program entry point.
4759
"""
4860

49-
args = process_args()
61+
if args is None:
62+
args = process_args()
5063

5164
print('Parsing and resolving model: '+args.lems_file)
5265
model = Model()

0 commit comments

Comments
 (0)