{ "metadata": { "name": "", "signature": "sha256:bfe57484c58a7bf08b8ee8db5f91c2ebd9781e947c41d176034ed1bc86fc1947" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import traceback" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "# VisTrails API example\n", "\n", "This notebook showcases the new API. Inlined are some comments on design decisions." ] }, { "cell_type": "code", "collapsed": false, "input": [ "import vistrails as vt" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are few reasons for the API not to be under the top-level `vistrails` package. They are:\n", "\n", "* Versioning; rolling out a new API would be difficult (this is the third attempt at an API already).\n", "* Weight; the top-level package is always imported even if VisTrails is not to be used programmatically. This is a non-issue if the API doesn't do any initialization before the first API call, and provided that importing stuff from the rest of VisTrails doesn't have harmful side-effects." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `Vistrail`s and `Pipeline`s\n", "\n", "`Vistrail`s objects are currently obtained through `load_vistrail()`, although they can be constructed from an existing `Pipeline` or `VistrailController`internal.\n", "\n", "> Question: should we allow Vistrail('path/to/file') as well?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "vistrail = vt.load_vistrail('examples/simplemath.vt')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "A `Vistrail` is basically a controller. From it we can get `Pipeline`s, but it is also stateful (i.e. has a current version); this is useful for editing (creating new versions from the current one). It also provides the interface that `Pipeline` has, implicitely acting on the `current_pipeline`.\n", "\n", "> Problem: there are issues with upgrades; `get_pipeline()` can return non-upgraded pipelines and this is bad.\n", "> `vistrail.get_pipeline(vistrail.current_version)` will return the non-upgraded thing which is unexpected." ] }, { "cell_type": "code", "collapsed": false, "input": [ "vistrail" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "
<Vistrail: simplemath.vt, version -1, not changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 4, "text": [ "
<Vistrail: simplemath.vt, version 28, not changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 6, "text": [ "
<Pipeline: 1 modules, 0 connections>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 7, "text": [ "
<Vistrail: outputs.vt, version 1, not changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 13, "text": [ "
<Vistrail: outputs.vt, version 5, changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 16, "text": [ "
<Pipeline: 2 modules, 1 connections; outputs: msg>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 17, "text": [ "
<Pipeline: 6 modules, 6 connections; inputs: in_a, in_b; outputs: out_times, out_plus>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 20, "text": [ "
<Vistrail: imagemagick.vt, version 9 (tag read), not changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 25, "text": [ "
<Vistrail: imagemagick.vt, version 16 (tag blur), changed>" ], "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": [ "