Skip to content

Commit

Permalink
#422: Begin experimenting with VTDataWriter to pass data to vt-tv
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Oct 12, 2023
1 parent 020be89 commit 2c489e6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
47 changes: 47 additions & 0 deletions config/test-vt-tv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Specify input
from_data:
data_stem: ../data/nolb-8color-16nodes-11firstphases/data
phase_ids:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
check_schema: False

# Specify work model
work_model:
name: AffineCombination
parameters:
alpha: 1.0
beta: 1.0e-08
gamma: 0.0

# Specify algorithm
algorithm:
name: PhaseStepper

# Specify output
output_dir: ../output
output_file_stem: output_file
LBAF_Viz:
x_ranks: 8
y_ranks: 4
z_ranks: 1
object_jitter: 0.5
rank_qoi: work
object_qoi: load
save_meshes: True
force_continuous_object_qoi: True

write_JSON:
compressed: False
suffix: json
communications: True
offline_LB_compatible: True
9 changes: 9 additions & 0 deletions src/lbaf/Applications/LBAF_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import importlib
import yaml

import tv

Check failure on line 9 in src/lbaf/Applications/LBAF_app.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Unable to import 'tv' (import-error)

# pylint:disable=C0413:wrong-import-position
# Use lbaf module from source if lbaf package is not installed
if importlib.util.find_spec('lbaf') is None:
Expand Down Expand Up @@ -563,6 +565,13 @@ def run(self):
self.__parameters.rank_qoi))
qoi_request.append(self.__parameters.object_qoi)

# Serialize data to JSON-formatted string
json_str = self.__json_writer.serialize_phases(phases)
print(json_str)

# Pass string to vt-tv for rendering
tv.process_json(json_str)

# Instantiate and execute visualizer
visualizer = Visualizer(
self.__logger,
Expand Down
27 changes: 27 additions & 0 deletions src/lbaf/IO/lbsVTDataWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ def __create_tasks(self, rank_id, objects, migratable):
tasks.append(task_data)
return tasks

def serialize_phases(self, phases) -> str:
"""Serialize rank for list of phase instances data in a JSON-formatted string."""
for p in phases.values():

Check notice on line 73 in src/lbaf/IO/lbsVTDataWriter.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Variable name "p" doesn't conform to snake_case naming style (invalid-name)
p_id = p.get_id()
for rank in p.get_ranks():
r_id = rank.get_id()

# Initialize output dict
output = {
"metadata": {
"type": "LBDatafile",
"rank": r_id},
"phases": []}

# Iterate over phases
for p_id, phase in phases.items():

Check warning on line 86 in src/lbaf/IO/lbsVTDataWriter.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Unused variable 'phase' (unused-variable)
# Create data to be outputted for current phase
self.__logger.debug(f"Serializing phase {p_id} for rank {r_id}")
phase_data = {"id": p_id}
phase_data["tasks"] = self.__create_tasks(
r_id, rank.get_migratable_objects(), migratable=True) + self.__create_tasks(
r_id, rank.get_sentinel_objects(), migratable=False)
output["phases"].append(phase_data)

# Serialize and return JSON payload
serial_json = json.dumps(output, separators=(',', ':'))
return serial_json

def _json_writer(self, rank_phases_double) -> str:
"""Write one JSON per rank for list of phase instances."""
Expand Down

0 comments on commit 2c489e6

Please sign in to comment.