vipr.plugins.api.exporters package

Submodules

vipr.plugins.api.exporters.diagram_csv_exporter module

Diagram CSV Exporter - Exports diagram data as CSV files.

This module provides functionality to extract diagram data from the DataCollector and save it as CSV files, creating separate files for each series.

vipr.plugins.api.exporters.diagram_csv_exporter.extract_and_save_diagram_csv(result_id: str, result_data: dict, storage) None

Extract diagrams from result data and save them as CSV files. Creates separate CSV files for each series to ensure X-Y value alignment.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.diagram_image_generator module

Diagram Image Generator - Converts diagram data to matplotlib PNG images.

This module provides functionality to automatically generate PNG images from diagram data structures, making results accessible for CLI users without requiring JavaScript-based visualization.

vipr.plugins.api.exporters.diagram_image_generator.generate_diagram_images(result_id: str, result_data: dict, storage, vis_config=None) None

Generate images from diagram data using matplotlib. Automatically creates plots for all diagrams with proper styling.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

  • vis_config – Optional VisualizationConfig instance. When provided, per-diagram figsize/format/dpi overrides from the YAML visualization: block are applied. Falls back to DEFAULT_PLOT_STYLE when None.

vipr.plugins.api.exporters.diagram_statistics_extractor module

Diagram Statistics Extractor - Extracts and formats statistics from diagram metadata.

This module provides functionality to extract goodness-of-fit statistics and other metrics from diagram metadata and save them as human-readable text files.

vipr.plugins.api.exporters.diagram_statistics_extractor.extract_and_save_diagram_statistics(result_id: str, result_data: dict, storage) None

Extract statistics from diagram metadata and save as formatted text files. Creates log-style text files with goodness-of-fit statistics.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.image_exporter module

Image Exporter - Exports Base64-encoded images as separate files.

This module provides functionality to extract Base64-encoded image data from the DataCollector and save it as separate image files in various formats (PNG, SVG, JPG).

vipr.plugins.api.exporters.image_exporter.extract_and_save_images(result_id: str, result_data: dict, storage) None

Extract images from result data and save them as separate files.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing images

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.script_exporter module

Script exporter for VIPR result directories.

Copies plugin-provided plot scripts alongside their data into results/<uuid>/scripts/ so scientists can reproduce and customise plots without a VIPR installation.

IMPORTANT: extract_and_save_plot_scripts() MUST be called BEFORE model_dump() / pickle serialisation because it reads the live UIData object and the transient data buffer on DataCollector.

vipr.plugins.api.exporters.script_exporter.extract_and_save_plot_scripts(result_id: str, ui_data: UIData, transient_plot_data: dict, transient_plot_scripts: dict, storage, vis_config=None) None

Export plot scripts and data from live UIData and the transient buffers.

Must be called BEFORE model_dump() / pickle serialisation because: - It reads live UIData.items[*].images (Pydantic models, not dicts) - It reads DataCollector._transient_plot_data (never serialised) - It reads DataCollector._transient_plot_scripts (never serialised)

Script path and dependencies are resolved at set_plot_script() time (via inspect.getsourcefile + importlib) and stored transiently — no global registry is needed.

Parameters:
  • result_id – UUID of the result being saved

  • ui_data – Live UIData object (not serialised yet)

  • transient_plot_data – dc._transient_plot_data — “{idx}:{id}” → arrays

  • transient_plot_scripts – dc._transient_plot_scripts — “{idx}:{id}” → {path, deps, data_format}

  • storage – ResultStorage instance

  • vis_config – Optional VisualizationConfig instance for style snapshot export.

vipr.plugins.api.exporters.script_exporter.generate_diagram_scripts(result_id: str, result_data: dict, storage, transient_diagram_scripts: dict | None = None, vis_config=None) None

Tier 1: Auto-generate standalone plot scripts for every diagram in result_data.

Runs AFTER serialisation (reads the serialised dict, not live UIData). Scripts are saved to results/<uuid>/scripts/ and load the companion CSV from ../diagrams/ — no data is duplicated.

If a diagram has a Tier-2 override registered via DiagramBuilder.set_plot_script(), the plugin-provided script is copied instead of generating the generic template. If DiagramBuilder.skip_script_generation() was called, the diagram is skipped entirely.

Parameters:
  • result_id – UUID of the result

  • result_data – Serialised result dict (from model_dump())

  • storage – ResultStorage instance

  • transient_diagram_scripts – Optional dict populated by DiagramBuilder.set_plot_script() and .skip_script_generation(). Key: “diagram:{item_index}:{diagram_id}”.

  • vis_config – Optional VisualizationConfig instance for style snapshot export.

vipr.plugins.api.exporters.script_exporter.generate_run_all_script(result_id: str, storage) None

Scan scripts/plot_*.py in the result directory and write a run_all.sh that executes every script, saves an SVG with the same stem, and opens it.

This is called last in DataCollector.save_result() so it covers both Tier-1 auto-generated diagram scripts and Tier-2 plugin scripts.

