biosimulators_utils.log package#

Submodules#

biosimulators_utils.log.data_model module#

Data model for the execution status of COMBINE/OMEX archives

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

class biosimulators_utils.log.data_model.CombineArchiveLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, sed_documents=None, out_dir=None)[source]#

Bases: Log

Log of a COMBINE/OMEX archive

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

sed_documents[source]#

execution status of each SED document in the archive

Type:

dict of str to SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

finalize()[source]#

Mark all unexceuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.Log(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, parent=None, out_dir=None)[source]#

Bases: object

Log of a COMBINE/OMEX archive or one of its components

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

parent[source]#

execution status of parent COMBINE/OMEX archive

Type:

Log

out_dir[source]#

directory to export status

Type:

str

export()[source]#

Write to a file

finalize()[source]#

Mark all unexecuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.OutputLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, parent=None, out_dir=None)[source]#

Bases: Log

Log of a SED output

id[source]#

id of the output

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

parent[source]#

execution status of parent SED document

Type:

SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.Plot2DLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, curves=None, parent=None, out_dir=None)[source]#

Bases: OutputLog

Log of a 2D SED plot

id[source]#

id of the plot

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

curves[source]#

execution status of each curve

Type:

dict of str to Status

parent[source]#

execution status of parent SED document

Type:

SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

finalize()[source]#

Mark all unexceuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.Plot3DLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, surfaces=None, parent=None, out_dir=None)[source]#

Bases: OutputLog

Log of a 3D SED plot

id[source]#

id of the plot

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

surfaces[source]#

execution status of each surface

Type:

dict of str to Status

parent[source]#

execution status of parent SED document

Type:

SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

finalize()[source]#

Mark all unexceuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.ReportLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, data_sets=None, parent=None, out_dir=None)[source]#

Bases: OutputLog

Log of a SED report

id[source]#

id of the report

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

data_sets[source]#

execution status of each data set

Type:

dict of str to Status

parent[source]#

execution status of parent SED document

Type:

SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

finalize()[source]#

Mark all unexceuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.SedDocumentLog(location=None, status=None, exception=None, skip_reason=None, output=None, duration=None, tasks=None, outputs=None, parent=None, out_dir=None)[source]#

Bases: Log

Log of a SED document

location[source]#

location of the SED document

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

tasks[source]#

execution status of each task

Type:

dict of str to TaskLog

outputs[source]#

execution status of each output

Type:

dict of str to OutputLog

parent[source]#

execution status of parent COMBINE/OMEX archive

Type:

CombineArchiveLog

out_dir[source]#

directory to export status

Type:

str

finalize()[source]#

Mark all unexceuted elements as skipped

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

class biosimulators_utils.log.data_model.StandardOutputErrorCapturerLevel(value)[source]#

Bases: int, Enum

Level at which stdout/stderr should be captured

__format__(format_spec)[source]#

Returns format using actual value type unless __str__ has been overridden.

c = 1[source]#
python = 0[source]#
class biosimulators_utils.log.data_model.Status(value)[source]#

Bases: str, Enum

Status of COMBINE/OMEX archive or one of its components

FAILED = 'FAILED'[source]#
QUEUED = 'QUEUED'[source]#
RUNNING = 'RUNNING'[source]#
SKIPPED = 'SKIPPED'[source]#
SUCCEEDED = 'SUCCEEDED'[source]#
__format__(format_spec)[source]#

Returns format using actual value type unless __str__ has been overridden.

class biosimulators_utils.log.data_model.TaskLog(id=None, status=None, exception=None, skip_reason=None, output=None, duration=None, algorithm=None, simulator_details=None, parent=None, out_dir=None)[source]#

Bases: Log

Log of a SED task

id[source]#

id of the task

Type:

str

status[source]#

execution status of the archive

Type:

Status

exception[source]#

exception

Type:

Exception

skip_reason[source]#

reason of skip

Type:

Exception

output[source]#

output

Type:

str

duration[source]#

duration in seconds

Type:

float

algorithm[source]#

KiSAO id of the requested algorithm

Type:

str

simulator_details[source]#

additional simulator-specific information

Type:

dict

parent[source]#

execution status of parent SED document

Type:

SedDocumentLog

out_dir[source]#

directory to export status

Type:

str

to_json()[source]#

Generate a JSON-compatible representation

Returns:

JSON-compatible representation

Return type:

dict

biosimulators_utils.log.utils module#

Utilities for working with COMBINE/OMEX archives

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

class biosimulators_utils.log.utils.StandardOutputErrorCapturer(level=StandardOutputErrorCapturerLevel.c, relay=False, termination_delay=0.01, disabled=False)[source]#

Bases: AbstractContextManager

Context manager for capturing standard output/error. When capturer is available (i.e., Linux, MacOS, Unix), capturer is used to capture standard output/error. When capturer is not available (i.e. Windows), this context manager issues a warn and collects no output. The purpose of this context manager is to encapsulate the handling of whether capturer is or isn’t available so that the other modules can work seamless in Linux, as well as Windows (except without the ability to log standard output/error).

level[source]#

level at which stdout/stderr should be captured

Type:

StandardOutputErrorCapturerLevel, optional

relay[source]#

if True, collect the standard output/error streams and continue to pass them along. if False, collect the stream, squash them, and do not pass them along.

