plexus.reports.blocks.report_block_orm module
ORM-style ReportBlock class for programmatic API interaction.
This provides a unified interface for working with ReportBlock records, including standardized logging, file attachment, and real-time updates.
- class plexus.reports.blocks.report_block_orm.ReportBlockORM(api_client: PlexusDashboardClient, report_block_id: str | None = None, config: Dict[str, Any] | None = None)
Bases:
objectORM-style class for programmatic ReportBlock API interaction.
Provides unified logging, file management, and eventual real-time updates.
Initialize ReportBlock ORM instance.
- Args:
api_client: Dashboard API client for operations report_block_id: Existing report block ID (None for new blocks) config: Block configuration dictionary
- __init__(api_client: PlexusDashboardClient, report_block_id: str | None = None, config: Dict[str, Any] | None = None)
Initialize ReportBlock ORM instance.
- Args:
api_client: Dashboard API client for operations report_block_id: Existing report block ID (None for new blocks) config: Block configuration dictionary
- attach_file(file_name: str, content: bytes, content_type: str | None = None) str
Attach a file to this report block.
- Args:
file_name: Name of the file to create content: Bytes content of the file content_type: Optional MIME type for the file
- Returns:
The S3 path to the file
- Raises:
ValueError: If no report_block_id is set
- get_attached_files() List[str]
Get list of files attached to this report block.
- Returns:
List of S3 file paths
- get_log_string() str
Get the complete log string for this report block.
- Returns:
Concatenated log messages as a single string
- log(message: str, level: str = 'INFO', console_only: bool = False)
Unified logging method that sends to both console and attached log by default.
- Args:
message: Log message to record level: Log level (DEBUG, INFO, WARNING, ERROR) console_only: If True, only log to console, not to attached log
- log_debug(message: str, console_only: bool = False)
Convenience method for DEBUG level logging.
- log_error(message: str, console_only: bool = False)
Convenience method for ERROR level logging.
- log_info(message: str, console_only: bool = False)
Convenience method for INFO level logging.
- log_warning(message: str, console_only: bool = False)
Convenience method for WARNING level logging.
- set_report_block_id(report_block_id: str)
Set the report block ID (used when creating new blocks).
- Args:
report_block_id: The report block ID from the database