Skip to main content

Saturn allows to rerun python scripts skipping some places that were defined in previous runs.

Project description

saturn

A Python library that allows to rerun a script multiple times without stopping the process and keeping the scope (like it is done in Jupyter Notebook in code sections). The goal is to keep in RAM the datasets that are expensive to load in each run.

Installation

pip install saturn-python

Basic example

# example.py

import saturn

@saturn.main
def main(scope):
    if not saturn.defined('scope.a', scope):  # OR if 'a' not in scope:
        scope.a = 42
    scope.a += 1
    print(scope.a)

Run:

$ saturn
Welcome to Saturn terminal where you can reruns your Python module keeping its scope in RAM. Version 1.0.
S>>> run example
43
S>>> run example
44
S>>> print(scope)
{'a': 44}
S>>> exit
$

Work with sections

# example.py

import saturn

@saturn.main
def main(scope):
    print('main')

    if saturn.section('a'):
        print('section a')

    if saturn.section('b'):
        print('section b')

Run:

$ saturn
Welcome to Saturn terminal where you can reruns your Python module keeping its scope in RAM. Version 1.0.
S>>> run example
main
section a
section b
S>>> run example a
main
section a
S>>> run example c
main
S>>> exit
$

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saturn-python-1.4.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page