From 59b1b7c7294b7372e05315368049714e93200bc3 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Fri, 20 Mar 2020 18:12:10 +0000 Subject: [PATCH] RF: more little tweaks --- advanced_topics/08_fslpy.ipynb | 36 ++++++++++++++++++++++++---------- advanced_topics/08_fslpy.md | 26 +++++++++++++++--------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/advanced_topics/08_fslpy.ipynb b/advanced_topics/08_fslpy.ipynb index f7d8ee0..3ca6d7d 100644 --- a/advanced_topics/08_fslpy.ipynb +++ b/advanced_topics/08_fslpy.ipynb @@ -1480,7 +1480,23 @@ "outputs": [], "source": [ "jobid = run('ls', submit=True)\n", - "print('Job ID:', jobid)\n", + "print('Job ID:', jobid)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once the job finishes, we shouldd be able to read the usual `.o` and `.e`\n", + "files:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "stdout = f'ls.o{jobid}'\n", "print('Job output')\n", "print(open(stdout).read())" @@ -1533,9 +1549,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "When you submit a job, instead of passing `submit=True`, you can pass in a\n", - "dict which contains cluster submission options - you can include any arguments\n", - "to the\n", + "When you use `submit=True`, you can also specify cluster submission options -\n", + "you can include any arguments to the\n", "[`fslsub.submit`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.utils.fslsub.html#fsl.utils.fslsub.submit)\n", "function:" ] @@ -1546,12 +1561,13 @@ "metadata": {}, "outputs": [], "source": [ - "jid = runfsl('robustfov -i 08_fslpy/bighead -r bighead_cropped', submit=dict(queue='short.q'))\n", - "jid = runfsl('bet bighead_cropped bighead_brain', submit=dict(queue='short.q', wait_for=jid))\n", - "jid = runfsl('fslroi bighead_brain bighead_slices 0 -1 111 3 0 -1', submit=dict(queue='short.q', wait_for=jid))\n", - "jid = runfsl('fast -o bighead_fast bighead_slices', submit=dict(queue='short.q', wait_for=jid))\n", - "\n", - "wait(jid)\n", + "jobs = []\n", + "jobs.append(runfsl('robustfov -i 08_fslpy/bighead -r bighead_cropped', submit=True, queue='short.q'))\n", + "jobs.append(runfsl('bet bighead_cropped bighead_brain', submit=True, queue='short.q', wait_for=jobs[-1]))\n", + "jobs.append(runfsl('fslroi bighead_brain bighead_slices 0 -1 111 3 0 -1', submit=True, queue='short.q', wait_for=jobs[-1]))\n", + "jobs.append(runfsl('fast -o bighead_fast bighead_slices', submit=True, queue='short.q', wait_for=jobs[-1]))\n", + "print('Waiting for', jobs, '...')\n", + "wait(jobs)\n", "\n", "render('-vl 80 112 91 -xh -zh -hc '\n", " 'bighead_brain '\n", diff --git a/advanced_topics/08_fslpy.md b/advanced_topics/08_fslpy.md index b59a49a..21f5d74 100644 --- a/advanced_topics/08_fslpy.md +++ b/advanced_topics/08_fslpy.md @@ -1116,6 +1116,14 @@ ID: ``` jobid = run('ls', submit=True) print('Job ID:', jobid) +``` + + +Once the job finishes, we shouldd be able to read the usual `.o` and `.e` +files: + + +``` stdout = f'ls.o{jobid}' print('Job output') print(open(stdout).read()) @@ -1149,20 +1157,20 @@ render('08_fslpy/bighead bighead_brain -cm hot') ``` -When you submit a job, instead of passing `submit=True`, you can pass in a -dict which contains cluster submission options - you can include any arguments -to the +When you use `submit=True`, you can also specify cluster submission options - +you can include any arguments to the [`fslsub.submit`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.utils.fslsub.html#fsl.utils.fslsub.submit) function: ``` -jid = runfsl('robustfov -i 08_fslpy/bighead -r bighead_cropped', submit=dict(queue='short.q')) -jid = runfsl('bet bighead_cropped bighead_brain', submit=dict(queue='short.q', wait_for=jid)) -jid = runfsl('fslroi bighead_brain bighead_slices 0 -1 111 3 0 -1', submit=dict(queue='short.q', wait_for=jid)) -jid = runfsl('fast -o bighead_fast bighead_slices', submit=dict(queue='short.q', wait_for=jid)) - -wait(jid) +jobs = [] +jobs.append(runfsl('robustfov -i 08_fslpy/bighead -r bighead_cropped', submit=True, queue='short.q')) +jobs.append(runfsl('bet bighead_cropped bighead_brain', submit=True, queue='short.q', wait_for=jobs[-1])) +jobs.append(runfsl('fslroi bighead_brain bighead_slices 0 -1 111 3 0 -1', submit=True, queue='short.q', wait_for=jobs[-1])) +jobs.append(runfsl('fast -o bighead_fast bighead_slices', submit=True, queue='short.q', wait_for=jobs[-1])) +print('Waiting for', jobs, '...') +wait(jobs) render('-vl 80 112 91 -xh -zh -hc ' 'bighead_brain ' -- GitLab