Tutorial: Calculator app on AWS system
Topics
- Creating a Simple Bash Application on a AWS
- Application overview
- Step 1: Accessing the application creation page
- Step 2: Set the status
- Step 3: Provide app details
- Step 4: Select app type
- Step 5: Miscellaneous settings
- Step 6: Select container runtime
- Step 7: Batch scheduler
- Step 8: System selection
- Step 9: Input Type Configuration
- Step 10: Finalize and save
- Step 11: Creating Input Element
- Step 12: The final app form
- Step 13: Monitoring job status
- Step 14: Cloning and re-submitting jobs
Creating a Calculator Batch Application on a AWS ↑
This tutorial will walk you through the steps of creating an application to run on AWS using the provided web interface. Follow the instructions below to complete each section of the form.
Application overview ↑
This Bash script is a simple command-line calculator that accepts input parameters in the form of key-value pairs, such as first_operator=, operand=, second_operator=, and output=. It performs basic arithmetic operations (addition, subtraction, multiplication, and division) based on the given inputs and writes the result to a specified output file.
How it Works:
- Input Parsing: The script uses a loop to parse input arguments that are passed in the format:
- first_operator=<value>
- operand=<plus|minus|multiply|divide>
- second_operator=<value>
- output=<output_file>
- These arguments define two numeric values (first_operator, second_operator), the arithmetic operation (operand), and the file where the result will be saved (output_file).
- Validation: The script checks if all required arguments are provided. If any argument is missing, it exits with an error message and usage instructions.
- Arithmetic Operations:
- The script supports four basic operations: addition (plus), subtraction (minus), multiplication (multiply), and division (divide).
- It performs the selected operation on the two input numbers. For division, it checks for division by zero to avoid errors.
- Output: The result of the calculation is saved to the specified output file in the format Result: <calculated_value>. A success message is displayed indicating that the result has been saved.
Example Usage:
- To add two numbers and save the result to a file:
./calculator.sh first_operator=1 operand=plus second_operator=2 output=result.txt
- To multiply two numbers and save the result:
./calculator.sh first_operator=3 operand=multiply second_operator=4 output=output.txt
Step 1: Accessing the application creation page ↑
- Login to https://qwx1.onescienceway.com.
- Navigate to the “Apps” menu, https://qwx1.onescienceway.com/node/add/tapis_app and click on "Add app".
Step 2: Set the status ↑
Under the Status section, you will find three options:
- Enabled: Select this if the application should be available for use.
- Disabled: Select this to disable the app.
- Archived: Choose this if you want to archive the app but still retain its details for future use.
Select the appropriate status for your application. For this tutorial, choose Enabled.
Step 3: Provide app details ↑
In this section, you need to fill in the following fields:
- App nickname: Enter a short nickname for the application. This is a required field.
- App ID: Provide a unique ID for the app. It must be in lowercase and without any spaces. For this tutorial, use your user ID. (e.g., <your user ID>.tutorial.calculator).
- App Version: Specify the version of the app (e.g., 0.1.0).
- Summary: Add a one-line summary that describes the application.
- Long Description: You can include a detailed description of your app in this section using the rich text editor.
Step 4: Select app type ↑
In this section, choose the type of application from the following options:
- Batch: Select this if your app runs as a non-interactive command line application.
- VNC: Choose this for interactive graphical applications like MetaLab.
- Web: Use this for interactive web applications like Jupyter Notebook.
For this tutorial, select the option, Batch.
Step 5: Miscellaneous settings ↑
- Restartable: Check this box if the job can be restarted by the user after submission.
- Show generated command: Displays the command in the message window for troubleshooting.
- Update the app’s webform: If checked, this will update the app settings with the values from the form.
Step 6: Select container runtime ↑
Next, choose the runtime that will be used by the application. The available options are:
- Docker
- Singularity
- If this is chosen, additional runtime options like Singularity start or Singularity run become available.
- Executable
- If this is chosen, specify the Executable path to point to the location where the script or binary resides.
For this tutorial, the app uses the singularity container, selects Executable, and enters the executable path, “/home/ubuntu/apps/calculator.sh”.
Step 7: Batch scheduler ↑
- Use batch scheduler: Check this box if the app requires a batch scheduler like SLURM.
- If the app uses a batch scheduler, enable this option and add scheduler profiles.
Step 8: System selection ↑
- Available systems: Select the system(s) where the app can be executed. For example, you can choose ”AWS System (EC2)”.
- Default system: Choose the default system for the application.
- Tenant: Select a tenant from the dropdown.
For this tutorial, select the option for Available systems and Default system, AWS System (EC2), and select the Tenant, Quakeworx.
Step 9: Input Type Configuration ↑
Define how inputs will be provided to the app:
- No input parameters are needed: Select this if your application doesn't require any user-provided input.
- Fixed Command: Specify the full command to run the application: Choose this if you want to provide a specific command that will be executed when the application launches. You'll enter the command in the text field that appears.
- Form: Create a form that will allow users to set parameters, upload files as input to the application: Select this option to create a user interface where users can input parameters or upload files when they launch the application.
For this tutorial, users can input parameters, select Form and provide the necessary configuration.
Step 10: Finalize and save ↑
- After completing the form, review all the details to ensure correctness.
- Click on the Save button to register the application
Step 11: Creating Input Element ↑
This process is important if you want to collect specific input data from users running your scientific application on AWS. The following instructions will guide you through the process using the web interface shown in the images.
Step 11-1: Application created ↑
Once you have successfully created an application, you will see a confirmation message:
"An app form has been created. Calculator has been created."
Click the "Configure app form" button to start setting up the custom input elements that your app will require. The app will be configured to accept user inputs necessary for running the scientific application on a designated system (such as a HPC cluster or AWS).
Step 11-2: Begin configuring the app form ↑
After clicking "Configure app form", you will be directed to a page where you can specify job resources and add input fields for your application. In this case, we are working with a Calculator application as an example.
Step 11-3: Search for elements ↑
After clicking the Build link, to add UI elements, follow these steps:
- Select the Add element button on the top left.
- In the Select an element search box, type a keyword related to the input you need. For example, if you need a number element, you can search for the "number".
- From the list, choose the desired element. In this example, the Number (OSP) element is chosen to capture the First number.
Step 11-4: Add and configure the Number ↑
After selecting the number element, you need to configure it to match your application requirements.
- Title: Enter the title of the input field (e.g., First number). This is how users will know what to input.
- Command arguments: This section allows you to define how the input will be passed to the backend. In this case:
- Type: Select Command line argument.
- Command prefix: Set the prefix, for example, first_operator=
- Ensure the Add trailing space to command prefix checkbox is unselected so that the command is formatted correctly.
- Form validation: checked Required.
Once everything is configured, click Save to add this element to the form.
Step 11-5: Review added element ↑
After saving, the newly added number element (First number) will appear in the element list on the right side of the screen. This list shows all the input fields that will be included in the final application form.
At this stage, you can continue adding more elements or adjust the current ones as needed.
Step 11-6: Search for elements ↑
- Select the Add element button on the top left.
- In the Select an element search box, type a keyword related to the input you need. For example, if you need a select element, you can search for the "select".
- From the list, choose the desired element. In this example, the Select (OSP) element is chosen to capture the Operand.
Step 11-7: Add and configure the Select ↑
After selecting the select element, you need to configure it to match your application requirements.
- Title: Enter the title of the input field (e.g., Operand). This is how users will know what to input.
- Command arguments: This section allows you to define how the input will be passed to the backend. In this case:
- Type: Select Command line argument.
- Command prefix: Set the prefix, for example, operand=
- Ensure the Add trailing space to command prefix checkbox is unselected so that the command is formatted correctly.
- Options:
- Form validation: checked Required.
Once everything is configured, click Save to add this element to the form.
Step 11-8: Review added element ↑
After saving, the newly added select (Operand) will appear in the element list on the right side of the screen. This list shows all the input fields that will be included in the final application form.
At this stage, you can continue adding more elements or adjust the current ones as needed.
Step 11-9: Search for elements ↑
- Select the Add element button on the top left.
- In the Select an element search box, type a keyword related to the input you need. For example, if you need a number element, you can search for the "number".
- From the list, choose the desired element. In this example, the Number (OSP) element is chosen to capture the Second number.
Step 11-10: Add and configure the Number ↑
After selecting the number element, you need to configure it to match your application requirements.
- Title: Enter the title of the input field (e.g., Second number). This is how users will know what to input.
- Command arguments: This section allows you to define how the input will be passed to the backend. In this case:
- Type: Select Command line argument.
- Command prefix: Set the prefix, for example, second_operator=
- Ensure the Add trailing space to command prefix checkbox is unselected so that the command is formatted correctly.
- Form validation: checked Required.
Once everything is configured, click Save to add this element to the form.
Step 11-11: Review added element ↑
After saving, the newly added number element (Second number) will appear in the element list on the right side of the screen. This list shows all the input fields that will be included in the final application form.
At this stage, you can continue adding more elements or adjust the current ones as needed.
Step 11-12: Search for elements ↑
- Select the Add element button on the top left.
- In the Select an element search box, type a keyword related to the input you need. For example, if you need a text field, you can search for the "text field".
- From the list, choose the desired element. In this example, the Text field (OSP) element is chosen to capture the Output file name.
Step 11-13: Add and configure the Text field ↑
After selecting the text field element, you need to configure it to match your application requirements.
- Title: Enter the title of the input field (e.g., Output file name). This is how users will know what to input.
- Command arguments: This section allows you to define how the input will be passed to the backend. In this case:
- Type: Select Command line argument.
- Command prefix: Set the prefix, for example, output=
- Ensure the Add trailing space to command prefix checkbox is unselected so that the command is formatted correctly.
- Form validation: checked Required.
Once everything is configured, click Save to add this element to the form.
Step 11-14: Review added element ↑
After saving, the newly added text field (Output file name) will appear in the element list on the right side of the screen. This list shows all the input fields that will be included in the final application form.
At this stage, you can continue adding more elements or adjust the current ones as needed.
Step 12: The final app form ↑
Click the View link in the top left corner. Once you’ve added all necessary input fields, the app form will be complete.
Click "Submit" to proceed, in order to launch the job.
Step 13: Monitoring job status ↑
Once the job is submitted, you can monitor its status.
- Job status monitoring:
After launching the job, you will be taken to a status page where you can see the job’s progress. The possible statuses include:- Running: The job is actively being processed.
- Staging job: The job is being prepared for execution.
- Processing inputs: The inputs provided in the submission form are being processed.
- Here, you can also view resource details such as:
- Number of nodes, cores, memory, system name, etc.
- Terminating a job:
If needed, you can terminate the job from this page by clicking Terminate Job.
- Reviewing a job output:
You can review the job output from this page by clicking the Output link.
Step 14: Cloning and re-submitting jobs ↑
- Accessing previous jobs:
From the My Jobs menu, you can view a list of all jobs that have been submitted. This list shows the job name, application used, system, submission date, and other details. - Cloning a job:
You can clone an existing job by clicking the Clone button next to the job in the list. This will open the job submission page again with all the previously filled parameters.
- Modifying cloned job parameters:
On the cloned job submission page, you can update any of the parameters. For example, you can:- Change the Job name.
- Modify other resource settings if needed.
- Submit or Save Draft:
Once the modifications are made, click Submit to run the cloned job or Save Draft to make adjustments later.