|
| 1 | +## 1. Use Seqera Platform to capture and monitor Nextflow jobs launched from the CLI |
| 2 | + |
| 3 | +We'll start by using the Nextflow CLI to launch a pipeline and monitor it in Seqera Platform. |
| 4 | +Start by logging into the [Seqera Platform](https://cloud.seqera.io/). |
| 5 | + |
| 6 | +!!! info "Nextflow Tower" |
| 7 | + |
| 8 | + Seqera Platform was previously known as Nextflow Tower. |
| 9 | + You'll still see references to the previous name in environment variables and CLI option names. |
| 10 | + |
| 11 | +### 1.1. Set up your Seqera Platform token by exporting it to your environment |
| 12 | + |
| 13 | +Follow these steps to set up your token: |
| 14 | + |
| 15 | +1. Create a new token by clicking on the **Settings** drop-down menu: |
| 16 | + |
| 17 | +  |
| 18 | + |
| 19 | +2. Name your token: |
| 20 | + |
| 21 | +  |
| 22 | + |
| 23 | +3. Save your token safely: |
| 24 | + |
| 25 | +  |
| 26 | + |
| 27 | + !!! note |
| 28 | + |
| 29 | + Leave the browser tab with the token open as we will need it once more to store it as a Nextflow secret. |
| 30 | + |
| 31 | +4. To make your token available to the Nextflow CLI, export it on the command line: |
| 32 | + |
| 33 | + Open a terminal and type: |
| 34 | + |
| 35 | + ```bash |
| 36 | + export TOWER_ACCESS_TOKEN=eyxxxxxxxxxxxxxxxQ1ZTE= |
| 37 | + ``` |
| 38 | + |
| 39 | + Where `eyxxxxxxxxxxxxxxxQ1ZTE=` is the token you have just created. |
| 40 | + |
| 41 | + !!! Warning "Security Note" |
| 42 | + |
| 43 | + Keep your token secure and do not share it with others. |
| 44 | + You can add a ++space++ before the `export` command to prevent it from being saved in your shell history. |
| 45 | + |
| 46 | +### 1.2. Run Nextflow CLI with Seqera Platform visualizing and capturing logs |
| 47 | + |
| 48 | +Run a Nextflow workflow with the addition of the `-with-tower` command: |
| 49 | + |
| 50 | +```bash |
| 51 | +nextflow run nextflow-io/hello -with-tower |
| 52 | +``` |
| 53 | + |
| 54 | +You will see output similar to the following: |
| 55 | + |
| 56 | +```console title="Output" |
| 57 | + N E X T F L O W ~ version 24.04.4 |
| 58 | +
|
| 59 | +Launching `https://github.com/nextflow-io/hello` [evil_engelbart] DSL2 - revision: afff16a9b4 [master] |
| 60 | +
|
| 61 | +Downloading plugin [email protected] |
| 62 | +Monitor the execution with Seqera Platform using this URL: https://cloud.seqera.io/user/kenbrewer/watch/5Gs0qqV9Y9rguE |
| 63 | +executor > local (4) |
| 64 | +[80/810411] process > sayHello (1) [100%] 4 of 4 ✔ |
| 65 | +Ciao world! |
| 66 | +
|
| 67 | +Bonjour world! |
| 68 | +
|
| 69 | +Hola world! |
| 70 | +
|
| 71 | +Hello world! |
| 72 | +``` |
| 73 | + |
| 74 | +Hold ++ctrl++ or ++cmd++ and click on the link to open it in your browser. |
| 75 | +You'll see the Seqera Platform interface with the job finished and the logs captured. |
| 76 | +
|
| 77 | + |
| 78 | +
|
| 79 | +You will see and be able to monitor your **Nextflow jobs** in Seqera Platform. |
| 80 | +
|
| 81 | +### 1.3. Set up Seqera Platform in Nextflow configuration |
| 82 | +
|
| 83 | +Doing that token setup regularly can get a bit tedious, so let's set this configuration for all our pipeline runs with the global Nextflow configuration file located at `$HOME/.nextflow/config`. |
| 84 | + |
| 85 | +Before we set the configuration, we need to permanently store the token in Nextflow using a [Nextflow secret](https://www.nextflow.io/docs/latest/secrets.html): |
| 86 | + |
| 87 | +```bash |
| 88 | +nextflow secrets set tower_access_token "eyxxxxxxxxxxxxxxxQ1ZTE=" |
| 89 | +``` |
| 90 | + |
| 91 | +Open the Nextflow configuration file located at `$HOME/.nextflow/config`: |
| 92 | + |
| 93 | +```bash |
| 94 | +code $HOME/.nextflow/config |
| 95 | +``` |
| 96 | + |
| 97 | +Then add the following block of configuration: |
| 98 | + |
| 99 | +```groovy title="$HOME/.nextflow/config" |
| 100 | +tower { |
| 101 | + enabled = true |
| 102 | + endpoint = "https://api.cloud.seqera.io" |
| 103 | + accessToken = secrets.tower_access_token |
| 104 | + workspaceId = secrets.tower_workspace_id |
| 105 | +} |
| 106 | +``` |
| 107 | + |
| 108 | +!!! hint "Workspace ID and Endpoint" |
| 109 | + |
| 110 | + We haven't set `secrets.tower_workspace_id` yet, and so Nextflow will fill in an empty string for this value. |
| 111 | + This will default to the user's workspace in Seqera Platform which is what we want for now. |
| 112 | + |
| 113 | + The `endpoint` is the URL of the Seqera Platform API. |
| 114 | + If your institution is running a private instance of Seqera Platform, you will want to change this to the appropriate URL. |
| 115 | + |
| 116 | +Run your Nextflow workflows as before, but without the `-with-tower` command: |
| 117 | + |
| 118 | +```bash |
| 119 | +nextflow run nextflow-io/hello |
| 120 | +``` |
| 121 | + |
| 122 | +You will see the following output: |
| 123 | + |
| 124 | +```console title="Output" |
| 125 | + N E X T F L O W ~ version 24.04.4 |
| 126 | +
|
| 127 | +Launching `https://github.com/nextflow-io/hello` [fabulous_euclid] DSL2 - revision: afff16a9b4 [master] |
| 128 | +
|
| 129 | +Monitor the execution with Seqera Platform using this URL: https://cloud.seqera.io/user/kenbrewer/watch/KYjRktIlOuxrh |
| 130 | +executor > local (4) |
| 131 | +[71/eaa915] process > sayHello (3) [100%] 4 of 4 ✔ |
| 132 | +Ciao world! |
| 133 | +
|
| 134 | +Bonjour world! |
| 135 | +
|
| 136 | +Hola world! |
| 137 | +
|
| 138 | +Hello world! |
| 139 | +``` |
| 140 | + |
| 141 | +Note that we are logging to Seqera Platform even though we did not use the `-with-tower` command! |
| 142 | + |
| 143 | +### 1.4. Use Seqera Platform to explore the resolved configuration of a Nextflow pipeline |
| 144 | + |
| 145 | +Click on the link provided in the output to open the Seqera Platform for your run, then click on the `Configuration` tab. |
| 146 | +If you ran your pipeline from the `hello_nextflow` directory, you'll see something like this: |
| 147 | +
|
| 148 | + |
| 149 | +
|
| 150 | +Notice that configuration for our pipeline run is being run pulled from three separate files: |
| 151 | +
|
| 152 | +- `/home/gitpod/.nextflow/config` - This is the global configuration file we just added. |
| 153 | +- `/home/gitpod/.nextflow/assets/nextflow-io/hello/nextflow.config` - This is the `nextflow.config` file from the `nextflow-io/hello` repository. |
| 154 | +- `/workspace/gitpod/nf-training/hello-nextflow/nextflow.config` - This is the `nextflow.config` file from our current working directory. |
| 155 | +
|
| 156 | +Nextflow resolves these configurations at runtime with a [specific order of precedence](https://www.nextflow.io/docs/latest/config.html#configuration-file). |
| 157 | +The general rule, however, is that more specific configurations override less specific ones, and config/params specified on the CLI will override defaults in the config files. |
| 158 | +
|
| 159 | +Helpfully, Seqera Platform shows us the final output of this configuration resolution process which can be very useful for debugging! |
| 160 | +
|
| 161 | +### Takeaway |
| 162 | +
|
| 163 | +You have learned how to: |
| 164 | +
|
| 165 | +- Set up your Seqera Platform token by exporting it to your environment. |
| 166 | +- Run Nextflow CLI with Seqera Platform visualizing and capturing logs. |
| 167 | +- Set up Seqera Platform logging by default. |
| 168 | +- Use Seqera Platform to explore the resolved configuration of a Nextflow pipeline. |
| 169 | +
|
| 170 | +### What's next? |
| 171 | + |
| 172 | +Learn how to launch Nextflow pipelines from Seqera Platform using the Launchpad feature. |
0 commit comments