forked from opensbli/environment_and_run_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubmit.py
More file actions
executable file
·36 lines (29 loc) · 1.12 KB
/
Submit.py
File metadata and controls
executable file
·36 lines (29 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
try:
import jinja2
except ImportError:
print("Trying to Install required module: jinja2\n")
os.system('python -m pip install jinja2')
from jinja2 import Environment, FileSystemLoader
import os
try:
import commentjson
except ImportError:
print("Trying to Install required module: commentjson\n")
os.system('python -m pip install commentjson')
import commentjson as json
import argparse
parser = argparse.ArgumentParser(
prog = 'Submit.py',
description = 'Automatically generate submission for a specified supercomputer.',
epilog = '')
parser.add_argument('filename', type=str, nargs='?', default="JobSubmission.json",help="JSON file for specifying submission options.")
args = parser.parse_args()
with open(args.filename) as JsonOptionFile:
JobOptions=json.load(JsonOptionFile)
JsonOptionFile.close()
environment = Environment(loader=FileSystemLoader("SubmissionTemplate/"))
ScriptTemplate = environment.get_template(JobOptions["Machine"])
Script = ScriptTemplate.render(JobOptions)
with open(JobOptions["JobName"], mode="w", encoding="utf-8") as message:
message.write(Script)