Package openmdao.gui

This package contains a graphical user interface for the openmdao framework.

class openmdao.gui.consoleserver.ConsoleServer(name='', host='', publish_updates=True)[source]

Bases: cmd.Cmd

Object which knows how to load an OpenMDAO project and provides a command line interface and methods to interact with that project.

add_file(*args, **kargs)[source]
add_object(*args, **kargs)[source]
add_subscriber(pathname, publish)[source]

Publish the specified topic.


Cleanup various resources.

commit_project(*args, **kargs)[source]

Called on an input line when the command prefix is not recognized. In this case we execute the line as Python code.

delete_file(*args, **kargs)[source]

Print remembered trace from last exception.

ensure_dir(*args, **kargs)[source]
execfile(*args, **kargs)[source]

Returns True if the given file (assumed to be a file in the project) has classes that have been instantiated in the current process or if the file is a macro file. Note that this doesn’t keep track of removes/deletions, so if an instance was created earlier and then deleted, it will still be reported.


Get the attributes of the specified object.


Serve a list of events that are available to a driver.


Get hierarchical dictionary of openmdao objects.


Get the connectivity data for the assembly with the given pathname


Get current project name.


Get the structure of the specified assembly or of the global namespace if no pathname is specified; consists of the list of components and the connections between them (i.e., the dataflow).


Get contents of a file. Returns a tuple of (file contents, mimetype, encoding). Tuple values will be None if file was not found.


Get a nested dictionary of files.


Return this server’s _hist.

get_object(pathname, report=True)[source]

Get the container with the specified pathname. Returns the container and the name of the root object.


Get the inputs and outputs of the assembly’s child components and indicate for each whether or not it is a passthrough variable.


Return this server’s pid.


Return the current project.


Return this server’s _recorded_cmds.


Get constructor argument signature for classname.


Get a dictionary of types available for creation.


Get the value of the object with the given pathname.


Get the workflow for the specified driver or assembly. If no driver or assembly is specified, get the workflows for all of the top-level assemblies.

install_addon(url, distribution)[source]
load_project(*args, **kwargs)[source]
onecmd(*args, **kargs)[source]

Have to override this because base class version strips the lines, making multi-line Python commands impossible.


This method is called after the line has been input but before it has been interpreted. If you want to modify the input line before execution (for example, variable substitution), do it here.


Publish the current component tree and subscribed components.

put_object(pathname, classname, args=None)[source]

Create or replace object with the given pathname with a new object of the specified type.

rename_file(*args, **kargs)[source]
replace_object(*args, **kargs)[source]
revert_project(*args, **kargs)[source]
run(*args, **kargs)[source]
send_pub_msg(msg, topic)[source]

Publish the given message with the given topic.


Set current project name.

write_file(*args, **kargs)[source]

Decorator for methods that update the project (or might do so) via adding, removing or updating files in the project. This includes the issuing of commands that end up in the default macro file. (TODO: should be able to due this directly through the FileManager)

Updates the timestamp of the project _settings.cfg file so that it can be used to determine when the project was ‘last saved’.


Decorator for methods that modify the session state (or might do so). Performs maintenance on root level containers/assemblies and publishes the potentially updated components.

class openmdao.gui.filemanager.FileManager(name, path, publish_updates=False)[source]

Bases: object

Object that keeps track of a collection of files (i.e., a directory) and optionally publishes an update when the collection is modified.

add_file(filename, contents)[source]

Add file to working directory. If it’s a zip file, unzip it.


Stop observer and cleanup the file directory.


Delete file in working directory. Returns False if file was not found; otherwise, returns True.


Create directory in working directory. (Does nothing if directory already exists.)


Get contents of file in working directory. Returns None if file was not found.


Get a nested dictionary of files in the working directory.


Publish the current file collection.

rename_file(oldpath, newname)[source]

Rename last component of oldpath to newname.

write_file(filename, contents)[source]

Write contents to file in working directory.

class openmdao.gui.filemanager.FilesPublisher(files)[source]


Publishes file collection when ANY file system event occurs.


Just publish the updated file collection.

class openmdao.gui.handlers.ExitHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Shut it down; try to close the browser window.

