Giter Club home page Giter Club logo

station's Introduction

station

Latest Version Build Status

context manager for computational engines

Simple context manager in Python for targeting different computational engines. Makes it easy to write code that targets different engines depending on the setting (e.g. during benchmarking or unit testing). Currently supports spark and local modes, support for dask and distributed coming soon.

install

pip install station

initializing

If you have an existing SparkContext you can use it

station.start(sc)

or create a new spark context with options

station.start(spark=True, opts={'master': 'local'})

or use the default local environment

station.start()

methods

Once created you can get the context object provided by the backend

station.engine()
>> None | <pyspark.context.SparkContext>

get the current mode with

station.mode()
>> 'local' | 'spark'

and stop with

station.stop()

more

You can use in a with for tight context control e.g. for unit testing or benchmarking

with station.start(spark=True):
  # do spark stuff
  
with station.start():
  # do local stuff

with station.start(spark=True):
  # do more spark stuff

any engines created inside a with will be shut down upon exit, so results requiring the engine should be collected locally prior to exiting the context.

thanks

Credit to Matt Rocklin (@mrocklin) for providing nice examples of custom context managers.

station's People

Contributors

freeman-lab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

station's Issues

Supress output

Currently there is rather excessive output about processes starting and stopping, especially for Spark. This should be suppressed by default, but some basic logging should be available as an option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.