vuegen.report module

Contents

vuegen.report module#

Contains all comonent classes and Report related base classes for VueGen.

class vuegen.report.APICall(title: str, logger: Logger, api_url: str, method: str = 'GET', caption: str = None, headers: dict | None = None, params: dict | None = None, request_body: dict | None = None)[source]#

Bases: Component

A component for interacting with APIs in a report.

api_url#

The URL of the API to interact with.

Type:

str

method#

HTTP method to use for the request (“GET”, “POST”, or “PUT”). The deafult is “GET”.

Type:

str

headers#

Headers to include in the API request (default is None).

Type:

Optional[dict]

params#

Query parameters to include in the API request (default is None).

Type:

Optional[dict]

request_body#

The request body for methods like POST or PUT (default is None).

Type:

Optional[dict]

make_api_request(dynamic_request_body: dict | None = None) dict | None[source]#

Sends an HTTP request to the specified API and returns the JSON response. It allows overriding the request body dynamically.

Parameters:

dynamic_request_body (Optional[dict]) – A dictionary to use as the JSON request body for this specific call. Overrides the instance’s request_body if provided.

Returns:

response – The JSON response from the API, or None if the request fails.

Return type:

Optional[dict]

class vuegen.report.CSVNetworkFormat(value)[source]#

Bases: StrEnum

Enum representing different formats for CSV network files.

ADJLIST = 'adjlist'#
EDGELIST = 'edgelist'#
class vuegen.report.ChatBot(title: str, logger: Logger, api_url: str, caption: str = None, model: str | None = None, headers: dict | None = None, params: dict | None = None)[source]#

Bases: Component

A component for creating a ChatBot that interacts with an API. This component uses an APICall instance to send requests to the chatbot API and receive responses.

api_call#

An instance of the APICall class used to interact with the API for fetching chatbot responses.

Type:

APICall

model#

The language model to use for the chatbot (default is None).

Type:

Optional[str]

headers#

Headers to include in the API request (default is None).

Type:

Optional[dict]

params#

Query parameters to include in the API request (default is None).

Type:

Optional[dict]

class vuegen.report.Component(title: str, component_type: ComponentType, logger: Logger, file_path: str | None = None, caption: str | None = None)[source]#

Bases: object

Base class for different components in a report subsection. It encapsulates elements like plots, dataframes, markdown, or apicalls, providing a consistent structure for report generation.

_id_counter#

Class-level counter for unique IDs.

Type:

ClassVar[int]

id#

Unique identifier for the component, assigned automatically when an object is created.

Type:

int

title#

Title of the component.

Type:

str

component_type#

Type of the component (e.g., PLOT, DATAFRAME, MARKDOWN, APICALL).

Type:

ComponentType

logger#

Logger object for tracking warnings, errors, and info messages.

Type:

logging.Logger

file_path#

Path to the file associated with the component (e.g., plot JSON file, image file, csv file, etc.).

Type:

Optional[str]

caption#

Caption providing additional context about the component (default: None).

Type:

Optional[str]

caption: str | None = None#
component_type: ComponentType#
file_path: str | None = None#
id: int#
logger: Logger#
title: str#
class vuegen.report.ComponentType(value)[source]#

Bases: StrEnum

Enum representing different types of components in a report subsection.

APICALL = 'apicall'#
CHATBOT = 'chatbot'#
DATAFRAME = 'dataframe'#
HTML = 'html'#
MARKDOWN = 'markdown'#
PLOT = 'plot'#
class vuegen.report.DataFrame(title: str, logger: Logger, file_format: DataFrameFormat, file_path: str = None, caption: str = None, delimiter: str | None = None)[source]#

Bases: Component

A DataFrame within a subsection of a report.

file_format#

The format of the file from which the DataFrame is loaded (e.g., CSV, TXT, PARQUET).

Type:

DataFrameFormat

delimiter#

The delimiter to use if the file is a delimited text format (e.g., ‘;’, ‘ ‘, etc).

Type:

Optional[str]

class vuegen.report.DataFrameFormat(value)[source]#

Bases: StrEnum

Enum representing different file formats for data in DataFrame format.

CSV = 'csv'#
PARQUET = 'parquet'#
TXT = 'txt'#
XLS = 'xls'#
XLSX = 'xlsx'#
property value_with_dot#

Return the file extension with the dot.

class vuegen.report.Html(title: str, logger: Logger, file_path: str = None, caption: str = None)[source]#

Bases: Component

An html component within a subsection of a report.

class vuegen.report.ImageFormat(value)[source]#

Bases: StrEnum

Enum representing supported image file formats.

GIF = 'gif'#
JPEG = 'jpeg'#
JPG = 'jpg'#
PNG = 'png'#
SVG = 'svg'#
WEBP = 'webp'#
property value_with_dot#

Return the file extension with the dot.

class vuegen.report.Markdown(title: str, logger: Logger, file_path: str = None, caption: str = None)[source]#

Bases: Component

A Markdown text component within a subsection of a report.

class vuegen.report.NetworkFormat(value)[source]#

Bases: StrEnum

Enum representing different formats for network graphs.

CSV = 'csv'#
CYJS = 'cyjs'#
GEXF = 'gexf'#
GML = 'gml'#
GRAPHML = 'graphml'#
HTML = 'html'#
JPEG = 'jpeg'#
JPG = 'jpg'#
PNG = 'png'#
SVG = 'svg'#
TXT = 'txt'#
property value_with_dot#

Return the file extension with the dot.

