Skip to content

Generic base in situ block

GenericInSituBlock

Bases: DataBlock, ABC

Abstract base class for an in-situ data block. Manages data loading, processing, parameter handling, and plotting.

Attributes:

Name Type Description
accepted_file_extensions Tuple[str, ...]
block_db_model
blocktype str
defaults Dict[str, Any]
description str
name str
plot_functions
version str

accepted_file_extensions

accepted_file_extensions: Tuple[str, ...] = ('.zip',)

block_db_model

block_db_model = InsituBlockResponse

blocktype

blocktype: str = 'generic-insitu'

defaults

defaults: Dict[str, Any] = {}

description

description: str = 'A base class for in-situ data processing blocks.'

name

name: str = 'Generic Data Block'

plot_functions

plot_functions

version

version: str = __version__

get_available_folders

get_available_folders(file_path: Path) -> List[str]

Extract and return a list of available folders from the zip file.

This method opens the zip file identified by file_id, extracts the main folder and its subfolders, and returns a sorted list of subfolder names.

Parameters:

Name Type Description Default
file_path Path

Path to the zip file.

required

Returns:

Type Description
List[str]

Sorted list of subfolder names, or empty list if file not found or on error.

process_and_store_data

process_and_store_data(file_path: str | Path)

Subclasses must implement this method to process and store data.

subsample_data

subsample_data(data: Union[DataFrame, ndarray], sample_granularity: int, data_granularity: int, method: str = 'linear') -> Union[DataFrame, ndarray]

Subsample data to a specified granularity in both sample and feature dimensions.

Parameters:

Name Type Description Default
data Union[DataFrame, ndarray]

The data to be subsampled.

required
sample_granularity int

Subsampling step along rows (samples).

required
data_granularity int

Subsampling step along columns (features).

required
method str

Subsampling method; currently supports only 'linear' and 'max_pooling'.

'linear'

Returns:

Type Description
Union[DataFrame, ndarray]

Subsampled data of the same type as input.

InsituBlockResponse

Bases: DataBlockResponse

Response model extensions for the in situ data block operations.

Attributes:

Name Type Description
processed dict | None

processed

processed: dict | None = Field(datalab_exclude_from_db=True, datalab_exclude_from_load=True, datalab_exclude_from_response=True)

set_processed_default

set_processed_default(v)

Always null this field on load and response, as it's meant to be used only in-memory.

This is a bit of a temporary hack to allow testing of processed data.