Skip to content

Commit 85e7b0e

Browse files
authored
Merge pull request #137 from djarecka/tutorial_keywords
removing splitter and combiner kwargs in tutorial
2 parents 27db9dc + 00c1603 commit 85e7b0e

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

tutorial/notebooks/intro_task_state.ipynb

+35-23
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"metadata": {},
6363
"outputs": [],
6464
"source": [
65-
"task1.split(splitter=\"x\")"
65+
"task1.split(\"x\")"
6666
]
6767
},
6868
{
@@ -153,6 +153,25 @@
153153
"![nd_spl_1.png](attachment:nd_spl_1.png)"
154154
]
155155
},
156+
{
157+
"cell_type": "markdown",
158+
"metadata": {},
159+
"source": [
160+
"Note, that you can set the`splitter` only once, if you try to use `split` method again, you will get an error:"
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": null,
166+
"metadata": {},
167+
"outputs": [],
168+
"source": [
169+
"try:\n",
170+
" task1.split(\"x\")\n",
171+
"except(Exception) as err:\n",
172+
" print(f\"Exception: {err}\")"
173+
]
174+
},
156175
{
157176
"cell_type": "markdown",
158177
"metadata": {},
@@ -186,7 +205,7 @@
186205
"metadata": {},
187206
"outputs": [],
188207
"source": [
189-
"task2 = add_var(a=[1, 2, 3], b=10).split(splitter=\"a\")\n",
208+
"task2 = add_var(a=[1, 2, 3], b=10).split(\"a\")\n",
190209
"task2()\n",
191210
"task2.result()"
192211
]
@@ -250,7 +269,7 @@
250269
"metadata": {},
251270
"outputs": [],
252271
"source": [
253-
"task3.split(splitter=(\"a\", \"b\"))\n",
272+
"task3.split((\"a\", \"b\"))\n",
254273
"task3()\n",
255274
"task3.result()"
256275
]
@@ -292,7 +311,7 @@
292311
"outputs": [],
293312
"source": [
294313
"task4 = add_var(a=[1, 2], b=[10, 100])\n",
295-
"task4.split(splitter=[\"a\", \"b\"])\n",
314+
"task4.split([\"a\", \"b\"])\n",
296315
"task4()\n",
297316
"task4.result()"
298317
]
@@ -367,9 +386,9 @@
367386
"outputs": [],
368387
"source": [
369388
"task5 = add_var(a=[1, 2], b=[10, 100])\n",
370-
"task5.split(splitter=[\"a\", \"b\"])\n",
389+
"task5.split([\"a\", \"b\"])\n",
371390
"# adding combiner\n",
372-
"task5.combine(combiner=\"b\")\n",
391+
"task5.combine(\"b\")\n",
373392
"task5()\n",
374393
"task5.result()"
375394
]
@@ -407,9 +426,9 @@
407426
"outputs": [],
408427
"source": [
409428
"task6 = add_var(a=[1, 2], b=[10, 100])\n",
410-
"task6.split(splitter=[\"a\", \"b\"])\n",
429+
"task6.split([\"a\", \"b\"])\n",
411430
"# changing the combiner\n",
412-
"task6.combine(combiner=\"a\")\n",
431+
"task6.combine(\"a\")\n",
413432
"task6()\n",
414433
"task6.result()"
415434
]
@@ -447,9 +466,9 @@
447466
"outputs": [],
448467
"source": [
449468
"task7 = add_var(a=[1, 2], b=[10, 100])\n",
450-
"task7.split(splitter=[\"a\", \"b\"])\n",
469+
"task7.split([\"a\", \"b\"])\n",
451470
"# combining all inputs\n",
452-
"task7.combine(combiner=[\"a\", \"b\"])\n",
471+
"task7.combine([\"a\", \"b\"])\n",
453472
"task7()\n",
454473
"task7.result()"
455474
]
@@ -524,7 +543,7 @@
524543
},
525544
"outputs": [],
526545
"source": [
527-
"task_ex1 = power(x=[2, 3, 4, 5], n=[2, 3]).split(splitter=[\"x\", \"n\"]).combine(\"x\")\n",
546+
"task_ex1 = power(x=[2, 3, 4, 5], n=[2, 3]).split([\"x\", \"n\"]).combine(\"x\")\n",
528547
"task_ex1(plugin=\"cf\")\n",
529548
"task_ex1.result()"
530549
]
@@ -575,7 +594,7 @@
575594
" time.sleep(1)\n",
576595
" return x + 2\n",
577596
"\n",
578-
"task8 = add_two_sleep(x=[1, 2, 3, 4]).split(splitter=\"x\")\n",
597+
"task8 = add_two_sleep(x=[1, 2, 3, 4]).split(\"x\")\n",
579598
"t0 = time.time()\n",
580599
"task8()\n",
581600
"print(f'total time: {time.time() - t0}')\n",
@@ -599,7 +618,7 @@
599618
"metadata": {},
600619
"outputs": [],
601620
"source": [
602-
"task9 = add_two_sleep(x=[1, 2, 3, 4]).split(splitter=\"x\")\n",
621+
"task9 = add_two_sleep(x=[1, 2, 3, 4]).split(\"x\")\n",
603622
"\n",
604623
"t0 = time.time()\n",
605624
"with pydra.Submitter(plugin=\"cf\") as sub:\n",
@@ -621,7 +640,7 @@
621640
"metadata": {},
622641
"outputs": [],
623642
"source": [
624-
"task10 = add_two_sleep(x=[1, 2, 3, 4]).split(splitter=\"x\")\n",
643+
"task10 = add_two_sleep(x=[1, 2, 3, 4]).split(\"x\")\n",
625644
"\n",
626645
"t0 = time.time()\n",
627646
"task10(plugin=\"cf\")\n",
@@ -642,7 +661,7 @@
642661
"metadata": {},
643662
"outputs": [],
644663
"source": [
645-
"task11 = add_two_sleep(x=[1, 2, 3, 4]).split(splitter=\"x\")\n",
664+
"task11 = add_two_sleep(x=[1, 2, 3, 4]).split(\"x\")\n",
646665
"\n",
647666
"t0 = time.time()\n",
648667
"with pydra.Submitter(plugin=\"cf\") as sub:\n",
@@ -664,7 +683,7 @@
664683
"metadata": {},
665684
"outputs": [],
666685
"source": [
667-
"task12 = add_two_sleep(x=[1, 2, 3, 4]).split(splitter=\"x\")\n",
686+
"task12 = add_two_sleep(x=[1, 2, 3, 4]).split(\"x\")\n",
668687
"\n",
669688
"t0 = time.time()\n",
670689
"with pydra.Submitter(plugin=\"cf\", n_procs=2) as sub:\n",
@@ -680,13 +699,6 @@
680699
"Now, the total time could be significantly different. For example, if your machine has at least 4 processors, the previous `tasks8` - `task11` took around 1s to run, but the task12 took around 2s.\n",
681700
"If you have 2 processors or less, you should not see any difference in the execution time."
682701
]
683-
},
684-
{
685-
"cell_type": "code",
686-
"execution_count": null,
687-
"metadata": {},
688-
"outputs": [],
689-
"source": []
690702
}
691703
],
692704
"metadata": {

tutorial/notebooks/intro_workflow.ipynb

+4-11
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
"source": [
374374
"wf6 = pydra.Workflow(name=\"wf6\", input_spec=[\"x\"])\n",
375375
"# setting a plitter for the entire workflow\n",
376-
"wf6.split(splitter=\"x\", x=[3, 5])\n",
376+
"wf6.split(\"x\", x=[3, 5])\n",
377377
"wf6.add(add_two(name=\"add_two\", x=wf6.lzin.x))\n",
378378
"wf6.add(power(name=\"power\", a=wf6.lzin.x))\n",
379379
"wf6.add(mult_var(name=\"mult\", a=wf6.add_two.lzout.out, b=wf6.power.lzout.out))\n",
@@ -421,7 +421,7 @@
421421
"outputs": [],
422422
"source": [
423423
"wf7 = pydra.Workflow(name=\"wf7\", input_spec=[\"x\", \"y\"])\n",
424-
"wf7.split(splitter=[\"x\", \"y\"], x=[3, 5], y=[2, 3])\n",
424+
"wf7.split([\"x\", \"y\"], x=[3, 5], y=[2, 3])\n",
425425
"wf7.add(add_two(name=\"sum\", x=wf7.lzin.x))\n",
426426
"wf7.add(power(name=\"power\", a=wf7.lzin.y))\n",
427427
"wf7.add(mult_var(name=\"mult\", a=wf7.sum.lzout.out, b=wf7.power.lzout.out))\n",
@@ -468,7 +468,7 @@
468468
"metadata": {},
469469
"outputs": [],
470470
"source": [
471-
"wf7.combine(combiner=\"x\")\n",
471+
"wf7.combine(\"x\")\n",
472472
"\n",
473473
"with pydra.Submitter(plugin=\"cf\") as sub:\n",
474474
" sub(wf7)\n",
@@ -519,7 +519,7 @@
519519
"wf8 = pydra.Workflow(name=\"wf8\", input_spec=[\"x\"], x=[3, 5, 7])\n",
520520
"wf8.add(mean(name=\"mean\", x_list=wf8.lzin.x))\n",
521521
"# adding a task that has its own splitter\n",
522-
"wf8.add(power(name=\"power\", a=wf8.lzin.x).split(splitter=\"a\"))\n",
522+
"wf8.add(power(name=\"power\", a=wf8.lzin.x).split(\"a\"))\n",
523523
"\n",
524524
"wf8.set_output([(\"out_m\", wf8.mean.lzout.out),\n",
525525
" (\"out_p\", wf8.power.lzout.out)])\n",
@@ -548,13 +548,6 @@
548548
"source": [
549549
"![wf_9.png](attachment:wf_9.png)"
550550
]
551-
},
552-
{
553-
"cell_type": "code",
554-
"execution_count": null,
555-
"metadata": {},
556-
"outputs": [],
557-
"source": []
558551
}
559552
],
560553
"metadata": {

0 commit comments

Comments
 (0)