scistag.examples.vislog.getting_started.DemoBuilder¶
- class DemoBuilder(log)[source]¶
Bases:
VisualLogBuilder- Parameters
log (
VisualLog) – The log to which the content shall be added.
Methods
Adds the provided content to the log.
Inserts a simple line break
Builds the whole page including header, footers and other sugar.
Is called when the body of the log shall be build or rebuild.
Called to build the page's footer and after the body
Called to build the page's header and before the body
Clears the whole log (excluding headers and footers)
Clips the logging files (e.g.
Adds code to the log
Logs a critical error
Logs an info text
Adds a dataframe to the log
Embeds another VisualLog's content into this one
Logs an info text
Runs a piece of code and returns it's output
Adds a figure to the log
Returns a hashed filename for name to be store it with a fixed size on disk
Returns the temporary file path.
Adds a horizontal rule to the document
Adds a html section.
Logs an info text
Adds a hyperlink to the log
Adds a log text to the log
Logs a dictionary or a list.
Logs a list (just for convenience), forwards to log_dict.
Adds statistics about the VisualLog as table to the log
Logs a timestamp to the log
Adds a markdown section.
Adds a numpy matrix or vector to the log
Inserts a page break
Opens a matplotlib context to add a figure directly to the plot.
Reserves a unique name within the log, e.g.
Demo showing how to add a dataframe to your log :return:
Demo showing how to add tables and images to a log
Demo showing how to add matplotlib figures to your log
Adds a sub title to the log
Adds a subtest section to the log
Adds a subtitle to the log
Adds a subtitle to the log
Adds a text to the log
Adds a title to the log
Logs an info text
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
The maximum figure size in pixels
- _add_html(html_code)¶
The HTML code to add
- Parameters
html_code (
str) – The html code- Returns
True if txt logging is enabled
- _add_md(md_code, no_break=False)¶
The markdown code to add
- _add_txt(txt_code, console=True, md=False)¶
Adds text code to the txt / console log
- static _encode_html(text)¶
Escaped text to html compatible text
- static _html_linebreaks(text)¶
Replaces linebreaks through html linebreaks
- _log_advanced(text, level)¶
Detects tables and other objects in a log and pretty prints the tables while keeping the other log data intact
- Parameters
text – The log text
level (
LogLevel) – The log level
- add(content)¶
Adds the provided content to the log.
Supports a large variety of types. All supported types can also easily be embedded into tables and divs via the provided add_row and add_col methods.
- br()¶
Inserts a simple line break
- Return type
- Returns
The builder
- build()¶
Builds the whole page including header, footers and other sugar.
Only overwrite this if you really want to do a more complex customization.
- build_body()[source]¶
Is called when the body of the log shall be build or rebuild.
This is usually the function you want to override to implement your own page builder.
Called to build the page’s footer and after the body
- build_header()¶
Called to build the page’s header and before the body
- clear()¶
Clears the whole log (excluding headers and footers)
- clip_logs()¶
Clips the logging files (e.g. if they are limited in length)
- code(code)¶
Adds code to the log
- Parameters
code (
str) – The code to execute- Return type
- Returns
The builder
- critical(*args, **kwargs)¶
Logs a critical error
- Parameters
args – The elements to log. Will be separated by space.
kwargs – Keyword arguments
- Return type
- debug(*args, **kwargs)¶
Logs an info text
- Parameters
args – The elements to log. Will be separated by space.
kwargs – Keyword arguments
- Return type
- df(df, name=None, index=True)¶
Adds a dataframe to the log
- embed(log)¶
Embeds another VisualLog’s content into this one
- Parameters
log (
VisualLog) – The source log
- error(*args, **kwargs)¶
Logs an info text
- Parameters
args – The elements to log. Will be separated by space.
kwargs – Keyword arguments
- Return type
- evaluate(code, log_code=True)¶
Runs a piece of code and returns it’s output
- figure(figure, name=None, alt_text=None, _out_image_data=None)¶
Adds a figure to the log
- Parameters
name (str | None) – The figure’s name
figure (plt.Figure | plt.Axes | Figure | Plot) – The figure to log
alt_text (str | None) – An alternative text to display if the figure can not be displayed.
_out_image_data (io.IOBase | None) – Receives the image data if provided (for debugging and assertion purposes)
- static get_hashed_filename(name)¶
Returns a hashed filename for name to be store it with a fixed size on disk
- Parameters
name – The file’s name
- Returns
The hash name to be used as filename
- get_temp_path(relative=None)¶
Returns the temporary file path. The data will be wiped upon the call of finalize.
- hr()¶
Adds a horizontal rule to the document
- Return type
- Returns
The builder
- html(code)¶
Adds a html section. (only to targets supporting html)
- Parameters
code (
str) – The html code to parse- Return type
- info(*args, **kwargs)¶
Logs an info text
- Parameters
args – The elements to log. Will be separated by space.
kwargs – Keyword arguments
- Return type
- link(text, link)¶
Adds a hyperlink to the log
- Parameters
- Return type
- Returns
The builder
- log(*args, level=LogLevel.INFO, detect_objects=False, space=' ')¶
Adds a log text to the log
- Parameters
- Returns
- log_dict(dict_or_list)¶
Logs a dictionary or a list.
The data needs to be JSON compatible so can contain further nested diotionaries, lists, floats, booleans or integers but no more complex types.
- log_list(list_data)¶
Logs a list (just for convenience), forwards to log_dict.
The data needs to be JSON compatible so can contain further nested diotionaries, lists, floats, booleans or integers but no more complex types.
- Parameters
list_data (
list) – The list to log
- log_statistics()¶
Adds statistics about the VisualLog as table to the log
- log_timestamp(prefix='', postfix='')¶
Logs a timestamp to the log
- md(text, exclude_targets=None)¶
Adds a markdown section.
Requires the Markdown package to be installed.
- Parameters
- Return type
- Returns
The builder
- np(data, digits=2)¶
Adds a numpy matrix or vector to the log
- Parameters
data (
ndarray) – The data framedigits – The number of digits with which the numbers shall be formatted.
- page_break()¶
Inserts a page break
- Return type
- Returns
The builder
- pyplot()¶
Opens a matplotlib context to add a figure directly to the plot.
Also takes care off that no other thread is using matplotlib so you can safely plot using this function and matplotlib from multiple threads at once.
- Return type
- reserve_unique_name(name)¶
Reserves a unique name within the log, e.g. to store an object to a unique file.
- Parameters
name (
str) – The desired name- Returns
The effective name with which the data shall be stored
- sub(text, level=2)¶
Adds a sub title to the log
- Parameters
- Return type
- Returns
The builder
- sub_test(text)¶
Adds a subtest section to the log
- Parameters
text (
str) – The text to add to the log- Return type
- Returns
The builder
- sub_x3(text)¶
Adds a subtitle to the log
- Parameters
text (
str) – The text to add to the log- Return type
- Returns
The builder
- sub_x4(text)¶
Adds a subtitle to the log
- Parameters
text (
str) – The text to add to the log- Return type
- Returns
The builder
- text(text)¶
Adds a text to the log
- Parameters
text (
str) – The text to add to the log- Return type
- Returns
The builder
- title(text)¶
Adds a title to the log
- Parameters
text (
str) – The title’s text- Return type
- Returns
The builder
- warning(*args, **kwargs)¶
Logs an info text
- Parameters
args – The elements to log. Will be separated by space.
kwargs – Keyword arguments
- Return type
- forward_targets: dict[str, scistag.vislog.visual_log_builder.VisualLogBuilder]¶
List of logs to which all rendering commands shall be forwarded
- image¶
Helper object for adding images to the log
Can also be called directly to add a simple image to the log.
- table¶
Helper class for adding tables to the log.
Can also be called directly to add a simple table to the log.
- test¶
Helper class for adding regression tests to the log.