Skip to content

[IMG282] UI for load data

Zhang, Chen requested to merge IMG282_dataload_ui into next
  • Original Gitlab story: IMG282

This PR introduces the following changes:

  • updated MetaData and DataLoading class that serialize itself into json for output
  • utility function to handle json input
  • corresponding ui unit test based off PlayWright

To test the two stages, copy the following code in a cell

import panel as pn
from imars3d.ui.stages.metadata import MetaData
from imars3d.ui.stages.dataloading import DataLoader

pn.extension("jsoneditor")

# build the pipeline
wizard = pn.pipeline.Pipeline(
    stages=[
        ("Metadata", MetaData),
        ("Load Data", DataLoader),
    ],
    debug=True,
)
# NOTE: we have to disable the axes linking as it will try to link with
# the "ct" viewers in the pipeline.
wizard.network.linked_axes = False
wizard.servable()

and you should be able to see the app in the cell

Screenshot from 2022-09-28 13-50-25

Alternatively, you can use this script at the root of the repo with panel serve test.py to view the two stages as a web app.

#!/usr/bin/env python3

import panel as pn
from imars3d.ui.stages.metadata import MetaData
from imars3d.ui.stages.dataloading import DataLoader

pn.extension("jsoneditor")

# build the pipeline
wizard = pn.pipeline.Pipeline(
    stages=[
        ("Metadata", MetaData),
        ("Load Data", DataLoader),
    ],
    debug=True,
)
# NOTE: we have to disable the axes linking as it will try to link with
# the "ct" viewers in the pipeline.
wizard.network.linked_axes = False

# setup via template
pn.template.FastListTemplate(
    site="iMars3D demo",
    title="Neutron Image Reconstruction",
    logo="HFIR_SNS_logo.png",
    header_background="#00A170",
    main=wizard,
    # theme="dark",
    theme_toggle=False,
).servable()

Known issue: The JSONEditor widget from panel does not auto refresh when its underlying dictionary is updated. Update: the issue is resolved by adding a manual trigger after dict update to force a redraw of the JSONEditor.

Merge request reports