Skip to content

Commit 5a6c659

Browse files
Merge pull request #179 from rosswhitfield/multi_config_hierarchy
For multi-config simulations, make first simulation parent of all others
2 parents e754bd1 + 0d5f8b9 commit 5a6c659

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

ipsframework/portalBridge.py

+9
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __init__(self):
9393
self.counter = 0
9494
self.monitor_file_name = ""
9595
self.portal_runid = None
96+
self.parent_portal_runid = None
9697
self.sim_name = ''
9798
self.sim_root = ''
9899
self.monitor_file = None
@@ -126,6 +127,7 @@ def __init__(self, services, config):
126127
self.last_dump_time = time.time()
127128
self.write_to_htmldir = True
128129
self.html_dir = ""
130+
self.first_portal_runid = None
129131

130132
def init(self, timestamp=0.0, **keywords):
131133
"""
@@ -222,6 +224,8 @@ def process_event(self, topicName, theEvent):
222224
portal_data['vizurl'] = sim_data.monitor_url
223225

224226
portal_data['portal_runid'] = sim_data.portal_runid
227+
if portal_data['eventtype'] == 'IPS_START' and 'parent_portal_runid' not in portal_data:
228+
portal_data['parent_portal_runid'] = sim_data.parent_portal_runid
225229
portal_data['seqnum'] = sim_data.counter
226230

227231
if 'trace' in portal_data:
@@ -486,6 +490,11 @@ def init_simulation(self, sim_name, sim_root):
486490
self.services.error('Simulation %s is not accessible', sim_name)
487491
return
488492

493+
if self.first_portal_runid:
494+
sim_data.parent_portal_runid = self.first_portal_runid
495+
else:
496+
self.first_portal_runid = sim_data.portal_runid
497+
489498
if sim_data.sim_root.strip() == '.':
490499
sim_data.sim_root = os.environ['IPS_INITIAL_CWD']
491500
sim_log_dir = os.path.join(sim_data.sim_root, 'simulation_log')

tests/multirun/basic_serial1.ips

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CURRENT_STATE =
1616
PRIOR_STATE =
1717
NEXT_STATE =
1818
CURRENT_EQDSK =
19-
USE_PORTAL=False
19+
USE_PORTAL=True
2020

2121
LOG_FILE = $SIM_ROOT/$SIM_NAME.log
2222
LOG_LEVEL = INFO # Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL

tests/multirun/basic_serial2.ips

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CURRENT_STATE =
1616
PRIOR_STATE =
1717
NEXT_STATE =
1818
CURRENT_EQDSK =
19-
USE_PORTAL=False
19+
USE_PORTAL=True
2020

2121
LOG_FILE = $SIM_ROOT/$SIM_NAME.log
2222
LOG_LEVEL = INFO # Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL

tests/multirun/test_basic_serial.py

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import glob
4+
import json
45
import pytest
56
from ipsframework import Framework
67

@@ -204,6 +205,26 @@ def test_basic_serial_multi(tmpdir, capfd):
204205
for timestamp in ["3.40", "3.50", "3.60"]:
205206
assert f'workers_testing_{worker} INFO Stepping Worker timestamp={timestamp}\n' in lines
206207

208+
# check that the parent_portal_runid is correctly set
209+
serial1_json_files = glob.glob(str(tmpdir.join("test_basic_serial1_0").join("simulation_log").join("*.json")))
210+
assert len(serial1_json_files) == 1
211+
with open(serial1_json_files[0], 'r') as json_file:
212+
serial1_lines = json_file.readlines()
213+
214+
serial1_IPS_START = json.loads(serial1_lines[0])
215+
assert serial1_IPS_START['parent_portal_runid'] is None
216+
serial1_portal_runid = serial1_IPS_START['portal_runid']
217+
218+
serial2_json_files = glob.glob(str(tmpdir.join("test_basic_serial2_0").join("simulation_log").join("*.json")))
219+
assert len(serial2_json_files) == 1
220+
with open(serial2_json_files[0], 'r') as json_file:
221+
serial2_lines = json_file.readlines()
222+
223+
serial2_IPS_START = json.loads(serial2_lines[0])
224+
assert serial2_IPS_START['parent_portal_runid'] == serial1_portal_runid
225+
assert serial2_IPS_START['portal_runid'] is not None
226+
assert serial2_IPS_START['portal_runid'] != serial1_portal_runid
227+
207228

208229
@pytest.mark.skipif(not shutil.which('mpirun'), reason="requires mpirun")
209230
def test_basic_concurrent1(tmpdir, capfd):

0 commit comments

Comments
 (0)