Skip to content

mecfs_bio.figures.key_scripts.generate_new_figures

Functions:

  • generate_new_figures

    Aim of this function is to only invoke the build system to build figures that do not

Attributes:

logger module-attribute

logger = get_logger()

generate_new_figures

generate_new_figures(
    all_figure_tasks: list[Task],
    fig_dir: Path,
    exporter: AbstractFigureExporter,
)

Aim of this function is to only invoke the build system to build figures that do not currently exist in the figure directory.

Source code in mecfs_bio/figures/key_scripts/generate_new_figures.py
def generate_new_figures(
    all_figure_tasks: list[Task],
    fig_dir: Path,
    exporter: AbstractFigureExporter,
):
    """
    Aim of this function is to only invoke the build system  to build figures that do not
    currently exist in the figure directory.
    """
    tasks_to_run = []
    for task in all_figure_tasks:
        meta = task.meta
        assert isinstance(meta, ValidFigureMeta)
        dst = get_figure_destination(meta=meta, fig_dir=fig_dir)
        if not dst.exists():
            tasks_to_run.append(task)

    logger.debug(
        f"Found new figure tasks: {[task.meta.asset_id for task in tasks_to_run]}"
    )
    if len(tasks_to_run) > 0:
        exporter.export(tasks_to_run, fig_dir=fig_dir)