Skip to content

Commit e10d1eb

Browse files
authored
Merge pull request #413 from nextflow-io/feat/hello-seqera
Hello-seqera
2 parents 3ae8fac + a917fe7 commit e10d1eb

15 files changed

+289
-7
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ms-python.vscode-pylance",
2424
"nf-core.nf-core-extensionpack",
2525
"nextflow.nextflow",
26-
"codezombiech.gitignore",
26+
"codezombiech.gitignore"
2727
]
2828
}
2929
},

.github/gitpod.Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ RUN apt-get update --quiet && \
1515
curl \
1616
tree \
1717
graphviz \
18-
software-properties-common
19-
18+
software-properties-common && \
19+
apt-get clean && \
20+
rm -rf /var/lib/apt/lists/*
2021

2122
# Taken from: https://github.com/nf-core/tools/blob/master/nf_core/gitpod/gitpod.Dockerfile
2223
# Install Apptainer (Singularity)
2324
RUN add-apt-repository -y ppa:apptainer/ppa && \
2425
apt-get update --quiet && \
25-
apt install -y apptainer
26+
apt install -y apptainer && \
27+
apt-get clean && \
28+
rm -rf /var/lib/apt/lists/*
2629

2730
# Install Conda
2831
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
@@ -35,6 +38,11 @@ ENV PATH="/opt/conda/bin:$PATH"
3538
RUN mkdir -p /workspace/data \
3639
&& chown -R gitpod:gitpod /opt/conda /workspace/data
3740

41+
# Install Tower Agent
42+
RUN curl -fSL https://github.com/seqeralabs/tower-agent/releases/latest/download/tw-agent-linux-x86_64 > tw-agent && \
43+
chmod +x tw-agent && \
44+
mv tw-agent /usr/local/bin/tw-agent
45+
3846
# Change user to gitpod
3947
USER gitpod
4048

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
---
2+
title: "Part 9: Hello Seqera"
3+
description: Get started with Seqera Platform
4+
---
5+
16
# Part 9: Hello Seqera
27

3-
TODO
8+
So far we've been running Nextflow workflows on our local machine using the command line interface.
9+
In this section, we'll introduce you to Seqera Platform, a powerful cloud-based platform for running, monitoring, and sharing Nextflow workflows.
410

5-
---
11+
!!! tip
12+
13+
[Sign up](https://cloud.seqera.io/) to try Seqera for free or request a [demo](https://seqera.io/demo/) for deployments in your own on-premise or cloud environment.
14+
15+
You'll learn how to use Seqera Platform within Nextflow CLI, the Seqera Platform GUI, and the API.
16+
17+
You can use Seqera Platform via either the **CLI**, through the **online GUI** or through the **API**.
18+
19+
--8<-- "docs/hello_nextflow/seqera/01_run_with_cli.md"
620

7-
TODO
21+
--8<-- "docs/hello_nextflow/seqera/02_run_with_launchpad.md"
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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+
![Create a token](seqera/img/usage_create_token.png)
18+
19+
2. Name your token:
20+
21+
![Name your token](seqera/img/usage_name_token.png)
22+
23+
3. Save your token safely:
24+
25+
![Save token](seqera/img/usage_token.png)
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+
![Seqera Platform](seqera/img/run_with_tower.png)
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+
![Seqera Platform Configuration](seqera/img/resolved_configuration.png)
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.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## 2 Using Seqera Platform Launchpad to run Nextflow workflows
2+
3+
So far we've been running Nextflow workflows on our local machine using the command line interface but sending the logs to Seqera Platform for monitoring and visualization.
4+
Next we want to start using Seqera Platform to launch Nextflow workflows on our behalf.
5+
6+
!!! Note "Community Showcase"
7+
8+
Having a compute environment capable of running Nextflow workflows configured in Seqera Platform is normally a prerequisite for this task.
9+
But we want to see how it works before we put in that effort, so we'll start by launching a job in community/showcase workspace which has a compute environment already set up.
10+
11+
!!! tip "Trainer Tip"
12+
13+
Launch a test run of the nf-core/rnaseq pipeline in the community/showcase workspace prior to starting this session, so you'll have a recent run for participants to inspect.
14+
15+
### 2.1. Navigate to the community/showcase workspace
16+
17+
Seqera Platform has a concept of [**organizations**](https://docs.seqera.io/platform/latest/orgs-and-teams/organizations) and [**workspaces**](https://docs.seqera.io/platform/latest/orgs-and-teams/workspace-management) which are used to organize and share [pipelines](https://docs.seqera.io/platform/latest/launch/launchpad), [compute environments](https://docs.seqera.io/platform/latest/compute-envs/overview), [data](https://docs.seqera.io/platform/latest/data/data-explorer), [credentials](https://docs.seqera.io/platform/latest/credentials/overview), and more.
18+
The `community/showcase` workspace is a public workspace where you can see some example pipelines and compute environments.
19+
Each user has an alloted amount of free compute to use in this workspace.
20+
21+
Click on your username in the top left corner of the screen to bring up the list of organizations and workspaces you have access to.
22+
Select the `community/showcase` workspace.
23+
24+
### 2.2. Launch a test run of nf-core/rnaseq pipeline
25+
26+
In the `community/showcase` workspace, you will see a list of pipelines that have been set up by the workspace owner for you to run.
27+
Follow these steps to launch a test run of a pipeline:
28+
29+
![Launchpad](seqera/img/launchpad.gif)
30+
31+
1. Find the `nf-core-rnaseq` pipeline in the list of pipelines.
32+
2. Click on the `Launch` button to bring up the launch form.
33+
3. Change the "Workflow run name" to "<username>-rnaseq-test".
34+
4. Click "Next" to bring up the parameters form.
35+
5. Find the `trimmer` parameter and change it to `fastp`.
36+
6. Click on "Next" to inspect the advanced configuration.
37+
7. Click "Launch" to start the pipeline!
38+
39+
!!! Tip
40+
41+
In the advanced configuration, you'll see a section named "Pre-run script" with a script similar to the following:
42+
43+
```bash
44+
export NXF_FILE_ROOT=s3://nf-tower-bucket/scratch/$TOWER_WORKFLOW_ID
45+
```
46+
47+
This is what ensures that everyone's pipeline will write to a unique location in cloud storage despite all having the `outdir` parameter set to `./results`.
48+
49+
### 2.3. Monitor the pipeline run
50+
51+
After launching the pipeline, you will be taken to the pipeline run page where you can monitor the progress of the pipeline.
52+
It may take some time for the pipeline to start running while AWS Batch spins up the needed resources, so go to the "Runs" tab above the pipeline and open a recent completed (or failed) run by one of your "teammates" in the community.
53+
54+
### 2.4. Inspect a pipeline run
55+
56+
Scroll down to find the list of tasks that were executed in the pipeline run.
57+
For example, by searching for `fastq` we can find the task `NFCORE_RNASEQ:RNASEQ:FASTQ_FASTQC_UMITOOLS_FASTP:FASTP (WT_REP2)` that was executed as part of the pipeline.
58+
59+
Click on the task to see the task details:
60+
61+
![Task details](seqera/img/task_details.png)
62+
63+
1. Find the following details on the "About" page for the the task you're inspecting:
64+
65+
- [ ] How long did the task script run (not including scheduling time)?
66+
- [ ] How many CPUs were allocated to the task?
67+
- [ ] What was the virtual machine type that the task ran on?
68+
- [ ] What was the estimated cost of the task?
69+
70+
2. Explore the Execution Log tab. What information is available here?
71+
72+
3. Explore the Data Explorer tab. Note that the work directory structure we've seen during local runs is replicated here in cloud storage!
73+
74+
### Takeaway
75+
76+
You have learned how to:
77+
78+
- Switch between organizations and workspaces in Seqera Platform.
79+
- Launch a Nextflow pipeline that ran in the cloud using Seqera Platform.
80+
- Monitor the progress of the pipeline run.
81+
- Inspect the details of a task that was executed as part of the pipeline.
82+
83+
### Next steps
84+
85+
In the next section, we will learn how to set up a compute environment in Seqera Platform to run our own Nextflow workflows.
Loading
12.4 MB
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)