HowTo: Use TWCC CLI to automatically complete computing and delete containers
This article will help users understand how to use TWCC CLI to automate the following tasks:
1. Execute computing program
2. Delete container
After creating Interactive Container on portal or using TWCC CLI, you can assign manual tasks to script to complete computing automatically, delete containers, and reduce the cost of keeping the containers running. Since the computing program and data will be kept in the default storage space of the container, Hyper File System (HFS), there is no need to worry about losing data when the container is deleted.
Step 1. Upload the computing program to the container
Refer to Using SFTP + Filezilla to transfer file to upload the training script to the container's default storage space, namely the Hyper File System (HFS) storage space.
Step 2. Install TWCC CLI
- Please refer to Install TWCC CLI to install TWCC CLI in the Interactive Container.
- The container versions after 2021 already have TWCC CLI pre-installed for users, so you can log in directly after the creation.
- The container versions before 2021 require users to install TWCC CLI themselves.
- Please sign in after the installation completed.
Step 3. View Interactive Container's ID
- Enter the following command to view container's ID that you are currently using:
twccli ls ccs
Step 4. Writing automation script
- Enter the following command to edit the automation script:
vi auto.sh
- Enter
i
to enter the editing mode, copy and paste the following example script intoauto.sh
. The content can be modified according to your computing program.
TWCC_CLI_CMD=/home/<USERNAME>/.local/bin/twccli
# <USERNAME>:Supercomputer account
echo "1. Execute computing"
# Enter the executable file of the computing program
echo "2. Delete Interactive Container"
$TWCC_CLI_CMD rm ccs -f -s <CCS_ID>
# <CCS_ID>: the container ID in step 3
- Press Esc key and enter
:wq!
to save.
Step 5. Execute automated script
Enter the following command to have the script running the computing program and delete the container!
bash auto.sh
Step 6. Confirm that the container has been automatically deleted
After the program has finished running, you can confirm that the container has been deleted from the list on the Development Container Management Page.