Second App
worker_layout_inspection
Since assets are such a great app developer convenience, our second app, worker_layout_inspection, will illustrate the use of assets and inputs for presenting code and data to the app. First let's create some assets that will be incorporated into the app. Additionally, since Docker is also such a great app developer tool, the incorporation of Docker images into the app by packaging them in an asset or providing them as an input file, are both illustrated.
Create an asset with code and data
Layout your asset directories and files
The file system structure that you layout in your asset will be overlaid on the worker / (root) mount when the app is run. If you've include code in the asset's /usr/bin, it will be available to your app running on the worker. The app framework uses /work as the directory to present input files to apps so any files placed in the asset's /work directory will be available with other input files, though you could place files in whatever asset directory structure you want.
We going to construct our asset in a Linux shell, downloading from precisionFDA the following for inclusion in the asset:
-
ubuntu_latest.tar (file-GK1FP9j05gK8z93Y1xGQpf5B-1)
-
countries.txt (file-GK1F6j80Kj2XbJzx29f25y42-1)
Create your asset directory structure.
Create a shell script to install tree and run it, then move the script into the asset directory structure.
Create a Readme file as required for the asset. This doesn't need to reside in the asset /fakeroot directory structure.
Download the Docker and data files and move them into the asset directory structure. Under My Home Assets, click on the How to create assets button to find links to the precisionFDA CLI, and the button to generate the temporary authorization key that you'll use with the CLI.



Create the asset using the CLI
Now that the asset contents have been laid out, creating the asset on precisionFDA is a straightforward process using the precision FDA CLI.

Manually deploying an asset tar file
While this workflow should not be required, it is worth knowing to understand how assets work. Upload the asset tarball (e.g. worker_layout_inspection.tar) as a file, then in your app, add a file to the I/O Spec (e.g. "asset_tarball") and select this tarball as the default. Add the following line to the Script, right after the set -euxo pipefail command:
Everything that was installed in the fake_root/ in the tarball will be placed into the root directory of the worker, including any executable you may have. For example:
from the asset_tarball input, will be available in:
after the tar command above is run in the app script.
Create the App and Specify the I/O Spec
In My Home / Apps, click the Create App button to create the worker_layout_inspection app. In the I/O Spec tab, add the input and output fields.

| Class | Array? | Input Name | Label | Default Value |
|---|---|---|---|---|
| string | string_input | example string input | this is a string | |
| int | integer_input | example integer input | 54321 | |
| float | float_input | example float input | 1.234 | |
| boolean | boolean_input | example boolean input | FALSE | |
| file | observation_data | Delimited observation data | observations.txt | |
| file | patient data - | Delimited patient data | patients.txt | |
| file | samtools docker - image | Docker image for Samtools | samtools biocontaine rs.tar | |
| file | postgres_docker_ image | Docker image for postgres server | postgres_13.4- buster.tar | |
| string | inspection resul ts filename - | Inspection results filename | inspection_results.t xt | |
| string | url_to_fetch | URL to pass to next app in workflow | https://pfda- production-static- files.s3.amazonaws.c om/cli/pfda-linux- 2.2.tar.gz | |
| string | Yes | string_array_input image | example string array input | string1,string2,string3 |
| int | Yes | integer_array_input | example integer array input | 5,4,3,2,1 |
| file | Yes | file_array_input | example file array input | (select three files) |
| Class | Array? | Output Name | Label | |
| file | Inspection resul - ts | Worker layout and variable inspection results | ||
| string | url_to_fetch | URL to pass to next app in workflow | ||
| file | Yes | file_array_output | example file array output | |
| string | Yes | string_array_output | example string array output |
Specify the VM Environment
In the VM Environment tab, enable internet access, select default instance Baseline 2, and add the following assets: worker_layout_inspection, pfda_cli_2.2, and ubuntu_asset.

Specify the Script
Add the following code to the script tab:
Specify the Readme
Add the following in the Readme tab:
Run the app
In My Home / Apps, select the worker_layout_inspection app and click Run App to launch the latest version of the app with all default inputs.


Refresh the execution status using the
button until the job is first idle, runnable, running, and done, (or failed).

Inspect the execution logs and the inspection results file
Note that the execution of the app took just over a minute and produced inspection_results.txt file and URL string outputs.


Select View Logs from the the Actions dropdown menu. Let's look at a condensed and annotated version of the log output to understand what our app just did.