plexus.reports.blocks.base module

class plexus.reports.blocks.base.BaseReportBlock(config: Dict[str, Any], params: Dict[str, Any] | None, api_client: PlexusDashboardClient)

Bases: ABC

Abstract base class for all report blocks.

Each subclass is responsible for generating a specific section or data point within a report.

DEFAULT_DESCRIPTION: str | None = None
DEFAULT_NAME: str | None = None
__init__(config: Dict[str, Any], params: Dict[str, Any] | None, api_client: PlexusDashboardClient)
attach_detail_file(report_block_id: str, file_name: str, content: bytes, content_type: str | None = None) str

Attach a detail file to this report block.

This uploads the file to S3 and adds its path to the ReportBlock’s attachedFiles field. The Amplify Gen2 storage expects paths to be stored, not complex objects.

Args:

report_block_id: ID of the report block to attach the file to file_name: Name of the file to create content: Bytes content of the file (changed from str to bytes) content_type: Optional MIME type for the file

Returns:

The S3 path to the file

abstractmethod async generate() Tuple[Dict[str, Any] | None, str | None]

Generates the data for this report block asynchronously.

Access block configuration via self.config and report parameters via self.params. Use self.api_client for data fetching. Use self._log(“message”) to record log information.

Returns:
A tuple containing:
  • A dictionary containing the generated data (JSON-serializable), or None on failure.

  • A string containing concatenated log messages, or None if no logs.

get_resolved_dataset_id() str | None

Get the resolved dataset ID that this block actually used.

Returns:

The dataset ID if one was resolved, None otherwise

set_resolved_dataset_id(dataset_id: str)

Set the resolved dataset ID that this block actually used.

This should be called by blocks after they have resolved and used a dataset, to record which specific dataset was actually processed.

Args:

dataset_id: The ID of the dataset that was resolved and used