trw.reporting

Submodules

Package Contents

Classes

TableStream

A SQLite table that can be streamed.

PanelDataSamplesTabular

Display tabular data

Functions

as_image_ui8(image, min_value=None, max_value=None)

Rescale the image to fit in [0..255] range.

as_rgb_image(value)

Try interpreting the value as an image. (e.g., 2D, RGB) and return a RGB image

export_image(image, path)

Export an image

export_sample(export_root, table_stream, base_name, batch, sample_ids=None, export_fns=[convert_tuple_to_list, export_as_image, export_as_npy, export_as_text], name_expansions=['epoch', 'batch', 'split', 'dataset'])

Export samples to a SQL database with large binary objects on he local drive

export_as_image(batch, feature_name, name, sample_id, export_root, feature_attributes)

get_table_number_of_rows(cursor, table_name)

Return the number of rows of a table

report(sql_database_path, options, doc=None)

Generate the reporting from a SQL database and configuration.

create_default_reporting_options(embedded=True, config={})

config must follow this scheme:

Attributes

SQLITE_TYPE_PATTERN

trw.reporting.as_image_ui8(image, min_value=None, max_value=None)

Rescale the image to fit in [0..255] range.

Image min will be mapped to 0 and max to 255. Values in this range are interpolated :param image: a RGB float image :return: a RGB unsigned char image

trw.reporting.as_rgb_image(value)

Try interpreting the value as an image. (e.g., 2D, RGB) and return a RGB image :param value: an array of shape (y, x), (1, y, x), (3, y, x) :return: return a (3, y, x) array

trw.reporting.export_image(image, path)

Export an image

Parameters
  • image – a RGB image (float or ui8) with format (channels, height, width)

  • path – where to write the image

Returns

trw.reporting.export_sample(export_root, table_stream, base_name, batch, sample_ids=None, export_fns=[convert_tuple_to_list, export_as_image, export_as_npy, export_as_text], name_expansions=['epoch', 'batch', 'split', 'dataset'])

Export samples to a SQL database with large binary objects on he local drive with the following schema:

{export_root}/{table_stream.table_name}/{base_name}_{**name_expansions}

Parameters
  • export_root – the root from which the data will be exported relatively

  • table_stream – the SQL table where the data will be stored

  • base_name – the basename for the features to be exported on the local drive

  • batch – a key/value store

  • sample_ids – the index of the samples to be exported

  • export_fns – functions to be run to special features such as images, large numpy arrays

  • name_expansions – if the name is present in the batch, the sample name to be exported on the drive will be expanded ``base_name``_{name_expansion}_{batch[name_expansion]}.The purpose is to make sure the name is unique

trw.reporting.export_as_image(batch, feature_name, name, sample_id, export_root, feature_attributes)
class trw.reporting.TableStream(cursor, table_name, table_role, primary_key=None, table_preamble='')

A SQLite table that can be streamed.

Two tables will be created:

  1. in table_name:
    • feature name with *_type will have SQLITE type type

  2. in ``table_name``_metadata:
    • table_role: the role of the table

    • table_preamble: an explanation or complementary info of the table

_create(self, table_name, name_type_list, table_role, primary_key=0)
_insert(self, batch)
insert(self, batch)

Insert a batch of data to the table. If the table doesn’t exist, it will be created.

Parameters

batch – a dictionary like of names and values. All values must have the same length.

get_column_names(self)
trw.reporting.SQLITE_TYPE_PATTERN = _type
trw.reporting.get_table_number_of_rows(cursor, table_name)

Return the number of rows of a table

trw.reporting.report(sql_database_path, options, doc=None)

Generate the reporting from a SQL database and configuration.

Parameters
  • sql_database_path – the path to the SQLite database

  • options – the options to configure the different reporting views

  • doc – a possibly existing Bokeh document

Returns

a populated Bokeh document

trw.reporting.create_default_reporting_options(embedded=True, config={})

config must follow this scheme: {

table_name: {

option1: value1

}

}

The different options will depend on the table role.

  • for ALL tables:

    {n

    ‘data’{

    ‘remove_columns’: [‘column_name1’], ‘subsampling_factor’: 1.0, ‘keep_last_n_rows’: 1000

    }

  • For role data_samples:
    {
    ‘default’:

    ‘Scatter X Axis’: value, ‘Scatter Y Axis’: value, ‘Color by’: value, ‘Color scheme’: value, ‘Binning X Axis’: value, ‘Binning Y Axis’: value, ‘Label with’: value, ‘Display with’: value,

    }

class trw.reporting.PanelDataSamplesTabular(options, name, data, data_types, type_categories, title='Tabular')

Bases: trw.reporting.bokeh_ui.BokehUi

Display tabular data

Configuration options:

default/with_column_title_rotation: 1 or 0

update_data(self, options, name, data, data_types, type_categories)