Skip to main content

Two Sigma Memento Core

Project description

Two Sigma Memento

Memento is a framework and lightweight set of standards that encourage discipline in the way data is incrementally transformed through code. The goal of Memento is to ensure that data is reproducible and that accurate provenance is maintained in metadata. The Memento Framework does not pin itself to a specific programming language, back-end storage technology or compute framework. Rather, it focuses on a technique for generating and accessing data that preserves accurate metadata throughout.

Memento can be extended with plugins which customize where memoized data is stored and how distributed compute is executed.

This codebase hosts several independent products, which are all synchronized in their version. This product is the core memento framework, which is usable by itself or in combination with various plugins.

The core framework includes three storage backends, filesystem (the default), memory, and null (never store). The core framework also includes two runner backends, local (in-process), and null (never run). To use memento for distributed computation or shared storage, other plugins can be used.

Installation

If you just want to use Memento, you can easily install it from the PyPI package repository, as follows:

$ pip install twosigma-memento 

Memento is tested with Python 3.8 and above, and should work on Linux, Windows and Mac.

Development Quick Start

The following instructions should get you from a git clone to a working build of Memento. These instructions are tested on Linux and Windows but should work in other environments as well.

Prerequisites

You need a Python environment with hatch installed:

$ pip install hatch

Build Memento

To build, simply run the following command. You will get a dist directory with a pip package.

$ hatch build

Test Memento

Memento has an extensive suite of unit tests. To run the tests to ensure the build is working, run the following.

$ hatch run cov

There are some tests that will not run by default because they require a lot of RAM and are slow to run. To include those tests, include the --runslow parameter.

Run Memento

If you have an existing environment, you can install memento with:

$ pip install -e .

If you prefer to start an isolated environment with a barebones Python with just Memento installed:

$ hatch shell
$ python

Quick example

Try a simple cached function definition in a python repl:

$ hatch run python
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32                                                                                                                                                                                                               
Type "help", "copyright", "credits" or "license" for more information.
>>> from twosigma.memento import memento_function
>>> @memento_function
... def f(x):
...     print("eval f")
...     return x + 1
...
>>> f(1)
eval f
2
>>> # The second time we run it should not print "eval f" because it reads the cached result
>>> f(1)
2
>>>

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

twosigma_memento-0.28.1.tar.gz (34.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twosigma_memento-0.28.1-py3-none-any.whl (104.7 kB view details)

Uploaded Python 3

File details

Details for the file twosigma_memento-0.28.1.tar.gz.

File metadata

  • Download URL: twosigma_memento-0.28.1.tar.gz
  • Upload date:
  • Size: 34.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for twosigma_memento-0.28.1.tar.gz
Algorithm Hash digest
SHA256 e0fadaee3ca9329c4a34a97e1cb4c9090ffff192f626f082da683b27adaf0323
MD5 354a50ddb56f5a483b02842aecb7ca03
BLAKE2b-256 cefc5e78c3e7fdf0751f07a00f59691fd7c966998cb3d6213c7fa610eb7b3a05

See more details on using hashes here.

File details

Details for the file twosigma_memento-0.28.1-py3-none-any.whl.

File metadata

File hashes

Hashes for twosigma_memento-0.28.1-py3-none-any.whl
Algorithm Hash digest
SHA256 510a46b90aa25dad955f5d5efcefe3b78cef07025655a59119dd0fab70673b9f
MD5 6bbfefe734262c679b3abe1e044687d6
BLAKE2b-256 db30f529ac32d1d201ace794205222baea65868cdcf7df2491b1311941429a80

See more details on using hashes here.

Supported by

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