Job
- class MSMetaEnhancer.libs.utils.Job.Job(data: Tuple[str, str, str])
Bases:
object
- MSMetaEnhancer.libs.utils.Job.convert_to_jobs(jobs: Tuple[str, str, str])
Logger
- class MSMetaEnhancer.libs.utils.Logger.Logger
Bases:
object- add_coverage_after(metadata_keys: List[str])
Increase counts of annotated attributes
- Parameters:
metadata_keys – discovered attributes
- add_coverage_before(metadata_keys: List[str])
Increase counts of already present attributes.
- Parameters:
metadata_keys – present attributes
- add_filehandler(file_name: str = None)
Initialize filehandler for logfile.
- Args:
file_name (str, optional): Log filename. Defaults to None.
- add_logs(log_record: LogRecord)
Flush logs to log file.
- Parameters:
log_record – log record to write and format to file
- set_target_attributes(jobs: List[Job], length: int)
Gather all target attributes from specified jobs
- Parameters:
jobs – given list of jobs
length – number of analysed spectra
- setup(log_level: int, log_file: str)
Initialize log level and log file.
- Args:
log_level (int): Log level to set [‘error’: 1, ‘warning’: 2, ‘info’: 3] log_file (str): Path to log file.
- write_metrics()
Write obtained statistical values.
Metrics
- class MSMetaEnhancer.libs.utils.Metrics.Metrics
Bases:
object- set_params(target_attributes, length)
Set all parameters needed to compute metrics.
- Parameters:
target_attributes – target attributes to be obtained during annotation
length – number of spectra data
- update_after_annotation(metadata_keys)
Increase counts of annotated attributes
- Parameters:
metadata_keys – discovered attributes
- update_before_annotation(metadata_keys)
Increase counts of already present attributes.
- Parameters:
metadata_keys – present attributes
Errors
- exception MSMetaEnhancer.libs.utils.Errors.ConversionNotSupported
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.DataAlreadyPresent
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.InvalidAttributeFormat
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.ServiceNotAvailable
Bases:
Exception- async static raise_circuitbreaker(*args)
- exception MSMetaEnhancer.libs.utils.Errors.SourceAttributeNotAvailable
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.TargetAttributeNotRetrieved
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.UnknownConverter
Bases:
Exception
- exception MSMetaEnhancer.libs.utils.Errors.UnknownFileFormat
Bases:
ExceptionFormat not supported.
- exception MSMetaEnhancer.libs.utils.Errors.UnknownResponse
Bases:
Exception
Throttler
- class MSMetaEnhancer.libs.utils.Throttler.Throttler(rate_limit=10, period=1, retry_interval=0.01)
Bases:
objectClass to limit number of parallel requests by a rate (number per period of time).
- async acquire()
- decrease_limit()
Decrease rate (must be always positive).
- flush()
- increase_limit()
Increase rate up to allow limit.
ConverterBuilder
- class MSMetaEnhancer.libs.utils.ConverterBuilder.ConverterBuilder
Bases:
object- static build_converters(session, converters: list[str])
Create provided converters.
- Parameters:
session – given aiohttp session
converters – list of converters to be built
- Returns:
built converters
- converters: dict[str, type] = {}
- static register(converters: list[type])
- static validate_converters(converters)
Check if converters do exist. Raises UnknownConverter if a converter does not exist.
- Parameters:
converters – given list of converters names
Monitor
- class MSMetaEnhancer.libs.utils.Monitor.Monitor
Bases:
ThreadClass to periodically monitor status of used web.
- static check_service(url)
Send a GET request to given URL with 5 sec timeout.
- Parameters:
url – given URL
- Returns:
True if request is successful with status code 200
- static get_base_url(converter)
Extract base URL from the converter.
- Parameters:
converter – given converter
- Returns:
base URL
- join(timeout=None)
Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating-point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
- run()
Main loop of the Monitor thread.
Monitor checks if GET on base URL of every converter give status code 200. Such a converter is considered available. This is checked periodically to always have up-to-date information.
- set_converters(converters)