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