class openmdao.gui.handlers.LoginHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Currently we support a single user, the current user. This hook is for potential future development using Credentials.

class openmdao.gui.handlers.LogoutHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Lets users log out of the application simply by deleting the nickname cookie.

class openmdao.gui.handlers.PluginDocsHandler(application, request, **kwargs)[source]

Bases: tornado.web.StaticFileHandler

Retrieve docs for a plugin.

get(path, include_body=True)[source]
regex = <_sre.SRE_Pattern object at 0x10a829d80>
class openmdao.gui.handlers.ReqHandler(application, request, **kwargs)[source]

Bases: tornado.web.RequestHandler

Override the get_current_user() method in request handlers to determine the current user based on the value of a cookie.


class openmdao.gui.handlers_projectdb.DeleteHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Delete a project.

post(*args, **kwargs)[source]
class openmdao.gui.handlers_projectdb.DetailHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Get/set project details.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_projectdb.DownloadHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Download a copy of the project.

get(*args, **kwargs)[source]

Browser download of a project file

class openmdao.gui.handlers_projectdb.ImportHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Get/set project details.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_projectdb.IndexHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

get project list

get(*args, **kwargs)[source]
class openmdao.gui.handlers_projectdb.NewHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Add a project to the project database. This extracts the project file into a directory under the project’s directory of users.

post(*args, **kwargs)[source]

class openmdao.gui.handlers_workspace.AddOnsHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Add-on installation utility. (TODO: Wrap the OpenMDAO plugin functions to work through here....)

GET: Render the addon installation utility template.

POST: Install the POSTed addon.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
addons_url = ''
class openmdao.gui.handlers_workspace.CommandHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

POST: Execute a command and return the console-like response; required arguments are:

command: Command to execute

