biosimulators_utils.log package — BioSimulators utils 0.1.154 documentation

# 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)

  Bases: `biosimulators_utils.log.data_model.Log`

  Log of a COMBINE/OMEX archive

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  sed_documents

    execution status of each SED document in the archive

    Type

      `dict` of `str` to `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  finalize()

    Mark all unexceuted elements as skipped

  to_json()

    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)

  Bases: `object`

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

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  parent

    execution status of parent COMBINE/OMEX archive

    Type

      `Log`

  out_dir

    directory to export status

    Type

      `str`

  export()

    Write to a file

  finalize()

    Mark all unexecuted elements as skipped

  to_json()

    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)

  Bases: `biosimulators_utils.log.data_model.Log`

  Log of a SED output

  id

    id of the output

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  parent

    execution status of parent SED document

    Type

      `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  to_json()

    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)

  Bases: `biosimulators_utils.log.data_model.OutputLog`

  Log of a 2D SED plot

  id

    id of the plot

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  curves

    execution status of each curve

    Type

      `dict` of `str` to `Status`

  parent

    execution status of parent SED document

    Type

      `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  finalize()

    Mark all unexceuted elements as skipped

  to_json()

    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)

  Bases: `biosimulators_utils.log.data_model.OutputLog`

  Log of a 3D SED plot

  id

    id of the plot

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  surfaces

    execution status of each surface

    Type

      `dict` of `str` to `Status`

  parent

    execution status of parent SED document

    Type

      `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  finalize()

    Mark all unexceuted elements as skipped

  to_json()

    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)

  Bases: `biosimulators_utils.log.data_model.OutputLog`

  Log of a SED report

  id

    id of the report

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  data_sets

    execution status of each data set

    Type

      `dict` of `str` to `Status`

  parent

    execution status of parent SED document

    Type

      `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  finalize()

    Mark all unexceuted elements as skipped

  to_json()

    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)

  Bases: `biosimulators_utils.log.data_model.Log`

  Log of a SED document

  location

    location of the SED document

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  tasks

    execution status of each task

    Type

      `dict` of `str` to `TaskLog`

  outputs

    execution status of each output

    Type

      `dict` of `str` to `OutputLog`

  parent

    execution status of parent COMBINE/OMEX archive

    Type

      `CombineArchiveLog`

  out_dir

    directory to export status

    Type

      `str`

  finalize()

    Mark all unexceuted elements as skipped

  to_json()

    Generate a JSON-compatible representation

    Returns

      JSON-compatible representation

    Return type

      `dict`

class biosimulators_utils.log.data_model.StandardOutputErrorCapturerLevel(value)

  Bases: `int`, `enum.Enum`

  Level at which stdout/stderr should be captured

  c = 1
  python = 0

class biosimulators_utils.log.data_model.Status(value)

  Bases: `str`, `enum.Enum`

  Status of COMBINE/OMEX archive or one of its components

  FAILED = 'FAILED'
  QUEUED = 'QUEUED'
  RUNNING = 'RUNNING'
  SKIPPED = 'SKIPPED'
  SUCCEEDED = 'SUCCEEDED'

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)

  Bases: `biosimulators_utils.log.data_model.Log`

  Log of a SED task

  id

    id of the task

    Type

      `str`

  status

    execution status of the archive

    Type

      `Status`

  exception

    exception

    Type

      `Exception`

  skip_reason

    reason of skip

    Type

      `Exception`

  output

    output

    Type

      `str`

  duration

    duration in seconds

    Type

      `float`

  algorithm

    KiSAO id of the requested algorithm

    Type

      `str`

  simulator_details

    additional simulator-specific information

    Type

      `dict`

  parent

    execution status of parent SED document

    Type

      `SedDocumentLog`

  out_dir

    directory to export status

    Type

      `str`

  to_json()

    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)

  Bases: `contextlib.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

    level at which stdout/stderr should be captured

    Type

      `StandardOutputErrorCapturerLevel`, optional

  relay

    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

    whether to capture standard output and error

    Type

      `bool`

  _captured

    logged C output

    Type

      `capturer.CaptureOutput`

  _log

    logged Python output

    Type

      `str`

  _stdout

    overridden stdout

    Type

      `io.IOBase`

  _stderr

    overridden stderr

    Type

      `io.IOBase`

  __enter__()

    Enter a context

  __exit__(exc_type, exc_value, traceback)

    Exit a context

  flush()
  get_text()

    Get the captured standard output/error

    Returns

      captured standard output/error

    Return type

      `str`

  write(message)

biosimulators_utils.log.utils.get_summary_combine_archive_log(log)

  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)

  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'>))

  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'>)

  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'>)

  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'>))

  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'>))

  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=())

  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

  Bases: `biosimulators_utils.warnings.BioSimulatorsWarning`

  Warning that standard output and error could not be logged