logml.report.notebooks.base

Functions

render_template(template_name[, context, ...])

Renders template with jinja2.

Classes

BKNotebookExecutionStatus(value)

Defines possible BK notebook statuses.

BKNotebookScopes(value)

Defines possible BasekineKit scopes.

BaseBKNotebook(cfg, global_params, ...[, ...])

Base BaselineKit Notebook class.

BaseReportItem(cfg, global_params, ...[, ...])

Base Report Item class.

CustomNotebook(*args[, custom_template_name])

Custom Notebook class.

InjectionRemovePreprocessor(**kwargs)

Mark injected-parameters to be removed.

NotebooksSet(cfg, global_params, ...[, logger])

Base class for group of notebooks, such as EDA

TemplateLoader(package)

LogML template loader for Jinja2 templates.

TemplatedArtifact(cfg, global_params, ...[, ...])

Generates report artifact from Jinja2 template.

class logml.report.notebooks.base.BKNotebookExecutionStatus(value)

Bases: str, enum.Enum

Defines possible BK notebook statuses.

SUCCESS = 'successful'
FAILURE = 'failed'
UNDEFINED = 'undefined'
class logml.report.notebooks.base.BKNotebookMetadata

Bases: pydantic.main.BaseModel

Defines a schema for BK notebook metadata.

Show JSON schema
{
   "$ref": "#/definitions/BKNotebookMetadata",
   "definitions": {
      "BKNotebookExecutionStatus": {
         "title": "BKNotebookExecutionStatus",
         "description": "Defines possible BK notebook statuses.",
         "enum": [
            "successful",
            "failed",
            "undefined"
         ],
         "type": "string"
      },
      "BKNotebookMetadata": {
         "title": "BKNotebookMetadata",
         "description": "Defines a schema for BK notebook metadata.",
         "type": "object",
         "properties": {
            "executed_notebook_path": {
               "title": "Executed Notebook Path",
               "type": "string"
            },
            "class_name": {
               "title": "Class Name",
               "type": "string"
            },
            "topic": {
               "title": "Topic",
               "type": "string"
            },
            "execution_status": {
               "$ref": "#/definitions/BKNotebookExecutionStatus"
            },
            "children": {
               "title": "Children",
               "default": [],
               "type": "array",
               "items": {
                  "$ref": "#/definitions/BKNotebookMetadata"
               }
            },
            "toc_entry": {
               "title": "Toc Entry",
               "default": {},
               "type": "object"
            },
            "report_section": {
               "title": "Report Section",
               "default": "",
               "type": "string"
            }
         },
         "required": [
            "executed_notebook_path",
            "class_name",
            "topic",
            "execution_status"
         ]
      }
   }
}

Fields
field executed_notebook_path: str [Required]
field class_name: str [Required]
field topic: str [Required]
field execution_status: logml.report.notebooks.base.BKNotebookExecutionStatus [Required]
field children: List[logml.report.notebooks.base.BKNotebookMetadata] = []
field toc_entry: dict = {}
field report_section: str = ''
class logml.report.notebooks.base.BKNotebookScopes(value)

Bases: str, enum.Enum

Defines possible BasekineKit scopes. NOTE: Scopes are NOT mutually exclusive.

GLOBAL = 'global'
STRATA = 'strata'
SETUP = 'setup'
class logml.report.notebooks.base.InjectionRemovePreprocessor(**kwargs)

Bases: nbconvert.preprocessors.base.Preprocessor

Mark injected-parameters to be removed.

remove_cell_tags = {'injected-parameters'}
check_cell_conditions(cell, unused_resources, unused_index)

Checks that a cell has a tag that is to be removed

preprocess(nb, resources)

Preprocessing to apply to a notebook

preprocess_cell(cell, resources, index)

Apply a transformation on each cell.

class logml.report.notebooks.base.BaseReportItem(cfg: GlobalConfig, global_params: Dict, output_structure: logml.report.ReportOutputStructure, logger: logging.Logger = None, file_ext: str = '.ipynb')

Bases: object

Base Report Item class. Generates artifact to be included into final Logml report.

ALIAS: str = None
VIEWS: List[str] = []
SCOPE: List[logml.report.notebooks.base.BKNotebookScopes] = []
get_notebook_filename(*suffix_args)

Based on the notebook’s scope defines its filename.

get_result_notebook_path()

Returns a path where executed notebook will be dumped.

get_notebook_metadata_path()

Returns a path where notebook’s metadata will be dumped.

get_notebook_metadata() logml.report.notebooks.base.BKNotebookMetadata

Returns a metadata object for the notebook.

get_notebook_toc_entry() dict

Get table of content entry for the notebook.

generate(write_metadata=True) None

Generates artifact.

get_report_section() str

Returns report chapter to assign notebook to

class logml.report.notebooks.base.BaseBKNotebook(cfg: GlobalConfig, global_params: Dict, output_structure: logml.report.ReportOutputStructure, logger: logging.Logger = None, file_ext: str = '.ipynb')

Bases: logml.report.notebooks.base.BaseReportItem

Base BaselineKit Notebook class.

Links views and scope, so that a notebook doesn’t depend on BaselineKit module.

Supports template notebook generation and execution capabilities.

get_template_notebook_path()

Returns a path where template notebook will be dumped.

class logml.report.notebooks.base.CustomNotebook(*args, custom_template_name: Optional[str] = None, **kwargs)

Bases: logml.report.notebooks.base.BaseBKNotebook

Custom Notebook class.

Loads prepared notebook from ipynb file.

VIEWS: List[str] = []
SCOPE: List[logml.report.notebooks.base.BKNotebookScopes] = []
ALIAS: str = None
get_custom_template_path()

Returns a path of custom template notebook.

get_report_section() str

Returns report chapter to assign notebook to

class logml.report.notebooks.base.TemplatedArtifact(cfg, global_params, output_structure, logger=None, file_ext: str = '.md', template_name: Optional[str] = None)

Bases: logml.report.notebooks.base.BaseReportItem

Generates report artifact from Jinja2 template.

TEMPLATE_NAME: Optional[str] = None
class logml.report.notebooks.base.NotebooksSet(cfg, global_params, output_structure, logger=None)

Bases: logml.report.notebooks.base.BaseReportItem

Base class for group of notebooks, such as EDA

INNER_NOTEBOOKS: List[Type[logml.report.notebooks.base.BaseBKNotebook]] = []
generate_topic_content() str

Generate content for the section page. Note: leave it empty if you generate file is some other page.

get_notebook_toc_entry() dict

Get table of content entry for the Topic notebook.

generate(write_metadata=True) None

Simply invokes .generate method of the inner notebooks.

class logml.report.notebooks.base.TemplateLoader(package)

Bases: jinja2.loaders.BaseLoader

LogML template loader for Jinja2 templates.

get_source(environment, template)

See parent description.

logml.report.notebooks.base.render_template(template_name: str, context: Optional[dict] = None, templates_package=None) str

Renders template with jinja2.

Parameters
  • template_name – Template file name, to be located in template_package package.

  • context – Data to be provided to be rendered.

  • templates_package – Package to look for template file. Default is baselinekit.notebooks.templates.

Returns

String with processed template.