km3modules.common

A collection of commonly used modules.

Module Contents

Classes

Dump

Print the content of the blob.

Delete

Remove specific keys from the blob.

Keep

Keep only specified keys in the blob.

HitCounter

Prints the number of hits

HitCalibrator

A very basic hit calibrator, which requires a Calibration module.

BlobIndexer

Puts an incremented index in each blob for the key 'blob_index'

StatusBar

Displays the current blob number.

TickTock

Display the elapsed time.

MemoryObserver

Shows the maximum memory usage

Siphon

A siphon to accumulate a given volume of blobs.

MultiFilePump

Use the given pump to iterate through a list of files.

LocalDBService

Provides a local sqlite3 based database service to store information

Observer

A simple helper to observe the blobs in a test pipeline.

FilePump

A basic iterator for a list of files.

Attributes

log

km3modules.common.log[source]
class km3modules.common.Dump(name=None, **parameters)[source]

Print the content of the blob.

Parameters:
keys: collection(string), optional [default=None]

Keys to print. If None, print all keys.

full: bool, default=False

Print blob values too, not just the keys?

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.Delete(name=None, **parameters)[source]

Remove specific keys from the blob.

Parameters:
keys: collection(string), optional

Keys to remove.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.Keep(name=None, **parameters)[source]

Keep only specified keys in the blob.

Parameters:
keys: collection(string), optional

Keys to keep. Everything else is removed.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.HitCounter(name=None, **parameters)[source]

Prints the number of hits

process(blob)[source]

Knead the blob and return it

class km3modules.common.HitCalibrator(name=None, **parameters)[source]

A very basic hit calibrator, which requires a Calibration module.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.BlobIndexer(name=None, **parameters)[source]

Puts an incremented index in each blob for the key ‘blob_index’

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.StatusBar(name=None, **parameters)[source]

Displays the current blob number.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

finish()[source]

Clean everything up.

class km3modules.common.TickTock(name=None, **parameters)[source]

Display the elapsed time.

Parameters:
every: int, optional [default=1]

Number of iterations between printout.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.MemoryObserver(name=None, **parameters)[source]

Shows the maximum memory usage

Parameters:
every: int, optional [default=1]

Number of iterations between printout.

process(blob)[source]

Knead the blob and return it

class km3modules.common.Siphon(name=None, **parameters)[source]

A siphon to accumulate a given volume of blobs.

Parameters:
volume: int

number of blobs to hold

flush: bool

discard blobs after accumulation

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

class km3modules.common.MultiFilePump(name=None, **parameters)[source]

Use the given pump to iterate through a list of files.

The group_id will be reset so that it’s unique for each iteration.

Parameters:
pump: Pump

The pump to be used to generate the blobs.

filenames: iterable(str)

List of filenames.

kwargs: dict(str -> any) optional

Keyword arguments to be passed to the pump.

configure()[source]

Configure module, like instance variables etc.

blob_generator()[source]
process(blob)[source]

Knead the blob and return it

finish()[source]

Clean everything up.

class km3modules.common.LocalDBService(name=None, **parameters)[source]

Provides a local sqlite3 based database service to store information

configure()[source]

Configure module, like instance variables etc.

query(query)[source]

Execute a SQL query and return the result of fetchall()

insert_row(table, column_names, values)[source]

Insert a row into the table with a given list of values

create_table(name, columns, types, overwrite=False)[source]

Create a table with given columns and types, overwrite if specified

The types should be a list of SQL types, like [“INT”, “TEXT”, “INT”]

table_exists(name)[source]

Check if a table exists in the database

finish()[source]

Clean everything up.

class km3modules.common.Observer(name=None, **parameters)[source]

A simple helper to observe the blobs in a test pipeline.

Parameters:
count: int

The exact number of iterations the pipeline has to drain

required_keys: list(str)

A list of keys which has to be present in a blob in every cycle.

configure()[source]

Configure module, like instance variables etc.

process(blob)[source]

Knead the blob and return it

finish()[source]

Clean everything up.

class km3modules.common.FilePump(name=None, **parameters)[source]

A basic iterator for a list of files.

Parameters:
filenames: iterable(str)

The filenames to be iterated over which are put into blob["filename"]

configure()[source]

Configure module, like instance variables etc.

blob_generator()[source]
process(blob)[source]

Knead the blob and return it