Overivew

The novem python library is designed with convenience in mind and to easily integrate with existing data processing workflows.

Overview

The novem python api provides utility and convenience functions for using the novem api from python.

The primary use case is creating charts combined with pandas data frames, but most relevant novem functionality is exposed through the api.

This document explains the overall design of the library and how to use it, for examples of specific use cases please see the relevant chart, doc, grid, e-mail and view sections.

The libary offers 5 main modules

  • plot - for creating charts and other plot like objects (see CHARTS documentation)
  • doc - novem documents (see Document documentation)
  • grid - novem grids (see GRID documentation)
  • view - novem views (see VIEW documentation)
  • mail - novem mails (see MAIL documentation)

Installation

The novem python library requires python 3.8.5 or higher and is avaiable from pypi, in additon the source code can be found on our github page.

pip install novem

Once the novem library is installed you can run python -m novem --init to generate a new token and create the default config file. This token will be named novem-python-$hostname-$nounce unless otherwise specified by the --token_name switch.

For a list of all availbale options python -m novem please check out the appendix for the novem cli.

username@computer:~/$ python -m novem --init
 • novem.no username: <your_username>
 • novem.no password: <your_password>
 ✓ authenticated
 ✓ token created
 ✓ new token "novem-python-computer-rj8chk2j" saved to ~/.config/novem/novem.conf
username@computer:~/$ _

An alternative option is logging into app.novem.no, generate a token and save it to $CONFIG_DIR/novem/novem.conf manually.

Common

Sharing

Files

Visualisations

Plot

The plot module exposes a novem plot class that maps to the /v1/vis/plots/ api end-point.

The class takes one positional parameter, the plot name, and several optional named parameters. All the named parameters in the constructor are also available as properties.

"""
Below we show the various ways you can set the options on your novem plot
"""

from novem import Plot

# everything in the constructor
barchart = Plot(<name>, \
  type='bar', \
  title='barchart tiitle', \
  caption = 'caption'
)

# property approach
barchart = Plot('plot_name')
barchart.type = 'bar'
barchart.title = 'barchart title'
barchart.caption = 'caption'

Mail

The mail module exposes a novem plot class that maps to the /v1/vis/mails/ api end-point.

The mail allows two primary way of constructing a plot. Either by supplying a novem markdown document as a content file or constructing the e-mail programatically.

The markdown appoarch

from novem import Mail

mail = Mail('name')                     # create mail object

mail.to = "user@example.com"            # add recipient

with open('content.txt', 'r') as f:
    mail(f)                             # add content to mail

mail.send()

The pythonic appoarch

from novem import Mail,S 
from novem.mail.sections import \
  PreviewSummarySection,
  TextSection

mail = Mail('name')                     # create mail object

mail.to = "user@example.com"            # add recipient

mail.subject = "Test e-mail"

mail.add_section(PreviewSummarySection("""
Preview summary that is not visible in the main
body of the mail
"""))

mail.add_sectoin(TextSection("""
Markdown text for text section
""", title="Section title"
))



mail.send()

Preview version of the above code.

EMBED PREVIEW HERE