Context Navigation

Uploading with Rappture

Topics discussed:

Uploading Basics

Uploading Data Example Files

How It Works

Uploading Basics

Rappture developers can allow application users to upload data into the
application by using Rappture's Upload capabilities. This is usesful
if you have an older application that requires a complicated input deck
or if the input deck is actually the output of another application.
You can allow the user to upload data into the Rappture GUI using the
"Upload" capabilities of the loader. To learn
more about how loaders work, check out the wiki page on
loaders and pay particular attention to the
"Upload / Download" section.

Uploading Data Example

This example demonstrates using the upload capabilities of Rappture.
The following files are used in this example:

sineIt.py - python script representing some science code

inputDeck - cryptic input deck used by our science code

wrapper.py - python script representing a wrapper script

tool.xml - Rappture tool description file

You can download these files by clicking on the links at the bottom of this page.
Here is what each file should look like:

How it works

As always, first the user starts simulation and the graphical user interface comes up.

By clicking on the loader (drop down menu labeled Example in above picture) and choosing the "Upload" option the user
can pick a file from their local computer and have it uploaded to the rappture graphical user interface.

After the user uploads their data, it is stored in the xml file at the location described in the loader:

In this case the contents of the uploaded file was saved to input.string(uploadedFile).current as described by the path input.loader.upload.to. The rappture graphical user inerface will be updated with text from the uploaded file. If you do not want to display the uploaded file to the user, you can hide input.string(uploadedFile) using Hidden Options

Next the user clicks the simulate button. Rappture writes the inputs to the driver.xml file and executes the tool command (wrapper.py).
wrapper.py reads the xml file, checks to see if the user uploaded data to the graphical user interface or manually filled in the values.

You can check to see if the user uploaded data by comparing the value of input.loader.current to the string 'Uploaded data'. If they match, then you know the user uploaded data into the graphical user interface. As the wrapper.py script shows, to get the data that was uploaded by the user, simply issue a get command with the "upload to" location specified.

After writing the data to a file, we call the science code with the name of the input deck. The science code reads the input deck, calculates its science and writes the answer back to a file. The wrapper.py script then reads and parses the result file from the science code and places the results back into the rappture library.