GithubHelp home page GithubHelp logo

pyfmq's Introduction

FMQ (Client-Side)

What is FMQ?

FMQ is a service that allows simulations of FMUs to be queued up and run "in the cloud". The complexity of queueing and load-balancing simulation jobs is completely handled behind the scenes.

What is pyfmq?

The pyfmq is a small Python package that provides a Python "front-end" to the FMQ web services API. It allows normal Python data to be passed in and returns a "promise" for the simulation results that can retrieve simulation results and convert them into normal Python data.

Installation

The really easy way to install this package (for now) is to just install the latest version on GitHub. You can do this directly with pip using the following command:

% pip install git+git://github.com/xogeny/pyfmq.git

Usage

The following example assumes that the current directory contains an FMU whose file name is bouncingBall.fmu.

import pyfmq

pyfmq.setKeys("<your user id>", "<your password>")  

# This registers the FMU file with the FMQ service
fmu = pyfmq.register("./bouncingBall.fmu")

results = []
for i in range(1,10):
  promise = pyfmq.sim(fmu, sim_args={"final_time": 10.0},
                      params={"e": 0.5+0.02*i},
                      signals=["h", "v"])
  results.append(promise)

for r in results:
  print r.get()

The params keyword argument to the sim method includes a dictionary of parameter names (as keys) which map to parameter values. The signals keyword argument includes the names of all signals whose trajectory you would like to retrieve.

Note: the current implementation requires you to specify all results you are interested in a priori. You cannot later request additional signals. The hope is that this limitation will be addressed in a future release.

Promises

The careful reader will note that each simulation does not return a simulation result. Instead, it returns a "promise" for a simulation result. The results of the simulation can be extracted using the get method on the promise object. But note, this will cause the Python thread to block (wait for a result).

The example above shows a useful pattern where all jobs are submitted first and then the results are queried. This allows all the simulation jobs to run in parallel and gives the biggest potential performance.

A good "promise" implementation (and this isn't one :-), would allow you to compose other computations together into other promise objects (ala Akka in Scala). I haven't gone to that extent with this library (yet).

pyfmq's People

Contributors

mtiller avatar

Watchers

 avatar  avatar

Forkers

lebg2 bufanping

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.