Skip to main content

sylte

Testing and linting codecov GitHub release (latest by date including pre-releases) PyPI

Sylte provides a decorator that stores function arguments as a pickle file in a central location, and functions for retrieving those arguments later on, so that the function can be re-invoked with the same args. Useful when writing or debugging a function that exists somewhere near the end of a long-running pipeline.

Installation

Using poetry:

poetry add sylte

Using pipenv:

pipenv install sylte

Using pip:

pip install sylte

Usage

Let's say we have a function transform that we want to debug or modify. We will have to call it several times to see how it behaves with real data. It's normally called as part of a long-running pipeline, and we don't want to have to wait for this pipeline every time. We could write a unit-test, but perhaps we aren't yet sure how the output will look, and perhaps the input-data is complex and time-consuming to recreate in a test, and we'd prefer to do that when the function is finalized, to avoid having to repeatedly modify the test as the function is modified.

Enter sylte. By applying the @sylt decorator to the function and running the pipeline once, the args are recorded, and can be retrieved later.

from sylte import sylt

@sylt
def transform(this_huge_df, this_other_huge_df, this_object_with_lots_of_attributes):
    ...

The arg set will be stored in a pickle file in the default cache location for the os. The location can be seen by running from sylte import CACHE_DIR; print(CACHE_DIR). To use a different location than the default, specify the location with the environment variable SYLTE_CACHE_DIR.

The file name will have the format <file name>-<function name>-<timestamp>.pickle.

The function latest will retrieve an unsylt the latest arg set, returning a tuple with args and kwargs.

>>> from sylte import latest
...
>>> args, kwargs = latest()
>>> transform(*args, **kwargs)

show returns a list of all sylted arg sets:

>>> from sylte import show
...
>>> show()
['demo-transform-2022-01-14-15-08-59',
 'demo-transform-2022-01-14-15-12-33',]

unsylt unsylts and returns the arg set with the specified name as output by show, i.e. the filename with the extension omitted:

>>> from sylte import unsylt
...
>>> args, kwargs = unsylt('demo-add-2022-01-14-15-08-59')
>>> transform(*args, **kwargs)

clear deletes all previously sylted arg sets:

>>> from sylte import clear, show
...
>>> clear()
>>> show()
[]

Metadata

Release files for sylte 0.0.3

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

Source distribution (sdist)

Source distribution for sylte 0.0.3
File Size Uploaded
sylte-0.0.3.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sylte 0.0.3
File Interpreter ABI Platform
sylte-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / sylte-0.0.3.tar.gz

Download URL sylte-0.0.3.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cddef9f73c3383f71aa89754452b43781c2d92844c045964ea3b2bb14325e2a4
BLAKE2b-256 checksum
How to use checksums
8eb8e60821826fe75480397bdb9be771df69a5eb6be2fbf1748e50d7d5709bdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-1027-azure

Release files / sylte-0.0.3-py3-none-any.whl

Download URL sylte-0.0.3-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb0c5ebcda3aa105d7ea6e51c7c598b473aba227d779a80a3322b1eb64020e26
BLAKE2b-256 checksum
How to use checksums
f412203f8abcfe5f57ca4822179139195ee2b58befca9a831358e510498e502e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-1027-azure

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

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