Utility Apps
untar_files, tar_files_from_manifest
We are going to use the pfda_cli_2.2.tar asset to create two very useful apps that demonstrate a design pattern that is readily extensible. The precisionFDA app I/O specification supports scalar and file and output types but does not support arrays for input or output variables. This means that using the app input variable and output emit framework, you cannot create apps with an arbitrary number of inputs or outputs. For instance, you really can't even create an untar app due to this limitation. These two apps demonstrate a design pattern to overcome this limitation.
Note that these apps require a temporary authorization key that you'll use with the CLI and this key will appear in the execution log files. Thus you should only run this app in your My Home or Private Space contexts so as not to expose the key to other users.

tar_files_from_manifest: Tar a manifest of fileIDs
From My Home / Files, select the detail page and copy the file ID for a number of files. Create and upload manifest.txt with the list to be incorporated into an archive file (e.g.):
Create a tar_files_from_manifest app titled "Tar a manifest of fileIDs", with the following I/O Spec.
| Class | Input Name | Label | Default Value |
|---|---|---|---|
| file | manifest | Text manifest of fileIDs | manifext.file |
| string | tar_filename | Filename for tar archive | archive.tar |
| string | pfda_key | Token for pfda CLI | |
| Class | Output Name | Label | |
| file | tarfile | Tar archive file |

Setup the VM environment with internet access enabled, Baseline 2 default instance type, and select the pfda_cli_2.2 asset. Note that it can take minutes for the list of assets to loaded before they can be searched.
Enter the following Script:
Enter a Readme and Create the app.
Run the app with the default inputs and a fresh authorization token for the pfda CLI and observe the new archive.tar file.

When the execution is done, download the archive.tar file to verify its contents.
untar_files: Untar archive to files
Create a untar_files app titled "Untar archive to files", with the following I/O Spec.
| Class | Input Name | Label | Default Value |
|---|---|---|---|
| string | pfda_key | CLI access authorization token | |
| file | input_tarfile | Tar file to extract | archive.tar |
| string | extracted_list_f ilename | List of extracted files | extracted_list.txt |
| Class | Output Name | Label | |
| file | tarfile_contents | Listing of the tarfile contents |

Setup the VM environment with internet access enabled, Baseline 2 default instance type, and select the pfda_cli_2.2 asset. Note that it can take minutes for the list of assets to loaded before they can be searched.
Enter the following Script:
Enter a Readme and Create the app.
Run the app with the default inputs and a fresh authorization token for the pfda CLI.


When the execution is done, observe the new extracted files, and open the extracted_list.txt file to see the list of extracted files.
