Skip to main content

REProducible Experimental environment.

Project description

fret

Build Status Coverage Status

Framework for Reproducible ExperimenTs

Installation

From pip:

pip install fret

From source: clone the repository and then run: python setup.py install.

Tutorial

Basic Usage

Create a file named app.py with content:

import fret

@fret.configurable
class Model:
    def __init__(self, x=3, y=4):
        ...

@fret.command
def run(ws):
    model = ws.build()
    print(model)

Then under the same directory, you can run:

$ fret config Model
$ fret run
Model(x=3, y=4)
$ fret config Model -x 5 -y 10
$ fret run
Model(x=5, y=10)

Using Workspace

You can specify different configuration in different workspace:

$ fret -w ws/model1 config Model
$ fret -w ws/model2 config Model -x 5 -y 10
$ fret -w ws/model1 run
Model(x=3, y=4)
$ fret -w ws/model2 run
Model(x=5, y=10)

You can ommit -w <path> if you are currently under a workspace:

$ cd ws/model2
$ fret run
Model(x=5, y=10)

An Advanced Workflow

In app.py:

import time
import fret

@fret.configurable
@fret.stateful(['value'])
class Model:
    def __init__(self):
        self.value = 0

@fret.command
def resumable(ws):
    model = ws.build()
    with ws.run('exp-1') as run:
        run.register(model)
        cnt = run.acc()
        for e in fret.nonbreak(run.range(5)):
            # with `nonbreak`, the program always finish this loop before exit
            model.value += e
            time.sleep(0.2)
            cnt += 1
            print('current epoch: %d, sum: %d, cnt: %d' %
                  (e, model.value, cnt))

Then you can stop and restart this program anytime, with consistent results:

$ fret resumable
current epoch: 0, sum: 0, cnt: 1
current epoch: 1, sum: 1, cnt: 2
^CW SIGINT received. Delaying KeyboardInterrupt.
current epoch: 2, sum: 3, cnt: 3
Traceback (most recent call last):
    ...
KeyboardInterrupt
W cancelled by user
$ fret resumable
current epoch: 3, sum: 6, cnt: 4
current epoch: 4, sum: 10, cnt: 5

Submodule

@fret.configurable
class A:
    def __init__(self, foo='bar'):
        ...

@fret.configurable(submodules=['a'])
class B:
    def __init__(self, a, bar=3):
        ...

>>> a = A()
>>> b = B(a, bar=4)
>>> b
B(A(foo='bar'), bar=4)

Inheritance

@fret.configurable
class A:
    def __init__(self, foo='bar', sth=3):
        ...

@fret.configurable
class B(A):
    def __init__(self, bar=3, **others):
        super().__init__(**others)
        ...

>>> b = B(foo=0, bar=0)
>>> b
B(foo=0, bar=0, sth=3)

Internals

>>> config = fret.Configuration({'foo': 'bar'})
>>> config
foo='bar'

TODO

  • fret.Configuration: high-level class for configuration
  • fret.Workspace: module build/save/load (by tag or by path)
  • ws.run() context manager, run.value(), run.acc(), run.range(), run.register()
  • @fret.configurable: parameter checking
  • fret.App, global app object
  • CLI: entry point logic, testing, tagged workspace
  • Parameter check
  • Java/GNU style command line args, shorthands, better logic for boolean default value
  • Global configuration file: fret.toml
  • Documents and examples
  • fret new command with interactive CLI
  • Other fret commands like show log, check module, etc.

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

fret-0.2.0b1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

fret-0.2.0b1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file fret-0.2.0b1.tar.gz.

File metadata

  • Download URL: fret-0.2.0b1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for fret-0.2.0b1.tar.gz
Algorithm Hash digest
SHA256 297d4fe971f5015cb062dfd8e10ddf92956d34f1c4b08b1d10b980a5944f80ba
MD5 501ab4295244f65efeb1e598a974936d
BLAKE2b-256 f548cfec3f5f34db820fa76717bd6152a71ffc76d46d380659557ffa84273536

See more details on using hashes here.

File details

Details for the file fret-0.2.0b1-py3-none-any.whl.

File metadata

  • Download URL: fret-0.2.0b1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for fret-0.2.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 a96aa5ab52ccaf8dc928ec91f5b2d28b2163b5d59b1787675e05c982205c80b7
MD5 bf76dea68febad74f2818d65af48be0e
BLAKE2b-256 ed0f47ceced0c9c7d52248d7fe6af8c09f1d2df30896b0a29ca15838e150ed93

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