Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ipsframework/portalBridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self):
self.counter = 0
self.monitor_file_name = ""
self.portal_runid = None
self.parent_portal_runid = None
self.sim_name = ''
self.sim_root = ''
self.monitor_file = None
Expand Down Expand Up @@ -126,6 +127,7 @@ def __init__(self, services, config):
self.last_dump_time = time.time()
self.write_to_htmldir = True
self.html_dir = ""
self.first_portal_runid = None

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

portal_data['portal_runid'] = sim_data.portal_runid
if portal_data['eventtype'] == 'IPS_START' and 'parent_portal_runid' not in portal_data:
portal_data['parent_portal_runid'] = sim_data.parent_portal_runid
portal_data['seqnum'] = sim_data.counter

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

if self.first_portal_runid:
sim_data.parent_portal_runid = self.first_portal_runid
else:
self.first_portal_runid = sim_data.portal_runid

if sim_data.sim_root.strip() == '.':
sim_data.sim_root = os.environ['IPS_INITIAL_CWD']
sim_log_dir = os.path.join(sim_data.sim_root, 'simulation_log')
Expand Down
2 changes: 1 addition & 1 deletion tests/multirun/basic_serial1.ips
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CURRENT_STATE =
PRIOR_STATE =
NEXT_STATE =
CURRENT_EQDSK =
USE_PORTAL=False
USE_PORTAL=True

LOG_FILE = $SIM_ROOT/$SIM_NAME.log
LOG_LEVEL = INFO # Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL
Expand Down
2 changes: 1 addition & 1 deletion tests/multirun/basic_serial2.ips
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CURRENT_STATE =
PRIOR_STATE =
NEXT_STATE =
CURRENT_EQDSK =
USE_PORTAL=False
USE_PORTAL=True

LOG_FILE = $SIM_ROOT/$SIM_NAME.log
LOG_LEVEL = INFO # Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL
Expand Down
21 changes: 21 additions & 0 deletions tests/multirun/test_basic_serial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import glob
import json
import pytest
from ipsframework import Framework

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

# check that the parent_portal_runid is correctly set
serial1_json_files = glob.glob(str(tmpdir.join("test_basic_serial1_0").join("simulation_log").join("*.json")))
assert len(serial1_json_files) == 1
with open(serial1_json_files[0], 'r') as json_file:
serial1_lines = json_file.readlines()

serial1_IPS_START = json.loads(serial1_lines[0])
assert serial1_IPS_START['parent_portal_runid'] is None
serial1_portal_runid = serial1_IPS_START['portal_runid']

serial2_json_files = glob.glob(str(tmpdir.join("test_basic_serial2_0").join("simulation_log").join("*.json")))
assert len(serial2_json_files) == 1
with open(serial2_json_files[0], 'r') as json_file:
serial2_lines = json_file.readlines()

serial2_IPS_START = json.loads(serial2_lines[0])
assert serial2_IPS_START['parent_portal_runid'] == serial1_portal_runid
assert serial2_IPS_START['portal_runid'] is not None
assert serial2_IPS_START['portal_runid'] != serial1_portal_runid


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