From ff3c488405395a186d52ded2bc887efbf689cad4 Mon Sep 17 00:00:00 2001 From: zethson Date: Tue, 22 Aug 2023 15:27:03 +0200 Subject: [PATCH 1/4] :sparkles: Add nextflow execution ID tracking Signed-off-by: zethson --- docs/guide/bulk_rna_seq.ipynb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/guide/bulk_rna_seq.ipynb b/docs/guide/bulk_rna_seq.ipynb index 1cb95cc..b8699e5 100644 --- a/docs/guide/bulk_rna_seq.ipynb +++ b/docs/guide/bulk_rna_seq.ipynb @@ -317,6 +317,38 @@ "To make the count matrix queryable by biological entities (genes, experimental metadata, etc.), we can now proceed with: {doc}`docs:bulkrna`" ] }, + { + "cell_type": "markdown", + "id": "429bf863", + "metadata": {}, + "source": [ + "## Register the Nextflow execution id\n", + "\n", + "If we want to be able to query LaminDB for Nextflow execution ID, this here is a way to get it:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c14e053", + "metadata": {}, + "outputs": [], + "source": [ + "# load the nextflow execution id from the execution_report.html and store it in the LaminDB run record\n", + "# Regular expression pattern to match the Workflow session ID. We will simplify this in the future.\n", + "import re\n", + "\n", + "pattern = r'Workflow session<\\/dt>\\s*
(.*?)<\\/code>'\n", + "with open(\"execution_report.html\", \"r\") as file:\n", + " html_content = file.read()\n", + "match = re.search(pattern, html_content)\n", + "\n", + "run = ln.Run.filter(transform__name=\"nf-core rnaseq\").order_by(\"-run_at\").first()\n", + "run.reference = match.group(1)\n", + "run.reference_type = \"nextflow_id\"\n", + "run.save()" + ] + }, { "cell_type": "markdown", "id": "9f607150", @@ -400,7 +432,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.12" }, "nbproject": { "id": "8124Vtle6ZrO", From 680479a94899407618ad8df3940a2e7af9f3ec7d Mon Sep 17 00:00:00 2001 From: zethson Date: Tue, 22 Aug 2023 15:34:12 +0200 Subject: [PATCH 2/4] :bug: Don't resume Signed-off-by: zethson --- docs/guide/bulk_rna_seq.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/bulk_rna_seq.ipynb b/docs/guide/bulk_rna_seq.ipynb index b8699e5..51b5d5c 100644 --- a/docs/guide/bulk_rna_seq.ipynb +++ b/docs/guide/bulk_rna_seq.ipynb @@ -229,7 +229,7 @@ }, "outputs": [], "source": [ - "!nextflow run nf-core/rnaseq -r 3.11.2 -profile test,docker --outdir rna-seq-results -name {ln.dev.run_context.run.id} -resume" + "!nextflow run nf-core/rnaseq -r 3.11.2 -profile test,docker --outdir rna-seq-results -name {ln.dev.run_context.run.id}" ] }, { From e5ff1c3ed393e4c6f1dcd34f087e82353705f3b0 Mon Sep 17 00:00:00 2001 From: zethson Date: Tue, 22 Aug 2023 16:07:51 +0200 Subject: [PATCH 3/4] :bug: Use nextflow log Signed-off-by: zethson --- docs/guide/bulk_rna_seq.ipynb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/guide/bulk_rna_seq.ipynb b/docs/guide/bulk_rna_seq.ipynb index 51b5d5c..b02a192 100644 --- a/docs/guide/bulk_rna_seq.ipynb +++ b/docs/guide/bulk_rna_seq.ipynb @@ -218,6 +218,16 @@ "All data is now in place and we can run the nextflow pipeline:" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "73f0d174", + "metadata": {}, + "outputs": [], + "source": [ + "ln.dev.run_context.run.id" + ] + }, { "cell_type": "code", "execution_count": null, @@ -334,17 +344,13 @@ "metadata": {}, "outputs": [], "source": [ - "# load the nextflow execution id from the execution_report.html and store it in the LaminDB run record\n", - "# Regular expression pattern to match the Workflow session ID. We will simplify this in the future.\n", - "import re\n", + "import subprocess\n", "\n", - "pattern = r'Workflow session<\\/dt>\\s*
(.*?)<\\/code>'\n", - "with open(\"execution_report.html\", \"r\") as file:\n", - " html_content = file.read()\n", - "match = re.search(pattern, html_content)\n", + "command = f\"nextflow log | grep -F '{ln.dev.run_context.run.id}' | awk '{{print $8}}'\"\n", + "session_id = subprocess.getoutput(command)\n", "\n", "run = ln.Run.filter(transform__name=\"nf-core rnaseq\").order_by(\"-run_at\").first()\n", - "run.reference = match.group(1)\n", + "run.reference = session_id\n", "run.reference_type = \"nextflow_id\"\n", "run.save()" ] From e0594fcfbcd918623bdf2f1aa2477ba0389705f1 Mon Sep 17 00:00:00 2001 From: zethson Date: Tue, 22 Aug 2023 16:33:47 +0200 Subject: [PATCH 4/4] :sparkles: Simplify Signed-off-by: zethson --- docs/guide/bulk_rna_seq.ipynb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/guide/bulk_rna_seq.ipynb b/docs/guide/bulk_rna_seq.ipynb index b02a192..b7ce857 100644 --- a/docs/guide/bulk_rna_seq.ipynb +++ b/docs/guide/bulk_rna_seq.ipynb @@ -218,16 +218,6 @@ "All data is now in place and we can run the nextflow pipeline:" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "73f0d174", - "metadata": {}, - "outputs": [], - "source": [ - "ln.dev.run_context.run.id" - ] - }, { "cell_type": "code", "execution_count": null,