bioimageit_core.core package

Submodules

bioimageit_core.core.config module

BioImagePy config module.

This module contains classes that allows to read and manage configuration parameters

Example

You need to use the ConfigAccess which is a singleton to read config

>>> # first call to load the configuration
>>> ConfigAccess("config.json")
>>> # or
>>> ConfigAccess.instance().load("config.json")
>>>
>>> # then to access the config variables
>>> var = ConfigAccess.instance().get('key_name')
>>> # or access the config dictionary
>>> config_dict = ConfigAccess.instance().var

Classes

Config ConfigManager

class bioimageit_core.core.config.Config(config_file: str = '')

Bases: object

Allows to access config variables

The configuration can be instantiate manually but the usage is to instantiate it with the singleton ConfigManager

Parameters:

config_file – File where the configuration is stored in JSON format

config

Dictionary containing the config variables

get(key: str) dict

Read a variable from the config dictionary

Parameters:

key – Key of the variable to read

Return type:

Value of the config variable

Raises:

ConfigKeyNotFoundError – if the configuration key does not exists:

is_key(key: str) bool

Check if a key exists in the config dictionary

Parameters:

key – Key to check

Returns:

True if the key exists, False otherwise

Return type:

bool

load(config_file: str)

Read the metadata from the a json file

save(config_file='')
set(key: str, value)

Add a variable to the config

If the variable exists it is changed

Parameters:
  • key – Key of the variable

  • value – Value to set (can be str, dict, list)

class bioimageit_core.core.config.ConfigAccess(config_file: str)

Bases: object

Singleton to access the Config

Parameters:

config_file – JSON file where the config is stored

Raises:

Exception – if multiple instantiation of the Config is tried:

static file()
static instance(config_file='')

Static access method to the Config.

exception bioimageit_core.core.config.ConfigKeyNotFoundError

Bases: Exception

Raised when key is not found in the config

bioimageit_core.core.exceptions module

exception bioimageit_core.core.exceptions.ConfigError

Bases: Exception

Raised when an error happen when an operation is made on the configuration

exception bioimageit_core.core.exceptions.DataQueryError

Bases: Exception

Raised when an error happen in the metadata query

exception bioimageit_core.core.exceptions.DataServiceError

Bases: Exception

Raised when an error happen in the metadata database

exception bioimageit_core.core.exceptions.RunnerExecError

Bases: Exception

Raised when an error occur during a runner execution

exception bioimageit_core.core.exceptions.ToolNotFoundError

Bases: Exception

Raised when a process is not found

exception bioimageit_core.core.exceptions.ToolsServiceError

Bases: Exception

Raised when an error happen when running a process

bioimageit_core.core.factory module

BioImagePy factory module.

Generic Interface to Object Factory

Classes

ObjectFactory

class bioimageit_core.core.factory.ObjectFactory

Bases: object

create(key, **kwargs)
register_builder(key, builder)

bioimageit_core.core.observer module

class bioimageit_core.core.observer.Observable

Bases: object

Define an object that can be observed

Objects inheriting from this object can be observed by an Observer

add_observer(observer: Observer)

Add an observer

Parameters:

observer – ProgressObserver to add

new_job()

Create a new job

Generate a new job ID and notify all the observers of this new job

notify(message: str, job_id: int = 0)

Notify observers any information

Parameters:
  • message – Information message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_error(message: str, job_id: int = 0)

Notify observers any error

Parameters:
  • message – Error message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_progress(progress: int, message: str = '', job_id: int = 0)

Notify observers computing progress

Parameters:
  • progress – Percentage of progress

  • message – Message to describe the progress step

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_warning(message: str, job_id: int = 0)

Notify observers any warning

Parameters:
  • message – Warning message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

observers_count()

Get the number of observers

remove_observers()
class bioimageit_core.core.observer.Observer(debug=True)

Bases: object

COL_B = '\x1b[34m'
COL_G = '\x1b[32m'
COL_O = '\x1b[33m'
COL_P = '\x1b[35m'

Observer that display messages in the console

The basic implementation just display the progress in the console with ‘print’. Please subclass this class to write progress in log files or notify a GUI for example

COL_R = '\x1b[31m'
COL_W = '\x1b[0m'
new_job(job_id: int)

Add a new job id

Parameters:

job_id (int) – unique ID of the new job

notify(message: str, job_id: int = 0)

Function called by the observable to notify or log any information

Parameters:
  • message (str) – Information message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_error(message: str, job_id: int = 0)

Function called by the observable to warn

Parameters:
  • message – Warning message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_progress(progress: int, message: int = '', job_id: int = 0)

Function called by the observable to notify progress

Parameters:
  • progress – Data describing the progress

  • message – Message to describe the progress step

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_warning(message: str, job_id: int = 0)

Function called by the observable to warn

Parameters:
  • message – Warning message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

bioimageit_core.core.log_observer module

class bioimageit_core.core.log_observer.LogObserver(log_dir, log_file_id=None)

Bases: Observer

Observer that write messages in txt file

The log observer implements the BioImageIT logs in txt file. For each session there is one new log file with the date time, and one extra file per job

Parameters:

log_dir (str) – Path of the directory where the log are saved

new_job(job_id: int)

Add a new job id

Parameters:

job_id (int) – unique ID of the new job

notify(message: str, job_id: int = 0)

Function called by the observable to notify or log any information

Parameters:
  • message (str) – Information message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_error(message: str, job_id: int = 0)

Function called by the observable to warn

Parameters:
  • message – Warning message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_progress(progress: int, message: int = '', job_id: int = 0)

Function called by the observable to notify progress

Parameters:
  • progress – Data describing the progress

  • message – Message to describe the progress step

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

notify_warning(message: str, job_id: int = 0)

Function called by the observable to warn

Parameters:
  • message – Warning message

  • job_id (int) – unique ID of the job. 0 is main app, and positive is a subprocess

bioimageit_core.core.query module

bioimageit_core.core.run module

bioimageit_core.core.serialize module

Serialize the containers

bioimageit_core.core.serialize.serialize_data()
bioimageit_core.core.serialize.serialize_raw_data()
bioimageit_core.core.serialize.serialize_processed_data()
bioimageit_core.core.serialize.serialize_dataset()
bioimageit_core.core.serialize.serialize_experiment()
bioimageit_core.core.serialize.serialize_run()
bioimageit_core.core.serialize.serialize_data(data)

Serialize a data :param data: Container of data metadata :type data: Data

Return type:

str containing the serialized container

bioimageit_core.core.serialize.serialize_dataset(dataset)

Serialize a dataset :param dataset: Container of dataset metadata :type dataset: Dataset

Return type:

str containing the serialized container

bioimageit_core.core.serialize.serialize_experiment(experiment)

Serialize an experiment :param experiment: Container of experiment metadata :type experiment: Experiment

Return type:

str containing the serialized container

bioimageit_core.core.serialize.serialize_processed_data(processed_data)

Serialize a processed_data

Parameters:

processed_data (ProcessedData) – Container of processed data metadata

Return type:

str containing the serialized container

bioimageit_core.core.serialize.serialize_raw_data(raw_data)

Serialize a raw data :param raw_data: Container of raw data metadata :type raw_data: RawData

Return type:

str containing the serialized container

bioimageit_core.core.serialize.serialize_run(run)

Serialize a run :param run: Container of run metadata :type run: Run

Return type:

str containing the serialized container

bioimageit_core.core.toolboxes module

bioimageit_core.core.utils module

bioimageit_core.core.utils.extract_filename(uri: str)
bioimageit_core.core.utils.format_date(date: str)
bioimageit_core.core.utils.generate_uuid()

Module contents