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