Skip to main content

:rocket: NB Workflows

nb-workflows readthedocs PyPI - Format PyPI - Status

codecov

:books: Description

NB Workflows empowers different data roles to put notebooks into production, simplifying the time required to do so. It enables people to go from a data exploration instance to an entirely project deployed in production, using the same notebooks files made by a data scientist, analyst or whatever role working with data in an iterative way.

NB Workflows is a library and a service that allows you to run parametrized notebooks in a distributed way.

A Notebook could be launched remotly on demand, or could be scheduled by intervals or using cron syntax.

Internally it uses Sanic as web server, papermill as notebook executor, an RQ for task distributions and coordination.

:tada: Demo :tada:

:floppy_disk: Example project

:telescope: Philosophy

NB Workflows it insn't a complete MLOps solution and it will never be. We try hard to simply and expose the right APIs to the user for the part of scheduling notebooks with reproducibility in mind.

We also try to give the user the same freedom that lego tiles can give, but we are opinated in some aspects: we understand the process of writing code for data science or/and data analytics, as a engineer problem to be solved

With this point of view, then:

  1. Git is neccesary :wink:
  2. Docker is necessary for environment reproducibility.
  3. Although you can push not versioned code, versioning is almost enforced, and is always a good practice in software development

The idea comes from a Netflix post which suggest using notebooks like an interface or a some kind of DSL to orchestrate different workloads like Spark and so on. But it also could be used to run entire process: like training a model, crawlings sites, performing etls, and so on.

The benefits of this approach is that notebooks runned could be stored and inspected for good or for bad. If something fails, is easy to run in a classical way: cell by cell.

The last point to clarify and it could challange the common sense or the way that we are used to use Jupyter's Notebooks, is that each notebook is more like a function definition with inputs and outputs, so a notebook potentially could be used for different purposes, hence the name of workflow, and indeed this idea is common in the data space. Then a workflow will be a notebook with params defined to be used anytime that a user wants, altering or not the parameters sent.

:nut_and_bolt: Features

  • Define a notebook like a function, and execute it on demand or scheduled it
  • Automatic Dockerfile generation. A project should share a unique environment but could use different versions of the same environment
  • Execution History, Notifications to Slack or Discord.

Installation

Server

Docker-compose

The project provides a docker-compose.yaml file as en example.

:construction: Note :construction:

Because NB Workflows will spawn docker instance for each workload, the installation inside docker containers could be tricky. The most difficult part is the configuration of the worker that needs access to the docker socket.

A Dockerfile is provided for customization of uid and guid witch should match with the local environment. A second alternative is expose the docker daemon through HTTP, if that is the case a DOCKER_HOST env could be used, see docker client sdk

git clone https://github.com/nuxion/nb_workflows
cd nb_workflows

The next step is intializing the database and creating a user (please review the script first):

docker-compose postgres up -d 
./scripts/initdb_docker.sh

Now you can start everything else:

docker-compose up -d 

Without docker

pip install nb-workflows[server]==0.6.0

first terminal:

export NB_SERVER=True
nb manager db upgrade
nb manager users create
nb web --apps workflows,history,projects,events,runtimes

second terminal:

nb rqworker -w 1 -q control,mch.default

Before all that, redis postgresql and the nginx in webdav mode should be configurated

Client

Client:

pip install nb-workflows==0.6.0
nb startporject .

:earth_americas: Roadmap

See Roadmap draft

:post_office: Architecture

nb_workflows architecture

:bookmark_tabs: References & inspirations

Release files for nb-workflows 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nb-workflows 0.7.0
File Size Uploaded
nb_workflows-0.7.0.tar.gz 87.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nb-workflows 0.7.0
File Interpreter ABI Platform
nb_workflows-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 212.4 kB

Release files / nb_workflows-0.7.0.tar.gz

Download URL nb_workflows-0.7.0.tar.gz
Size 87.6 kB
Tags Source
SHA-256 checksum
How to use checksums
44e944121a07a7cf1795b3f432c400636cf9899ceb4685d1ec799de3fc35467f
BLAKE2b-256 checksum
How to use checksums
9d6f98315e3938c536a8a6b6f556bb644c2ae20ddcd63bed6185829fce19a5bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.10.27_1

Release files / nb_workflows-0.7.0-py3-none-any.whl

Download URL nb_workflows-0.7.0-py3-none-any.whl
Size 124.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f5f1121d93703fffa71532516d88a580d310498488104873cb5a9977145db8b
BLAKE2b-256 checksum
How to use checksums
d50c40466d1aa90ca66d5945010530adf04fa848cceb720694f8e3a4ef815b32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.10.27_1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page