Difference between revisions of "FAQ"
Line 83: | Line 83: | ||
By default, an unoccupied cell on the active sheet will be chosen to display the result. However, you can specify exactly in the pipeline where a spreadsheet cell will be placed by using CellLocation and SheetReference. CellLocation specifies the location (row and column) of a cell when connecting to a spreadsheet cell (VTKCell, ImageViewerCell, ...). Similarly, a SheetReference module (when connecting to a CellLocation) will specify which sheet the cell will be put on given its name, minimum row size and minimum column size. There is an example of this in examples/vtk.xml (select the version below Double Renderer). | By default, an unoccupied cell on the active sheet will be chosen to display the result. However, you can specify exactly in the pipeline where a spreadsheet cell will be placed by using CellLocation and SheetReference. CellLocation specifies the location (row and column) of a cell when connecting to a spreadsheet cell (VTKCell, ImageViewerCell, ...). Similarly, a SheetReference module (when connecting to a CellLocation) will specify which sheet the cell will be put on given its name, minimum row size and minimum column size. There is an example of this in examples/vtk.xml (select the version below Double Renderer). | ||
=== How do I output results to the spreadsheet? === | |||
By inspecting the VisTrails Spreadsheet package (in the list of packages, to the left of the pipeline builder), you | |||
can see there are built-in cells for different kinds of data, e.g., RichTextCell to display HTML and plain text. op | |||
You (the user) can also define new cell types to display application-specific data. For example, we have developed | |||
VtkCell, MplFigureCell, and OpenGLCell. It is possible to display pretty much anything on the Spreadsheet! | |||
Examples of writing cell modules can be found in: | |||
RichTextCell: packages/spreadsheet/widgets/richtext/richtext.py | |||
VTK: packages/vtk/vtkcell.py | |||
Here is the summary of some requirements on a cell widget: | |||
(1) It must be a Qt widget. It should inherit from spreadsheet_cell.QCellWidget in the spreadsheet package. Although any Qt Widget would work, certain features such as animation will not be available (without rewriting it). | |||
(2) It must re-implement the updateContents() function to take a set of inputs (usually coming from input ports of a wrapper Module) and display on the cells. VisTrails uses this function to update/reuse cells on the spreadsheet when new data comes in. | |||
(3) It needs a wrapper VisTrails Module (inherited from basic_widgets.SpreadsheetCell of the spreadsheet package). Inside the compute() method of this module, it may call self.display(CellWidgetType, (inputs)) to trigger the display event on the spreadsheet. | |||
== Integrating your software into VisTrails == | == Integrating your software into VisTrails == | ||
Line 150: | Line 170: | ||
Yes. Versions 1.4 and greater support these features. See [[UsersGuideVisTrailsPackages#Adding_default_values_and.2For_labels_for_parameters | UsersGuideVisTrailsPacakges]] for more details. | Yes. Versions 1.4 and greater support these features. See [[UsersGuideVisTrailsPackages#Adding_default_values_and.2For_labels_for_parameters | UsersGuideVisTrailsPacakges]] for more details. | ||
== The Console == | |||
=== Where should I go to find out what I can call from the console and how to import it? === | |||
We have tried to make some methods more accessible in the console via an api. You can import the api via "import api" in the console and see the available methods with "dir(api)". To open a vistrail: | |||
import api | |||
api.open_vistrail_from_file('/Applications/VisTrails/examples/terminator.vt') | |||
To execute a version of a workflow, you currently have to go through the controller: | |||
api.select_version('Histogram') | |||
api.get_current_controller().execute_current_workflow() | |||
Reloading a package is currently two separate calls connected with a signal so I wasn't able to make that work via the console. Currently, only a subset of VisTrails functionality is directly available from the api. However, since VisTrails is written in python, you can dig down starting with the VistrailsApplication or controller object to expose most of our internal methods. If you have suggestions for calls to be added to the api, please let us know. | |||
One other feature that we're working on, but is still in progress is the ability to construct workflows via the console. For example: | |||
vtk = load_package('edu.utah.sci.vistrails.vtk') | |||
vtk.vtkDataSetReader() # adds a vtkDataSetReader module to the pipeline | |||
# click on the new module | |||
a = selected_modules()[0] # get the one currently selected module | |||
a.SetFile('/vistrails/examples/data/head120.vtk') # sets the SetFile parmaeter for the data set reader | |||
b = vtk.vtkContourFilter() # adds a vtkContourFilter module to the pipeline and saves to var b | |||
b.SetInputConnection0(a.GetOutputPort0()) # connects a's GetOutputPort0 port to b's SetInputConnection0 | |||
== VTK == | == VTK == |
Revision as of 20:45, 20 July 2010
Also check our Known Issues page for troubleshooting.
Running workflows
How can I run a workflow using the command line?
(Updated for version 1.2) Call vistrails using the following options:
python vistrails.py -b path_to_vistrails_file:pipeline
where pipeline can be a version tag name or version id
NOTE: If you downloaded the MacOS X bundle, you can run vistrails from the command line via the following commands in the Terminal. Change the current directory to wherever VisTrails was installed (often /Applications
), and then type:
Vistrails.app/Contents/MacOS/vistrails [<cmd_line_options>]
Using the command line, we'd like to execute a workflow multiple times, with slightly different parameters, and create a series of output files. Is this possible?
(Updated for version 1.2) We can change parameters that have an alias through the command line.
For example, offscreen pipeline in offscreen.vt always creates the file called image.png. If you want generate it with a different filename:
python vistrails.py -b ../examples/offscreen.vt:offscreen -a"filename=other.png"
filename
in the example above is the alias name assigned to the parameter in the value
method inside the String module. When running a pipeline from the command line, VisTrails will try to start the spreadsheet automatically if the pipeline requires it. For example, this other execution will also start the spreadsheet:
python vistrails.py -b ../examples/head.vt:aliases \
-a"isovalue=30&Diffuse_Color_R=0.8&Diffuse_Color_G=0.4&Diffuse_Color_B=0.2"
You can also execute more than one pipeline on the command line:
python vistrails.py -b ../examples/head.vt:aliases ../examples/spx.vt:spx \
-a"isovalue=30"
Use the -a parameter only once regardless the number of pipelines.
I can load a vistrail, and the version tree shows up fine. However, no pipelines appear when I click on a version. What gives?
The most likely reason is that the vistrail uses a package that is not registered with VisTrails. You need to identify the needed package and add it to your .vistrails/startup.py
. A single line like the following should be enough:
addPackage('enter_package_name_here')
Some packages might need more information. For example:
addPackage('afront', executable_path='/path/to/afront')
Refer to the package documentation for details. The one inconvenient step is that currently there's no automated way to describe what is the missing package. We're working on this feature for future releases.
Building workflows
Is there a way to give each widget a "display name" in addition to the module name at the center of the widget?
Yes, but it is not easily accessible from the GUI and it definitely needs to be more intuitive. For now, we use the annotation value of key "__desc__" as a module label. If you want to set a PythonSource label, you have to select the module. Then click on the Annotation tab, and add a key named "__desc__", whatever value you set to this key will be the label. We are currently working on a new interface for this functionality.
Is there a way to re-center the picture-in-picture (PiP) view?
Yes. If you click on the PIP window to bring it to focus, you can press Ctrl-R (or Command-R on Mac) to re-center the PiP window.
Spreadsheet
Where pipeline is a version number or a tag.
How can I save an image from the spreadsheet?
While having the focus on a spreadsheet cell press "Ctrl" (on Windows) and select the camera to take a snapshot. The system will prompt you for the location and file name where it should be saved. The other icons can be used for saving multiple images that can be used for generating an animation on demand.
Is it possible to save the complete state of the spreadsheet?
Can I view multiple sheets at the same time?
Yes. Each sheet on the spreadsheet can be displayed as a dock widget separated from the main spreadsheet window by dragging its tab name out of the tab bar at the bottom of the spreadsheet.
Then, how can I put back a separated sheet?
A sheet can be docked back to the main window by dragging it back to the tab bar or double-click on its title bar.
How can I order sheets on the spreadsheet?
This can be done by dragging the sheet name on the bottom top bar and drop it to the right place.
Can I control where a cell will be placed on the spreadsheet window?
By default, an unoccupied cell on the active sheet will be chosen to display the result. However, you can specify exactly in the pipeline where a spreadsheet cell will be placed by using CellLocation and SheetReference. CellLocation specifies the location (row and column) of a cell when connecting to a spreadsheet cell (VTKCell, ImageViewerCell, ...). Similarly, a SheetReference module (when connecting to a CellLocation) will specify which sheet the cell will be put on given its name, minimum row size and minimum column size. There is an example of this in examples/vtk.xml (select the version below Double Renderer).
How do I output results to the spreadsheet?
By inspecting the VisTrails Spreadsheet package (in the list of packages, to the left of the pipeline builder), you can see there are built-in cells for different kinds of data, e.g., RichTextCell to display HTML and plain text. op You (the user) can also define new cell types to display application-specific data. For example, we have developed VtkCell, MplFigureCell, and OpenGLCell. It is possible to display pretty much anything on the Spreadsheet!
Examples of writing cell modules can be found in: RichTextCell: packages/spreadsheet/widgets/richtext/richtext.py VTK: packages/vtk/vtkcell.py
Here is the summary of some requirements on a cell widget:
(1) It must be a Qt widget. It should inherit from spreadsheet_cell.QCellWidget in the spreadsheet package. Although any Qt Widget would work, certain features such as animation will not be available (without rewriting it).
(2) It must re-implement the updateContents() function to take a set of inputs (usually coming from input ports of a wrapper Module) and display on the cells. VisTrails uses this function to update/reuse cells on the spreadsheet when new data comes in.
(3) It needs a wrapper VisTrails Module (inherited from basic_widgets.SpreadsheetCell of the spreadsheet package). Inside the compute() method of this module, it may call self.display(CellWidgetType, (inputs)) to trigger the display event on the spreadsheet.
Integrating your software into VisTrails
How can I integrate my own program into VisTrails?
The easiest way is to create a package. Writing a package is often very simple, here are instructions on how to do it: UsersGuideVisTrailsPackages
How do modules deal with multiple inputs in a same port?
(And should that even be allowed?)
For compatibility reasons, we do need to allow multiple connections to an input port. However, most package developers should never have to use this, and so we do our best to hide it. the default behavior for getting inputs from a port, then, is to always return a single input.
If on your module you need multiple inputs connected to a single port, use the 'forceGetInputListFromPort' method. It will return a list of all the data items coming through the port. The VTK package uses this feature, so look there for usage examples (packages/vtk/base_widget.py)
Are there mechanisms for attaching widgets to different modules/parameters?
Right now, we have a mechanism for putting a specific widget for an input port. For example, if a port is SetColor(red, green, blue), we can put a color wheel widget there. Or we can also replace the SetFileName port with a File Widget. However, this is not per parameter (only per port). We are currently working on this problem.
Can I organize my package so it appears hierarchical in the module palette?
Yes. Use the namespace keyword argument when adding the module to the registry. For example,
registry.add_module(MyModule, namespace='MyNamespace')
Can I nest namespaces?
Yes. Use the '|' character to separate different the hierarchy. For example,
registry.add_module(MyModule, namespace='ParentNamespace|ChildNamespace')
Are there shortucts for registry initialization?
Yes. If you define _modules as a list of classes in the __init__.py file of your package, VisTrails will attempt to load all classes specified as modules. You can provide add_module options as keyword arguments by specifying a tuple (class, kwargs) in the list. For example:
_modules = [MyModule1, (MyModule2, {'namespace': 'MyNamespace'})]
In addition, you need to identify the ports of your modules as a field in your class by defining _input_ports and _output_ports lists. Here, the items in each list must be tuples of the form (portName, portSignature, optional=False, sort_key=-1). For example:
class MyModule(Module): def compute(self): pass _input_ports = [('firstInput', String), ('secondInput', Integer, True)] _output_ports = [('firstOutput', String), ('secondOutput', String)]
Can I define ports to be of types that I do not import into my package?
Yes. You can pass an identifier string as the portSignature instead. The port_signature string is defined by:
<module_string> := <package_identifier>:[<namespace>|]<module_name>, <port_signature> := (<module_string>*)
For example,
registry.add_input_port(MyModule, 'myInputPort', '(edu.utah.sci.vistrails.basic:String)')
or
_input_ports = [('myInputPort', '(edu.utah.sci.vistrails.basic:String)')]
What do I need to change in my package to make it reloadable (new in v1.4.2)?
See UsersGuideVisTrailsPackages for an explanation.
Can I add default values or labels for parameters?
Yes. Versions 1.4 and greater support these features. See UsersGuideVisTrailsPacakges for more details.
The Console
Where should I go to find out what I can call from the console and how to import it?
We have tried to make some methods more accessible in the console via an api. You can import the api via "import api" in the console and see the available methods with "dir(api)". To open a vistrail:
import api api.open_vistrail_from_file('/Applications/VisTrails/examples/terminator.vt')
To execute a version of a workflow, you currently have to go through the controller:
api.select_version('Histogram') api.get_current_controller().execute_current_workflow()
Reloading a package is currently two separate calls connected with a signal so I wasn't able to make that work via the console. Currently, only a subset of VisTrails functionality is directly available from the api. However, since VisTrails is written in python, you can dig down starting with the VistrailsApplication or controller object to expose most of our internal methods. If you have suggestions for calls to be added to the api, please let us know.
One other feature that we're working on, but is still in progress is the ability to construct workflows via the console. For example:
vtk = load_package('edu.utah.sci.vistrails.vtk') vtk.vtkDataSetReader() # adds a vtkDataSetReader module to the pipeline
- click on the new module
a = selected_modules()[0] # get the one currently selected module a.SetFile('/vistrails/examples/data/head120.vtk') # sets the SetFile parmaeter for the data set reader b = vtk.vtkContourFilter() # adds a vtkContourFilter module to the pipeline and saves to var b b.SetInputConnection0(a.GetOutputPort0()) # connects a's GetOutputPort0 port to b's SetInputConnection0
VTK
Given a VTK visualization, how can I generate a webpage from it?
Check out the html pipeline in offscreen.xml.
I'm trying to use VTK, but there doesn't seem to be any output. What is wrong?
To use VTK on VisTrails, you need a slightly different way of connecting the renderer modules. Instead of using the standard RenderWindow/RenderWindowInteractor infrastructure, you simply connect the renderer to a VTKCell. The examples directory in the distribution has several VTK examples that illustrate.