Parameters:
  • result_id – UUID of the result

  • storage – ResultStorage instance

vipr.plugins.api.exporters.table_csv_exporter module

Table CSV Exporter - Exports table data as CSV files.

This module provides functionality to extract table data from the DataCollector and save it as CSV files with proper column headers.

vipr.plugins.api.exporters.table_csv_exporter.extract_and_save_table_csv(result_id: str, result_data: dict, storage) None

Extract tables from result data and save them as CSV files.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing tables

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.table_text_formatter module

Table Text Formatter - Formats table data as human-readable text.

This module provides functionality to format table data from the DataCollector as nicely formatted text files with proper column alignment.

vipr.plugins.api.exporters.table_text_formatter.extract_and_save_table_text(result_id: str, result_data: dict, storage) None

Extract tables from result data and save as formatted text files. Creates nicely formatted text tables with proper column alignment.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing tables

  • storage – ResultStorage instance for saving files

Module contents

Result exporters for various output formats.

This module provides exporters that convert DataCollector results into different file formats for easy access and analysis.

vipr.plugins.api.exporters.extract_and_save_diagram_csv(result_id: str, result_data: dict, storage) None

Extract diagrams from result data and save them as CSV files. Creates separate CSV files for each series to ensure X-Y value alignment.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.extract_and_save_diagram_statistics(result_id: str, result_data: dict, storage) None

Extract statistics from diagram metadata and save as formatted text files. Creates log-style text files with goodness-of-fit statistics.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.extract_and_save_images(result_id: str, result_data: dict, storage) None

Extract images from result data and save them as separate files.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing images

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.extract_and_save_plot_scripts(result_id: str, ui_data: UIData, transient_plot_data: dict, transient_plot_scripts: dict, storage, vis_config=None) None

Export plot scripts and data from live UIData and the transient buffers.

Must be called BEFORE model_dump() / pickle serialisation because: - It reads live UIData.items[*].images (Pydantic models, not dicts) - It reads DataCollector._transient_plot_data (never serialised) - It reads DataCollector._transient_plot_scripts (never serialised)

Script path and dependencies are resolved at set_plot_script() time (via inspect.getsourcefile + importlib) and stored transiently — no global registry is needed.

Parameters:
  • result_id – UUID of the result being saved

  • ui_data – Live UIData object (not serialised yet)

  • transient_plot_data – dc._transient_plot_data — “{idx}:{id}” → arrays

  • transient_plot_scripts – dc._transient_plot_scripts — “{idx}:{id}” → {path, deps, data_format}

  • storage – ResultStorage instance

  • vis_config – Optional VisualizationConfig instance for style snapshot export.

vipr.plugins.api.exporters.extract_and_save_table_csv(result_id: str, result_data: dict, storage) None

Extract tables from result data and save them as CSV files.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing tables

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.extract_and_save_table_text(result_id: str, result_data: dict, storage) None

Extract tables from result data and save as formatted text files. Creates nicely formatted text tables with proper column alignment.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing tables

  • storage – ResultStorage instance for saving files

vipr.plugins.api.exporters.generate_diagram_images(result_id: str, result_data: dict, storage, vis_config=None) None

Generate images from diagram data using matplotlib. Automatically creates plots for all diagrams with proper styling.

Parameters:
  • result_id – UUID of the result

  • result_data – The result data dictionary containing diagrams

  • storage – ResultStorage instance for saving files

  • vis_config – Optional VisualizationConfig instance. When provided, per-diagram figsize/format/dpi overrides from the YAML visualization: block are applied. Falls back to DEFAULT_PLOT_STYLE when None.

vipr.plugins.api.exporters.generate_diagram_scripts(result_id: str, result_data: dict, storage, transient_diagram_scripts: dict | None = None, vis_config=None) None

Tier 1: Auto-generate standalone plot scripts for every diagram in result_data.

Runs AFTER serialisation (reads the serialised dict, not live UIData). Scripts are saved to results/<uuid>/scripts/ and load the companion CSV from ../diagrams/ — no data is duplicated.

If a diagram has a Tier-2 override registered via DiagramBuilder.set_plot_script(), the plugin-provided script is copied instead of generating the generic template. If DiagramBuilder.skip_script_generation() was called, the diagram is skipped entirely.

Parameters:
  • result_id – UUID of the result

  • result_data – Serialised result dict (from model_dump())

  • storage – ResultStorage instance

  • transient_diagram_scripts – Optional dict populated by DiagramBuilder.set_plot_script() and .skip_script_generation(). Key: “diagram:{item_index}:{diagram_id}”.

  • vis_config – Optional VisualizationConfig instance for style snapshot export.

vipr.plugins.api.exporters.generate_run_all_script(result_id: str, storage) None

Scan scripts/plot_*.py in the result directory and write a run_all.sh that executes every script, saves an SVG with the same stem, and opens it.

This is called last in DataCollector.save_result() so it covers both Tier-1 auto-generated diagram scripts and Tier-2 plugin scripts.

Parameters:
  • result_id – UUID of the result

  • storage – ResultStorage instance