Developing CWL Workflows with VSCode
These lessons give step by step instructions for using Visual Studio
Code (abbreviated “vscode”) to develop CWL workflows on Arvados.
- Set up SSH
- Install vscode and necessary extensions, then use vscode to connect to an Arvados shell node for development
- Register a workflow, run it on workbench, and view the log
- Upload input, run a workflow on it, and view the output
- Register a workflow with default inputs
- Run a workflow without registering it
1. SSH Setup
- (Windows only) Install Git for Windows https://git-scm.com/download/win
- Choose “64-bit Git for Windows Setup”. It does not require admin privileges to install.
- Hit “Next” a bunch of times to accept the defaults
- The most important things is that “install git bash” and “install OpenSSH” are enabled (this is the default).
- At the end of the installation, you can launch tick a box to git bash directly.
- Open “Git Bash” (installed in the “Git” folder of the start menu)
- (All operating systems) Starting from bash shell (on MacOS or Linux you will open “Terminal”)
- Shell: Run
ssh-keygen
- Hit enter to save to a default location
- You can choose to protect the key with a password, or just hit enter for no password.
- Shell: Look for a message like
Your public key has been saved
in /c/Users/MyUsername/.ssh/id_rsa.pub
(Windows git bash
example, on MacOS or Linux this will probably start with /Users
or /home
)
- Shell: Run
cat /c/Users/MyUsername/.ssh/id_rsa.pub
- Shell: Use the pointer to highlight and copy the lines starting
with
ssh-rsa …
up to the next blank line. Right click and
select “Copy”
- Open Arvados workbench 2. If necessary, go to the user menu and
select “Go to Workbench 2”
- Workbench: Go to
SSH keys
in the user menu
- Workbench:Click
+Add new ssh key
- Workbench: Paste the key into
Public key
and enter something for name
- Workbench: Go to
Virtual Machines
in the user menu
- Workbench: Highlight and copy the value in in the
Command line
column.
- At the git bash command line
- Shell: paste the
ssh shell…
command line you got from workbench.
- Shell: type “yes” if it asks
Are you sure you want to continue connecting
.
- Note: it can take up to two minutes for the SSH key to be copied to
the shell node. If you get “Permission denied” the first time, wait 60
seconds and try again.
- Shell: You should now be logged into the Arvados shell node.
- Shell: Log out by typing
exit
2. VSCode setup
- Install Visual Studio Code and start it up
- Vscode: On the left sidebar, select
Extensions
- In
Search Extensions in Marketplace
enter “remote development”.
- Choose and install the “Remote Development” extension pack from Microsoft
- Vscode: On the left sidebar, choose
Remote Explorer
- At the top of the Remote Explorer panel choose
SSH targets
- Click
Add New
- Enter the
ssh shell…
command line you used in the previous section, step 1.4.1
- If it asks you
Select SSH configuration file to update
choose the first one in the list.
- Right click the newly added ssh target in the list and select “connect to host in current window`
- If it asks
Select platform of the remote host
select Linux
.
- Vscode: On the left sidebar, go back to
Extensions
- Search for “benten”, then look for
CWL (Rabix/Benten)
and click Install
- On the information page for
CWL (Rabix/Benten)
- If you see a warning
Install the extension on 'SSH: ...' to enable
then click the button Install in SSH: ...
- You should now see a message
Extension is enabled on 'SSH: ...' and disabled locally.
- Vscode: On the left sidebar, choose
Explorer
- Select
Clone Repository
and enter https://github.com/arvados/arvados-vscode-cwl-training, then click Open
- If asked
Would you like to open the cloned repository?
choose Open
- Go to Arvados Workbench
- Workbench: In the user menu, select
Current token
- Workbench: Click on
Copy to Clipboard
.
- Workbench: You should see a notification
Token copied to clipboard
.
- Go to Vscode
- Vscode: Click on the
Terminal
menu
- Vscode: Click
Run Task…
- Vscode: Select
Set Arvados Host
- Vscode: Paste the value of API Host from the Workbench
Get API Token
dialog (found in the User menu) at the prompt
- Vscode: Next, run task
Set Arvados Token
- Vscode: Paste the value of API Token from the Workbench
Get API Token
dialog
- Vscode: These will create files called
API_HOST
and API_TOKEN
3. Register & run a workflow
- Vscode: Click on the
lesson1/main.cwl
file
- Click on the
Terminal
menu
- Click
Run Task…
- Select
Register or update CWL workflow on Arvados Workbench
- This will create a file called
WORKFLOW_UUID
- Workbench: Go to
+NEW
and select New project
- Enter a name for the project like “Lesson 1”
- You should arrive at the panel for the new project
- Workbench: With
Lesson 1
selected
- Click on
+NEW
and select Run a process
- Select
CWL training lesson 1
from the list and click Next
- Enter a name for this run like
First training run
- Enter a message (under
#main/message
) like “Hello world”
- Click
Run process
- This should take you to a panel showing the workflow run status
- Workbench: workflow run status panel
- Wait for the badge in the upper right to say
Completed
- In the lower panel, double click on the
echo
workflow step
- This will take you to the status panel for the
echo
step
- Click on the three vertical dots in the top-right corner next to
Completed
- Choose
Log
- This will take you to the log viewer panel
- Under
Event Type
choose stdout
- You should see your message
- Vscode: Click on the
lesson2/main.cwl
file
- Click on the
Terminal
menu
- Click
Run Task…
- Select
Register or update CWL workflow on Arvados Workbench
- Go to your desktop
- Right click on the desktop, select
New > Text Document
- Name the file
message
- Enter a message like “Hello earth” and save
- Workbench: Go to
+NEW
and select New project
- Enter a name for the project like “Lesson 2”
- You should arrive at the panel for the new project
- Arvados workbench: With
Lesson 2
project selected
- Click on +NEW and select
New collection
- For Collection Name enter “my message”
- Drag and drop
message.txt
into the browser
- Click
Create a collection
- The file should be uploaded and then you will be on the collection page
- Workbench: Select the
Lesson 2
project
- Click on
+NEW
and select Run a process
- Select
CWL training lesson 2
from the list and click Next
- Enter a name for this run like “Second training run”
- Click on
#main/message
- A selection dialog box will appear
- Navigate to the collection you created in step (4.4.4) and choose
message.txt
- Click
Run process
- This should take you to a panel showing the workflow run status
- Workbench: workflow run status panel
- Wait for the process to complete
- Click on the dot menu
- Choose
Outputs
- Right click on
reverse.txt
- Click on
Open in new tab
- The results should be visible in a new browser tab.
The default value for the message
parameter will taken from the lesson3/defaults.yaml
file
- Vscode: Click on the
lesson3/main.cwl
file
- Click on the
Terminal
menu
- Click
Run Task…
- Select
Register or update CWL workflow on Arvados Workbench
- Workbench: Go to
+NEW
and select New project
- Enter a name for the project like “Lesson 3”
- You should arrive at the panel for the new project
- Workbench: With
Lesson 3
selected
- Click on
+NEW
and select Run a process
- Select
CWL training lesson 3
from the list and click Next
- Enter a name for this run like “Third training run”
- The
#main/message
parameter will be pre-filled with your default value. You can choose to change it or use the default.
- Click
Run process
- This should take you to the status page for this workflow
- The greeting will appear in the
Log
of the echo
task, which
can be found the same way as described earlier in section 3.
6. Run a workflow without registering it
The message
parameter will be taken from the file lesson4/main-input.yaml
. This is useful during development.
- Workbench: Go to
+NEW
and select New project
- Enter a name for the project like “Lesson 4”
- You should arrive at the panel for the new project
- Click on
Additional info
in the upper right to expand the info
panel
- Under
Project UUID
click the Copy to clipboard
button
- Vscode: Select the file
lesson4/main.cwl
- Click on the
Terminal
menu
- Click
Run Task…
- Select
Set Arvados project UUID
- Paste the project UUID from workbench at the prompt
- Vscode: Select the file
lesson4/main.cwl
- Click on the
Terminal
menu
- Click
Run Task…
- Select
Run CWL workflow on Arvados
- Vscode: In the bottom panel select the
Terminal
tab
- In the upper right corner of the Terminal tab select
Task - Run CWL Workflow
from the drop-down
- Look for logging text like
submitted container_request zzzzz-xvhdp-0123456789abcde
- Highlight and copy the workflow identifier (this the string containing
-xvhdp-
in the middle)
- The results of this run will appear in the terminal when the run completes.
- Workbench: Paste the workflow identifier into the search box
- This will take you to the status page for this workflow
Notes
If you need to change something about the environment of the user on
the remote host (for example, the user has been added to a new unix
group) you need to restart the vscode server that runs on the remote
host. Do this in vscode:
ctrl+shift+p: Remote-SSH: Kill VS Code Server on Host
This is because the vscode server remains running on the remote host
even after you disconnect, so exiting/restarting vscode on the desktop
has no effect.
Previous: Getting Started with CWL
Next: Working with container images