Type:

bool

disabled[source]#

whether to capture standard output and error

Type:

bool

_captured[source]#

logged C output

Type:

capturer.CaptureOutput

_log[source]#

logged Python output

Type:

str

_stdout[source]#

overridden stdout

Type:

io.IOBase

_stderr[source]#

overridden stderr

Type:

io.IOBase

__enter__()[source]#

Enter a context

__exit__(exc_type, exc_value, traceback)[source]#

Exit a context

flush()[source]#
get_text()[source]#

Get the captured standard output/error

Returns:

captured standard output/error

Return type:

str

write(message)[source]#
biosimulators_utils.log.utils.get_summary_combine_archive_log(log)[source]#

Get a summary of the log of a COMBINE/OMEX archive

Parameters:

log (CombineArchiveLog) – log of a COMBINE/OMEX archive

Returns:

summary of the log

Return type:

str

biosimulators_utils.log.utils.init_combine_archive_log(archive, archive_dir, supported_features=(<class 'biosimulators_utils.sedml.data_model.SedDocument'>, <class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), logged_features=(<class 'biosimulators_utils.sedml.data_model.SedDocument'>, <class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), config=None)[source]#

Initialize a log of a COMBINE/OMEX archive

Parameters:
  • archive (CombineArchive) – COMBINE/OMEX archive

  • archive_dir (str) – path where the content of the archive is located

  • supported_features (list of type, optional) – list of supported elements. Default: COMBINE/OMEX archives and SED documents, tasks, reports, plots, data sets, curves, and surfaces.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: COMBINE/OMEX archives and SED documents, tasks, reports, plots, data sets, curves, and surfaces.

  • config (Config, optional) – whether to fail on missing includes

Returns:

initialized log of a COMBINE/OMEX archive

Return type:

CombineArchiveLog

biosimulators_utils.log.utils.init_output_log(output, supported_features=(<class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), logged_features=(<class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>))[source]#

Initialize a log of an output

Parameters:
  • output (Output) – a SED output

  • supported_features (list of type, optional) – list of supported elements. Default: data sets, curves, and surfaces.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: data sets, curves, and surfaces.

Returns:

initialized log of a SED document

Return type:

OutputLog

biosimulators_utils.log.utils.init_plot2d_log(plot, supported_features=<class 'biosimulators_utils.sedml.data_model.Curve'>, logged_features=<class 'biosimulators_utils.sedml.data_model.Curve'>)[source]#

Initialize a log of a 2D plot

Parameters:
  • plot (Plot2D) – a SED 2D plot

  • supported_features (list of type, optional) – list of supported elements. Default: curves.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: curves.

Returns:

initialized log of a 2D plot

Return type:

Plot2DLog

biosimulators_utils.log.utils.init_plot3d_log(plot, supported_features=<class 'biosimulators_utils.sedml.data_model.Surface'>, logged_features=<class 'biosimulators_utils.sedml.data_model.Surface'>)[source]#

Initialize a log of a 3D plot

Parameters:
  • plot (Plot3D) – a SED 3D plot

  • supported_features (list of type, optional) – list of supported elements. Default: surfaces.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: surfaces.

Returns:

initialized log of a 3D plot

Return type:

Plot3DLog

biosimulators_utils.log.utils.init_report_log(report, supported_features=(<class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), logged_features=(<class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>))[source]#

Initialize a log of a report

Parameters:
  • report (Report) – a SED report

  • supported_features (list of type, optional) – list of supported elements. Default: data sets.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: data sets.

Returns:

initialized log of a report

Return type:

ReportLog

biosimulators_utils.log.utils.init_sed_document_log(doc, supported_features=(<class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>), logged_features=(<class 'biosimulators_utils.sedml.data_model.Task'>, <class 'biosimulators_utils.sedml.data_model.Report'>, <class 'biosimulators_utils.sedml.data_model.Plot2D'>, <class 'biosimulators_utils.sedml.data_model.Plot3D'>, <class 'biosimulators_utils.sedml.data_model.DataSet'>, <class 'biosimulators_utils.sedml.data_model.Curve'>, <class 'biosimulators_utils.sedml.data_model.Surface'>))[source]#

Initialize a log of a SED document

Parameters:
  • doc (SedDocument) – SED document

  • supported_features (list of type, optional) – list of supported elements. Default: tasks, reports, plots, data sets, curves, and surfaces.

  • logged_features (list of type, optional) – list of SED elements which will be logged. Default: tasks, reports, plots, data sets, curves, and surfaces.

Returns:

initialized log of a SED document

Return type:

SedDocumentLog

biosimulators_utils.log.utils.init_task_log(task, supported_features=(), logged_features=())[source]#

Initialize a log of a task

Parameters:
  • output (Task) – a SED task

  • supported_features (list of type, optional) – list of supported elements. Default: empty list.

  • logged_features (list of type, optional) – list of elements which will be logged. Default: empty list.

Returns:

initialized log of a SED document

Return type:

OutputLog

biosimulators_utils.log.warnings module#

Warnings for logging

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2021-02-04

Copyright:

2021, Center for Reproducible Biomedical Modeling

License:

MIT

exception biosimulators_utils.log.warnings.StandardOutputNotLoggedWarning[source]#

Bases: BioSimulatorsWarning

Warning that standard output and error could not be logged