Coder Social home page Coder Social logo

pydash's Introduction

pydash

Python bindings for DASH by exposing DASH datatypes to Python.

Synopsis

$ git clone https://github.com/dash-project/pydash.git ~/tmp/pydash
$ pip install ~/tmp/pydash
$ python
>>> import pydash
>>> pydash.initialize(0, '')
>>> # See help(pydash) for API documentation
>>> pydash.finalize()

Basic Examples

Hello World

To run a pydash application on distributed nodes (via MPI), just spawn the interpreter via mpiexec/mpirun as usual:

# File: initialize_test.py
import pydash

pydash.initialize(0, "")

print "My unit id: {}".format(pydash.myid().id())

pydash.finalize()
$ mpirun -n 4 python initialize_test.py
My unit id: 2
My unit id: 1
My unit id: 3
My unit id: 0

Array Read/Write

# File: array_test.py
import pydash

pydash.initialize(0, "")

myid   = pydash.myid().id()
nunits = pydash.nunits()
# Collectively instantiate array:
array  = pydash.ArrayInt(3 * nunits)
# Initialize array:
array[myid * 3 + 0] = 100 * (1 + myid) + 0
array[myid * 3 + 1] = 100 * (1 + myid) + 1
array[myid * 3 + 2] = 100 * (1 + myid) + 2
# Wait for all units:
pydash.barrier()
# Read array elements from remote unit:
fromid = nunits - myid - 1
# Print remote values:
print("Unit {0:2} read array[{1:3} ..{2:3}]:"
        .format(myid, fromid * 3, fromid * 3 + 2),
      "  u:", repr(array.unit_at(fromid * 3 + 0)).rjust(2), repr(array[fromid * 3 + 0]).rjust(5),
      "  u:", repr(array.unit_at(fromid * 3 + 1)).rjust(2), repr(array[fromid * 3 + 1]).rjust(5),
      "  u:", repr(array.unit_at(fromid * 3 + 2)).rjust(2), repr(array[fromid * 3 + 2]).rjust(5))

pydash.finalize()
$ mpirun -n 5 python array_test.py
Unit  0 read array[ 12 .. 14]:   u:  4   500   u:  4   501   u:  4   502
Unit  3 read array[  3 ..  5]:   u:  1   200   u:  1   201   u:  1   202
Unit  2 read array[  6 ..  8]:   u:  2   300   u:  2   301   u:  2   302
Unit  4 read array[  0 ..  2]:   u:  0   100   u:  0   101   u:  0   102
Unit  1 read array[  9 .. 11]:   u:  3   400   u:  3   401   u:  3   402

Build and Install

  • Install DASH using CMake version 3.0 or newer:

    (~) $ git clone https://github.com/dash-project/dash.git -b development ./dash
    (~) $ cd dash
    (dash) $ ./build.sh && (cd build ; make doc ; make install)
  • In PyDASH, run build.sh

pybind11

  • Pull from official pybind11 repository:

    git clone https://github.com/pybind/pybind11
    
  • Build and install, installation path of pybind11 must be provided when building pydash applications via CMake option PYBIND11_BASE

Running Tests

  • Install py.test:

    $ pip install pytest --user

Further References

pybind11 User Guides

Extending Python with C or C++ using Python API

See this reference as a starting point:

Links

pydash's People

Contributors

fuchsto avatar josefschaeffer avatar

Watchers

 avatar

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.