Skip to content

Commit

Permalink
Merge pull request #180 from rosswhitfield/fix_update_time_stamp_from…
Browse files Browse the repository at this point in the history
…_sub_workflow

Fix calling update_time_stamp from sub workflow
  • Loading branch information
rosswhitfield authored Dec 8, 2022
2 parents 5a6c659 + 5fed3f2 commit 0e54957
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ipsframework/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,9 @@ def update_time_stamp(self, new_time_stamp=-1):
Update time stamp on portal.
"""
event_data = {}
event_data['sim_name'] = self.sim_name
event_data['sim_name'] = self.sim_conf['__PORTAL_SIM_NAME']
event_data['real_sim_name'] = self.sim_name

portal_data = {}
portal_data['phystimestamp'] = new_time_stamp
portal_data['eventtype'] = 'PORTALBRIDGE_UPDATE_TIMESTAMP'
Expand Down
1 change: 1 addition & 0 deletions tests/hello-world-nested/hello_driver_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def step(self, timestamp=0.0, **keywords):
except Exception:
self.services.exception('Error accessing worker component')
raise
self.services.update_time_stamp(1)
self.services.call(worker_comp, 'step', 0.0)
with open(self.OUTPUT_FILES.split()[0], 'w') as f:
f.write("SUB OUTPUT FILE\n")
Expand Down
1 change: 1 addition & 0 deletions tests/hello-world-nested/hello_worker_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ def __init__(self, services, config):
def step(self, timestamp=0.0, **keywords):
print('Hello from HelloWorker - sub')
self.services.info('Hello from HelloWorker - sub')
self.services.send_portal_event(event_comment='Hello from HelloWorker - sub')
25 changes: 25 additions & 0 deletions tests/hello-world-nested/test_hello-world-nested.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import shutil
import json
import glob
from ipsframework import Framework


Expand Down Expand Up @@ -98,3 +100,26 @@ def test_hello_world_nested(tmpdir, capfd):
lines = f.readlines()

assert lines[0] == "SUB INPUT FILE\n"

# check the simulation log json
json_files = glob.glob(str(tmpdir.join("hello_example_SUPER").join("simulation_log").join("*.json")))
assert len(json_files) == 1
with open(json_files[0], 'r') as json_file:
events = [json.loads(event) for event in json_file.readlines()]

assert len(events) == 25
assert events[-1]['eventtype'] == "IPS_END"

codes = set(event["code"] for event in events)

# Check that the sub wortflow writes to the same json file
assert len(codes) == 5
assert "Framework" in codes
assert "DRIVERS_HELLO_HelloDriver" in codes
assert "WORKERS_HELLO_HelloWorker" in codes
assert "DRIVERS_HELLOSUB_HelloDriver" in codes
assert "WORKERSSUB_HELLO_HelloWorker" in codes

# Check that phystimestamp get updated by the sub workflow
assert events[0]["phystimestamp"] == -1
assert events[-1]["phystimestamp"] == 1

0 comments on commit 0e54957

Please sign in to comment.