3c66c19e4434aeda5bf07c97db189be607f6bca9
[arvados-vscode-cwl-training.git] / README.md
1 These lessons give step by step instructions for using Visual Studio
2 Code (abbreviated "vscode") to develop CWL workflows on Arvados.
3
4 1. Set up SSH
5 1. Install vscode and necessary extensions
6 1. Use vscode to connect to an Arvados shell node for development
7 1. Create an simple command line tool, run it, and view the log
8 1. Upload input, create a command line tool to process it, and view the output
9
10 ## SSH Setup
11
12 1. (Windows only) Install git for windows [https://git-scm.com/download/win](https://git-scm.com/download/win)
13 1. Open bash shell (installed with git for Windows)
14    1. Shell: Run `ssh-keygen`
15    1. Shell: Look for `Your public key has been saved in /c/Users/MyUsername/.ssh/id_rsa.pub`
16    1. Shell: Run `cat /c/Users/MyUsername/.ssh/id_rsa.pub`
17    1. Shell: Highlight and copy the lines starting with `ssh-rsa …`
18 1. Open Arvados workbench
19    1. Workbench: Go to `SSH keys` in the user menu
20    1. Workbench:Click `+Add new ssh key`
21    1. Workbench: Paste the key into "Public key" and enter something for "name"
22    1. Workbench: Go to `Virtual Machines` in the user menu
23    1. Workbench: Highlight and copy the value in in the "Command line" column.
24 1. At the git bash command line
25    1. Shell: paste the `ssh shell…` command line you got from workbench.
26    1. Shell: type “yes` if it asks “do you want to continue connecting`
27    1. Shell: You should now be logged into the Arvados shell node.  Note:
28       it can take up to two minutes for the SSH key to be copied to
29       the shell node.  If it doesn't work the first time, wait 60
30       seconds and try again.
31    1. Shell: Log out by typing `exit`
32
33 ## VSCode setup
34
35 1. Install [Visual Studio Code](https://code.visualstudio.com/) and start it up
36 1. Vscode: go to `Extensions`
37    1. search for "remote development` and install the Remote Development extension pack from Microsoft
38 1. Vscode: On the left side bar, choose `Remote explorer`
39    1. In the drop down, choose `SSH targets`
40    1. Click `Add new`
41    1. Enter the `ssh shell…`` command line you used for SSH Setup step 4.1
42    1. Right click the ssh target in the list and select “connect to host in current window`
43 1. Vscode: go to `Extensions`
44    1. Search for `benten` and install `CWL (Rabix/Benten)`
45    1. Choose `Install extension on the remote ssh host`
46 1. Vscode: On the left side bar, choose `Explorer`
47    1. Select `Clone Repository` and then enter [https://github.com/arvados/arvados-vscode-cwl-training](https://github.com/arvados/arvados-vscode-cwl-training)
48    1. Choose `Open`
49 1. Go to Arvados Workbench
50    1. Workbench: In the user menu, select `Current token`
51    1. Vscode: Click on the `Terminal` menu
52    1. Vscode: Click `Run Task…`
53    1. Vscode: Select `Configure Arvados`
54    1. Workbench: Copy the string following `ARVADOS_API_HOST=`
55    1. Vscode: Paste the string at the `Value for ARVADOS_API_HOST` prompt
56    1. Workbench: Copy the string following `ARVADOS_API_TOKEN=`
57    1. Vscode: Paste the string at the `Value for ARVADOS_API_TOKEN` prompt
58
59 # Register & run a workflow
60
61 1. Vscode: Click on the `lesson1/main.cwl` file
62    1. Click on the `Terminal` menu
63    1. Click `Run Task…`
64    1. Select `Register or update CWL workflow on Arvados Workbench`
65 1. Workbench: Go to `+NEW` and select `New project`
66    1. Enter a name for the project like "Lesson 1"
67    1. You should arrive at the panel for the new project
68 1. Workbench: With `Lesson 1` selected
69    1. Click on `+NEW` and select `Run a process`
70    1. Select `CWL training lesson 1` from the list and click `Next`
71    1. Enter a name for this run like `First training run`
72    1. Enter a message (under `#main/message`) like `Hello world`
73    1. Click `Run process`
74    1. This should take you to a panel showing the workflow run status
75 1. Workbench: workflow run status panel
76    1. Click on the three vertical dots in the top-right corner
77    1. Choose `Log`
78    1. Under `event type` choose `stdout`
79    1. You should see your message
80
81 ## Working with input and output files
82
83 1. Vscode: Click on the `lesson2/main.cwl` file
84    1. Click on the `Terminal` menu
85    1. Click `Run Task…`
86    1. Select `Register or update CWL workflow on Arvados Workbench`
87 1. Go to your desktop
88    1. Using a text editor such as notepad, create a file `message.txt`
89    1. Enter a message like `Hello world` and save
90 1. Workbench: Go to `+NEW` and select `New project`
91    1. Enter a name for the project like `Lesson 2`
92    1. You should arrive at the panel for the new project
93 1. Arvados workbench: With `Lesson 2` project selected
94    1. Click on +NEW and select `New collection`
95    1. Call the collection `my message`
96    1. Drag and drop `message.txt` into the browser
97    1. Click `Create a collection`
98    1. The file should be uploaded and then you will be on the collection page
99 1. Workbench: Select the `Lesson 2` project
100    1. Click on `+NEW` and select `Run a process`
101    1. Select `CWL training lesson 2` from the list and click `Next`
102    1. Enter a name for this run like `Second training run`
103    1. Click on `#main/message`
104    1. A selection dialog box will appear
105    1. Navigate to the collection you created in step (13) and choose `message.txt`
106    1. Click `Run process`
107    1. This should take you to a panel showing the workflow run status
108 1. Workbench: workflow run status panel
109    1. Wait for the process to complete
110    1. Click on the dot menu
111    1. Choose `Outputs`
112    1. Right click on `reverse.txt`
113    1. Click on `Download`
114    1. Open the downloaded file.  It should have your results.
115
116 ## Register a workflow with default inputs
117
118 The default value for the `message` parameter will taken from the `lesson3/defaults.yaml` file
119
120 1. Workbench: Go to `+NEW` and select `New project`
121    1. Enter a name for the project like `Lesson 3`
122    1. You should arrive at the panel for the new project
123 1. Workbench: With `Lesson 3` selected
124    1. Click on `+NEW` and select `Run a process`
125    1. Select `CWL training lesson 3` from the list and click `Next`
126    1. Enter a name for this run like `Third training run`
127    1. The `#main/message` parameter will be pre-filled with your default value.  You can choose to change it or use the default.
128    1. Click `Run process`
129    1. This should take you to the status page for this workflow
130
131 ## Run a workflow without registering it
132
133 The `message` parameter will be taken from the file `lesson4/main-input.yaml`.  This is useful during development.
134
135 1. Workbench: Go to `+NEW` and select `New project`
136    1. Enter a name for the project like `Lesson 4`
137    1. You should arrive at the panel for the new project
138    1. Click on `Additional info` in the upper right to expand the `info` panel
139    1. Under `Project UUID` click the `Copy to clipboard` button
140 1. Vscode: Select the file `lesson4/main.cwl`
141    1. Click on the `Terminal` menu
142    1. Click `Run Task…`
143    1. Select `Set Arvados project UUID`
144    1. Paste the project UUID from workbench at the prompt
145 1. Vscode: Select the file `lesson4/main.cwl`
146    1. Click on the `Terminal` menu
147    1. Click `Run Task…`
148    1. Select `Run CWL workflow on Arvados`
149 1. Vscode: In the bottom panel select the `Terminal` tab
150    1. In the upper right corner of the Terminal tab select `Task - Run CWL Workflow` from the drop-down
151    1. Look for logging text like `submitted container_request zzzzz-xvhdp-0123456789abcde`
152    1. Highlight and copy the workflow identifier (this the string containing -xvhdp- in the middle)
153    1. The results of this run will appear in the terminal when the run completes.
154 1. Workbench: Paste the workflow identifier into the search box
155    1. This will take you to the status page for this workflow