class vuegen.report.Plot(title: str, logger: Logger, plot_type: PlotType, file_path: str = None, caption: str = None, csv_network_format: CSVNetworkFormat | None = None)[source]#

Bases: Component

A plot within a subsection of a report.

plot_type#

The type of the plot (INTERACTIVE or STATIC).

Type:

PlotType

csv_network_format#

The format of the CSV file for network plots (EDGELIST or ADJLIST) (default is None).

Type:

CSVNetworkFormat, optional

create_and_save_pyvis_network(G: Graph, output_file: str) Network[source]#

Creates a PyVis network from a NetworkX graph object and saves it as an HTML file.

Parameters:
  • G (networkx.Graph) – A NetworkX graph object.

  • output_file (str) – The file path where the HTML should be saved.

Returns:

net – A PyVis network object.

Return type:

pyvis.network.Network

read_network() Graph[source]#

Reads the network file and returns a NetworkX graph object.

Returns:

G – A NetworkX graph object created from the specified network file.

Return type:

networkx.Graph

Raises:
save_network_image(G: Graph, output_file: str, format: str, dpi: int = 300) None[source]#

Saves a NetworkX graph as an image file in the specified format and resolution.

Parameters:
  • G (networkx.Graph) – A NetworkX graph object.

  • output_file (str) – The file path where the image should be saved.

  • format (str) – The format of the image file (e.g., ‘png’, ‘jpg’, ‘svg’).

  • dpi (int, optional) – The resolution of the image in dots per inch (default is 300).

class vuegen.report.PlotType(value)[source]#

Bases: StrEnum

Enum representing different types of plots that can be generated.

ALTAIR = 'altair'#
INTERACTIVE_NETWORK = 'interactive_network'#
PLOTLY = 'plotly'#
STATIC = 'static'#
class vuegen.report.Report(title: str, logger: Logger, sections: List[Section] = <factory>, description: str | None = None, graphical_abstract: str | None = None, logo: str | None = None)[source]#

Bases: object

A report consisting of multiple sections and subsections.

title#

Title of the report.

Type:

str

logger#

Logger object for tracking warnings, errors, and info messages.

Type:

logging.Logger

sections#

A list of sections that belong to the report.

Type:

List[Section]

description#

Description of the report (default is None).

Type:

str, optional

graphical_abstract#

Path to the graphical abstract image (default is None).

Type:

str, optional

The file path to the logo image (default is None).

Type:

str, optional

description: str | None = None#
graphical_abstract: str | None = None#
logger: Logger#
logo: str | None = None#
sections: List[Section]#
title: str#
class vuegen.report.ReportType(value)[source]#

Bases: StrEnum

Enum representing different types of reports that can be generated.

DOCX = 'docx'#
HTML = 'html'#
JUPYTER = 'jupyter'#
ODT = 'odt'#
PDF = 'pdf'#
PPTX = 'pptx'#
REVEALJS = 'revealjs'#
STREAMLIT = 'streamlit'#
class vuegen.report.ReportView(report: Report, report_type: ReportType)[source]#

Bases: ABC

An abstract base class for report view implementations.

id#

A unique identifier for the report view ABC.

Type:

int

name#

The name of the view.

Type:

str

report#

The report that this ABC is associated with.

Type:

Report

report_type#

The report type. It should be one of the values of the ReportType Enum.

Type:

ReportType

abstractmethod generate_report(output_dir: str = 'sections') None[source]#

Generates the report and creates output files.

Parameters:

output_dir (str, optional) – The folder where the generated report files will be saved (default is ‘sections’).

abstractmethod run_report(output_dir: str = 'sections') None[source]#

Runs the generated report.

Parameters:

output_dir (str, optional) – The folder where the report was generated (default is ‘sections’).

class vuegen.report.Section(title: str, subsections: List[Subsection] = <factory>, components: List[Component] = <factory>, description: str | None = None, file_path: str | None = None)[source]#

Bases: object

A section within a report, containing multiple subsections.

_id_counter#

Class-level counter for unique IDs.

Type:

ClassVar[int]

id#

Unique identifier for the section, assigned automatically when an object is created.

Type:

int

title#

Title of the section.

Type:

str

subsections#

A list of subsections within the section.

Type:

List[Subsection]

components#

A list of components within the subsection.

Type:

List[Component]

description#

A description of the section (default is None).

Type:

str, optional

file_path#

Relative file path to the section file in sections folder. Used for building reports (default is None).

Type:

str, optional

components: List[Component]#
description: str | None = None#
file_path: str | None = None#
id: int#
subsections: List[Subsection]#
title: str#
class vuegen.report.Subsection(title: str, components: List[Component] = <factory>, description: str | None = None, file_path: str | None = None)[source]#

Bases: object

A subsection within a section, containing multiple components (plots, dataFrames, markdown text, apicals, etc).

_id_counter#

Class-level counter for unique IDs.

Type:

ClassVar[int]

id#

Unique identifier for the subsection, assigned automatically when an object is created.

Type:

int

title#

Title of the subsection.

Type:

str

components#

A list of components within the subsection.

Type:

List[Component]

description#

A description of the subsection (default is None).

Type:

str, optional

file_path#

Relative file path to the section file in sections folder. Used for building reports (default is None).

Type:

str, optional

components: List[Component]#
description: str | None = None#
file_path: str | None = None#
id: int#
title: str#
class vuegen.report.WebAppReportView(report: Report, report_type: ReportType)[source]#

Bases: ReportView

An abstract class for web application report views.