CrayLabs / SmartDashboard

SmartSim Dashboard Package.
BSD 2-Clause "Simplified" License
6 stars 2 forks source link

Refactor view_builders for readability #13

Closed billschereriii closed 10 months ago

billschereriii commented 10 months ago

Description

In the file view_builders.py, there are many repetitions of code in the form:

        with col2:
            render_dataframe_with_title(
                "Run Settings",
                pd.DataFrame(
                    flatten_nested_keyvalue_containers("run_settings", member),
                    columns=["Name", "Value"],
                ),
            )

Creating a utility function could collapse these to a single line and make the code in this file a lot easier to follow.

Implementation Strategy

Something like the following:

def build_dataframe(column, title, container, member, columns):
        with column:
            render_dataframe_with_title(
                title,
                pd.DataFrame(
                    flatten_nested_keyvalue_containers(container, member),
                    columns=columns,
                ),
            )