Skip to main content

A framework for research code

Project description

pyfra

The Python Research Framework.

Design Philosophy

Research code has some of the fastest shifting requirements of any type of code. It's nearly impossible to plan ahead of time the proper abstractions, because it is exceedingly likely that in the course of the project what you originally thought was your main focus suddenly no longer is. Further, research code (especially in ML) often involves big and complicated pipelines, typically involving many different machines, which are either run by hand or using shell scripts that are far more complicated than any shell script ever should be.

Therefore, the objective of pyfra is to make it as fast and low-friction as possible to write research code involving complex pipelines over many machines. This entails making it as easy as possible to implement a research idea in reality, at the cost of fine-grained control and the long-term maintainability of the system. In other words, pyfra expects that code will either be rapidly obsoleted by newer code, or rewritten using some other framework once it is no longer a research project and requirements have settled down.

Pyfra is in its very early stages of development. The interface may change rapidly and without warning.

Features:

  • Spin up an internal webserver complete with a permissions system using only a few lines of code
  • Extremely elegant shell integration—run commands on any server seamlessly. All the best parts of bash and python combined
  • Automated remote environment setup, so you never have to worry about provisioning machines by hand again
  • (WIP) Tools for painless functional programming in python
  • (Coming soon) High level API for experiment management/scheduling and resource provisioning
  • (Coming soon) Idempotent resumable data pipelines with no cognitive overhead

Example code

from pyfra import *

loc = Remote()
rem = Remote("user@example.com")
nas = Remote("user@example2.com")

@page("Run experiment", dropdowns={'server': ['local', 'remote']})
def run_experiment(server: str, config_file: str, some_numerical_value: int, some_checkbox: bool):
    r = loc if server == 'local' else rem

    env = r.env("neox", "git clone https://github.com/EleutherAI/gpt-neox")

    # rsync as a function can do local-local, local-remote, and remote-remote
    rsync(config_file, env.file("configs/my-config.yml"))
    rsync(nas.file('some_data_file'), env.file('data/whatever'))

    return env.sh('python main.py')

@page("Write example file and copy")
def example():
    rem.fwrite("testing.txt", "hello world")

    # tlocal files can be specified as just a string
    rsync(rem.file('testing123.txt'), 'test1.txt')
    rsync(rem.file('testing123.txt'), loc.file('test2.txt'))

    loc.sh('cat test1.txt')

    assert fread('test1.txt') == fread('test2.txt')

    # fread, fwrite, etc can take a `rem.file` instead of a string filename.
    # you can also use all *read and *write functions directly on the remote too.
    assert fread('test1.txt') == fread(rem.file('testing123.txt'))
    assert fread('test1.txt') == rem.file('testing123.txt').read()

    # ls as a function returns a list of files (with absolute paths) on the selected remote.
    # the returned value is displayed on the webpage.
    return '\n'.join(rem.ls('/'))

@page("List files in some directory")
def list_files(directory):
    return sh(f"ls -la {directory | quote}")


# start internal webserver
webserver()

Installation

pip3 install git+https://github.com/EleutherAI/pyfra/

The version of PyPI is not up to date, do not use it.

Webserver screenshots

image image

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

pyfra-0.1.2.tar.gz (501.0 kB view details)

Uploaded Source

Built Distribution

pyfra-0.1.2-py3-none-any.whl (520.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfra-0.1.2.tar.gz.

File metadata

  • Download URL: pyfra-0.1.2.tar.gz
  • Upload date:
  • Size: 501.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for pyfra-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6a65b67ff561720b0896e2dc15de82fa3e6fc0b0b3db2356b99e8946331473c7
MD5 df8e6ffc3453a453230a31e2b862381d
BLAKE2b-256 b65403e32c8fc5d0ecea55914c8967d371dd9982176323f59a091ac52ff8d9f7

See more details on using hashes here.

File details

Details for the file pyfra-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyfra-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 520.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for pyfra-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 160ddffdd6751a686a7b21ddb16d6d38dd1a895a28be99a7f95a8d7675f88625
MD5 a7dc823e8beef0961f370d8739267e4d
BLAKE2b-256 5f4041ee28ee64bf33762fb53cd723452d3737863b0400559c6b8c776568153a

See more details on using hashes here.

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