mirar.monitor package

Submodules

mirar.monitor.base_monitor module

Script containing the Monitor class, used for processing data in real time.

exception mirar.monitor.base_monitor.ImageTimeoutError[source]

Bases: ProcessorError

Timeout for downloading an image has been exceeded.

class mirar.monitor.base_monitor.Monitor(night: str, pipeline: str, cal_requirements: list[CalRequirement] | None = None, realtime_configurations: str | list[str] = 'default', postprocess_configurations: str | list[str] | None = None, email_sender: str | None = None, email_recipients: str | list | None = None, midway_postprocess_hours: float = 16.0, final_postprocess_hours: float = 48.0, log_level: str = 'INFO', raw_dir: str = 'raw', base_raw_img_dir: Path = PosixPath('/home/docs'))[source]

Bases: object

Class to ‘monitor’ a directory, watching for newly created files. It then reduces these files. It will watch for a fixed duration, and run a postprocessing step at some configurable time after starting. It can send automated email notifications.

configure_logs(log_level='INFO')[source]

Function to configure the log level for the python logger. Posts the log to the terminal and also writes it to a file.

Parameters:

log_level – python log level

Returns:

lof file path

get_cals() ImageBatch[source]

Returns a copy of the calibration images (new and archival)

Returns:

postprocess()[source]

Function to be run after some realtime postprocessing has been run. This function is called once after a configurable number of hours (typically when the data is expected to be done), and then again when the monitor stops watching the directory.

Returns:

None

process_load_queue(queue: Queue)[source]

This is the worker thread function. It is run as a daemon threads that only exit when the main thread ends.

Args

queue: Queue() object

process_realtime()[source]

Function to initiate the actual monitoring.

Returns:

None

summarise_errors(errorstack: ErrorStack)[source]

Create a text summary using an errorstack and the list of processed images. Sends an email of this if configured to do so, or prints otherwise.

Parameters:

errorstack – list of errors to summarise

Returns:

None

update_cals(new_calibration_image: Image)[source]

Updates the calibration images by adding a new calibration image. The archival cal images are then rechecked, and only those which are still required are loaded.

Parameters:

new_calibration_image – new image

Returns:

None

update_error_log()[source]

Function to overwrite the error file with the latest version. The error summary is cumulative, so this just updates the file.

class mirar.monitor.base_monitor.NewImageHandler(queue)[source]

Bases: FileSystemEventHandler

Class to watch a directory, and add newly-created files to a queue.

on_created(event)[source]

Called when a file or directory is created.

Parameters:

event (DirCreatedEvent or FileCreatedEvent) – Event representing file/directory creation.