post(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.EditorHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

code editor utility

GET: Render the code editor; arguments are:

filename: Full pathname of file to edit (optional).
get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.FileHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get the contents of file filename.

PUT: Write contents to file filename.

DELETE: Delete file filename.

POST: Rename file filename if rename argument is provided;

otherwise execute file filename. Arguments are:

rename: New name for file filename (optional).

delete(*args, **kwargs)[source]
get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
put(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.FilesHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get heirarchical list of files in the current project.

DELETE: Delete files; arguments are:

filepaths - full pathnames of files to delete (required)

returns ‘True’ if all files were successfully deleted

delete(*args, **kwargs)[source]
get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.GeometryHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

geometry viewer utility

GET: Render the geometry viewer; arguments are:

path: Full path name of geometry object or file.
get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.ImagesHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

image viewer utility

GET: Render the image viewer.

get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.ObjectHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get the attributes of object pathname;
attr is optional and can specify one of the following:






PUT: Create or replace object pathname; arguments are:

type: The type of the new object (required)

args: Arguments required to create the new object (optional).

POST: Execute object pathname

DELETE: Delete object pathname

delete(*args, **kwargs)[source]
get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
put(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.ObjectsHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get heirarchical list of objects in the current project. (NOTE: currently only lists ‘Component’ objects...)

get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.ProjectHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Start up an empty workspace and prepare to load a project.
(Loading a project is a two-step process. The first step is when the server is initialized and the workspace is loaded. After the workspace is loaded and websockets are connected, the next step should be a POST to project/load that will actually load the project into the server.)

POST: Perform the specified action on the current project; arguments are:

action: One of the following (required)

load: Load project into the current server;

if no project path is given, get from session cookie.

additional args: projpath (optional)

commit: Commit the current project.

additional args: comment (optional)

revert: Revert back to the most recent commit of the project.

additional args: commit_id (optional)

close: Close the current project

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.ReqHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers.ReqHandler

Render the base template.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.StreamHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get the url of the websocket server for stream stream_name.

get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.SubscriptionHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get a subscription to topic.
(Messages will be published via the pub websocket.)

DELETE: Remove a subscription to topic.

delete(*args, **kwargs)[source]
get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.TypeHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get attributes of type typename; attr is required and must be one of:

signature: Arguments required to create an instance of typename

get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.TypesHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get the list of available types.

get(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.UploadHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

file upload utility

GET: Render the upload form.

POST: Add the POSTed files to the current project.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.VariableHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: Get the value of variable pathname.

PUT: Set the value of variable pathname.

get(*args, **kwargs)[source]
post(*args, **kwargs)[source]
class openmdao.gui.handlers_workspace.WorkspaceHandler(application, request, **kwargs)[source]

Bases: openmdao.gui.handlers_workspace.ReqHandler

GET: render the workspace.

get(*args, **kwargs)[source]


This graphical user interface for OpenMDAO is implemented as a web application.

Running this file will start a tornado web server on a local port and open a browser on that port. An up-to-date version of Chrome or Firefox with support for WebSockets is required.

class openmdao.gui.omg.App(secret=None, external=False)[source]

Bases: tornado.web.Application

Openmdao web application. Extends tornado web app with URL mappings, settings and server manager.



class openmdao.gui.omg.AppServer(options)[source]

Bases: object

Openmdao web application server. Wraps tornado web app, runs http server, and opens browser.

static get_argument_parser()[source]

Create a parser for command-line arguments.


Start server listening on port, launch browser if requested, and start the ioloop.


Shortcut to AppServer argument parser.


Return user’s GUI directory.


Process command line arguments and run., options=None, args=None)[source]

Launch the GUI with specified options.

class openmdao.gui.outstream.OutStream(pub_socket, name)[source]

Bases: object

A file-like object that publishes the stream to a 0MQ PUB socket. (Borrowed from IPython, but stripped down a bit...)

class openmdao.gui.outstream.OutStreamRedirector(name, addr, filename='sys.stdout')[source]

Bases: multiprocessing.process.Process

Listen for output on the given port and dump it to a file.


class openmdao.gui.projdirfactory.ProjDirFactory(watchdir, use_observer=True, observer=None)[source]

Bases: openmdao.main.factory.Factory

A Factory that watches a Project directory and dynamically keeps the set of available types up-to-date as project files change.


If this factory is removed from the FactoryManager during execution, this function will stop the watchdog observer thread.

create(typ, version=None, server=None, res_desc=None, **ctor_args)[source]

Create and return an instance of the specified type, or None if this Factory can’t satisfy the request.


Return a list of available types.

get_signature(typname, version=None)[source]

Return constructor argument signature for typname, using the specified package version. The return value is a dictionary.

on_deleted(fpath, deleted_set)[source]
on_modified(fpath, added_set, changed_set, deleted_set)[source]
publish_updates(added_set, changed_set, deleted_set)[source]

The Project’s object provides a basic interface for interacting with the project database used by the GUI.

class openmdao.gui.projectdb.Projects(pathname=None)[source]

Bases: object


Create a new clean database for the GUI user.


Does the database exist?


Get a dictionary containing the fields for a project id.

project_id: int
Unique id for requested project.

Get a dictionary containing the fields that belong to a project with a specific path.

path: str (valid path)
Path for requested project.

Return a list of dictionaries for all projects owned by the user. Each dictionary contains all fields for that project id.


Update metadate modification time-stamp for project_id, setting ‘modified’ to the current time/date.

project_id: int
Unique id for requested project.

Insert a new row into the project database.

data: dict
Dictionary containing all fields for the new entry.

Predict what the next auto-inserted rowid will be. This is here because the GUI handlers need to know the project_id before the row is inserted.


Remove a project from the database.

project_id: int
Unique id for requested project.
set(project_id, field, value)[source]

Set a single field in the project db.

project_id: int
Unique id for requested project.
field: str
Name of field to set.
value: various
Value of field to set.

Ref: (27 OCT/09)

From Gregg Caines blog:

In case anyone’s interested, here’s my that I use for doing a pickle-based session (stored as a file in a directory of your choosing) in Tornado. Feel free to use it however you please. If I write something more scalable one day, I’ll post it too.


In your application script:

settings["session_secret"] = 'some secret password!!'
settings["session_dir"] = 'sessions'  # the directory to store sessions in
application.session_manager = session.TornadoSessionManager(settings["session_secret"], settings["session_dir"])

In your RequestHandler (probably in __init__):

self.session = session.TornadoSession(self.application.session_manager, self)

After that, you can use it like this (in get(), post(), etc):

self.session['blah'] = 1234
blah = self.session['blah']

The basic session mechanism is this:

  • Take some data, pickle it, store it somewhere.
  • Assign an id to it. Run that id through a HMAC (NOT just a hash function) to prevent tampering.
  • Put the id and HMAC output in a cookie.
  • When you get a request, load the id, verify the HMAC. If it matches, load the data from wherever you put it and depickle it.
exception openmdao.gui.session.InvalidSessionException[source]

Bases: exceptions.Exception

class openmdao.gui.session.Session(session_id, hmac_digest)[source]

Bases: dict

A Session is basically a dict with a session_id and an hmac_digest string to verify access rights.

class openmdao.gui.session.SessionManager(secret, session_dir='')[source]

Bases: object

SessionManager handles the cookie and file read/writes for a Session.

get(session_id=None, hmac_digest=None)[source]
class openmdao.gui.session.TornadoSession(tornado_session_manager, request_handler)[source]

Bases: openmdao.gui.session.Session

A TornadoSession is a Session object for use in Tornado.

class openmdao.gui.session.TornadoSessionManager(secret, session_dir='')[source]

Bases: openmdao.gui.session.SessionManager

A TornadoSessionManager is a SessionManager that is specifically for use in Tornado and uses Tornado’s cookies.

set(requestHandler, session)[source]

Utility functions used by openmdao GUI.


Create directory if it doesn’t exist.


Create a nested dictionary for a file structure with names relative to the starting directory.


Find the Chrome executable.


Look for an executable given a list of the possible names.

openmdao.gui.util.launch_browser(port, preferred_browser=None)[source]

Launch web browser on specified port. Try to use preferred browser if specified; fall back to default. (Chrome will launch in “app mode”.)

openmdao.gui.util.makenode(doc, path)[source]

Return a document node containing a directory tree for the path. Modified version of:


Create a nested dict for a package structure.


Print the contents of a dictionary.


Pretty print json data.


Print the contents of a list.


Return a dict containing full name vs. short name where short name is still unique within the given list. Each entry in the initial list of dotted names is assumed to be unique.

class openmdao.gui.zmqserver.ZMQServer(options)[source]

Bases: object

Wraps an an openmdao object with ZMQ and runs it as a server.

static get_options_parser()[source]

Create a parser for command line arguments.

static spawn_server(classpath, rep_url, pub_url, out_url)[source]

Run server in its own process.


Process command line arguments, create server, and start it up.

class openmdao.gui.zmqservermanager.ZMQServerManager(classpath, external=False)[source]

Bases: object

Creates and keeps track of ZMQ servers for the given class.


Delete all servers.


Delete the server(s) associated with an id.

get_websocket_url(server_id, stream_name, target_url)[source]

Get the url of the websocket for the specified stream of the specified server; if websocket server does not exist, start it.

server_id: The id of the server.

stream_name: The name of the stream (‘out’ or ‘pub’).

target_url: The relative url at which to serve the websocket.


Get server associated with an id; create one if none exists.


class openmdao.gui.zmqstreamserver.ZMQStreamApp(zmqstream_addr, websocket_url)[source]

Bases: tornado.web.Application

A web application that serves a ZMQStream over a WebSocket.

class openmdao.gui.zmqstreamserver.ZMQStreamHandler(application, request, **kwargs)[source]

Bases: tornado.websocket.WebSocketHandler

A handler that forwards output from a ZMQStream to a WebSocket.

class openmdao.gui.zmqstreamserver.ZMQStreamServer(options)[source]

Bases: object

Runs an http server that serves a ZMQStream over a WebSocket.

static get_options_parser()[source]

Create a parser for command-line arguments.


Start server listening on port & start the ioloop.

static spawn_process(zmq_url, ws_port, ws_url='/', external=False)[source]

Run zmqstreamserver in its own process, mapping a zmq stream to a websocket.

args: zmq_url the url of the ZMQStream ws_port the port to serve the WebSocket on ws_url the url to map to the WebSocket


Process command line arguments, create server, and start it up.