Skip to content

Commit 8004ad7

Browse files
committed
Add dummy retro prov return to execute()
1 parent 8ec9cb7 commit 8004ad7

2 files changed

Lines changed: 53 additions & 78 deletions

File tree

examples/noodles_fw.ipynb

Lines changed: 43 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "designed-spoke",
5+
"id": "characteristic-renaissance",
66
"metadata": {},
77
"source": [
88
"# FairWorkflows execution demo"
99
]
1010
},
1111
{
1212
"cell_type": "markdown",
13-
"id": "secure-render",
13+
"id": "auburn-korea",
1414
"metadata": {},
1515
"source": [
1616
"## Define the steps of your workflow\n",
@@ -19,8 +19,8 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": 9,
23-
"id": "spiritual-order",
22+
"execution_count": 1,
23+
"id": "natural-hunger",
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
@@ -29,8 +29,8 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 10,
33-
"id": "wired-bibliography",
32+
"execution_count": 2,
33+
"id": "rational-retro",
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
@@ -42,8 +42,8 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"execution_count": 11,
46-
"id": "brilliant-thumb",
45+
"execution_count": 3,
46+
"id": "forward-fundamentals",
4747
"metadata": {},
4848
"outputs": [],
4949
"source": [
@@ -55,8 +55,8 @@
5555
},
5656
{
5757
"cell_type": "code",
58-
"execution_count": 12,
59-
"id": "interested-margin",
58+
"execution_count": 4,
59+
"id": "ahead-devices",
6060
"metadata": {},
6161
"outputs": [],
6262
"source": [
@@ -68,8 +68,8 @@
6868
},
6969
{
7070
"cell_type": "code",
71-
"execution_count": 13,
72-
"id": "closing-vatican",
71+
"execution_count": 5,
72+
"id": "metric-referral",
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
@@ -82,7 +82,7 @@
8282
},
8383
{
8484
"cell_type": "markdown",
85-
"id": "centered-nowhere",
85+
"id": "european-viking",
8686
"metadata": {},
8787
"source": [
8888
"## Define your workflow using @fairworkflow\n",
@@ -91,8 +91,8 @@
9191
},
9292
{
9393
"cell_type": "code",
94-
"execution_count": 14,
95-
"id": "paperback-recycling",
94+
"execution_count": 6,
95+
"id": "atmospheric-granny",
9696
"metadata": {},
9797
"outputs": [],
9898
"source": [
@@ -109,16 +109,16 @@
109109
},
110110
{
111111
"cell_type": "markdown",
112-
"id": "sustained-sweden",
112+
"id": "intimate-correction",
113113
"metadata": {},
114114
"source": [
115115
"## Create an instance of your workflow and display it"
116116
]
117117
},
118118
{
119119
"cell_type": "code",
120-
"execution_count": 15,
121-
"id": "noted-aviation",
120+
"execution_count": 7,
121+
"id": "hazardous-nancy",
122122
"metadata": {},
123123
"outputs": [
124124
{
@@ -127,7 +127,7 @@
127127
"fairworkflows.fairworkflow.FairWorkflow"
128128
]
129129
},
130-
"execution_count": 15,
130+
"execution_count": 7,
131131
"metadata": {},
132132
"output_type": "execute_result"
133133
}
@@ -139,8 +139,8 @@
139139
},
140140
{
141141
"cell_type": "code",
142-
"execution_count": 16,
143-
"id": "confirmed-hudson",
142+
"execution_count": 8,
143+
"id": "under-costa",
144144
"metadata": {},
145145
"outputs": [
146146
{
@@ -164,17 +164,17 @@
164164
},
165165
{
166166
"cell_type": "markdown",
167-
"id": "outside-glance",
167+
"id": "informal-cosmetic",
168168
"metadata": {},
169169
"source": [
170170
"## Execute your workflow using .execute()\n",
171-
"Set num_threads greater than 1 if you wish to exploit parallelisation in your workflow."
171+
"Set num_threads greater than 1 if you wish to exploit parallelisation in your workflow. A separate RetroProv object is also returned that can (optionally) be published as a nanopublication. This is not yet implemented, pending one of the RDF tasks set out in the planning document."
172172
]
173173
},
174174
{
175175
"cell_type": "code",
176-
"execution_count": 13,
177-
"id": "front-abuse",
176+
"execution_count": 14,
177+
"id": "baking-perspective",
178178
"metadata": {},
179179
"outputs": [
180180
{
@@ -183,50 +183,19 @@
183183
"-66"
184184
]
185185
},
186-
"execution_count": 13,
186+
"execution_count": 14,
187187
"metadata": {},
188188
"output_type": "execute_result"
189189
}
190190
],
191191
"source": [
192-
"answer = fw.execute(num_threads=2)\n",
193-
"answer"
194-
]
195-
},
196-
{
197-
"cell_type": "markdown",
198-
"id": "compound-shepherd",
199-
"metadata": {},
200-
"source": [
201-
"## Get retrospective provenance of run\n",
202-
"This is not in RDF format yet, but we have all the information needed."
203-
]
204-
},
205-
{
206-
"cell_type": "code",
207-
"execution_count": 12,
208-
"id": "comprehensive-finland",
209-
"metadata": {},
210-
"outputs": [
211-
{
212-
"ename": "AttributeError",
213-
"evalue": "'FairWorkflow' object has no attribute 'prov'",
214-
"output_type": "error",
215-
"traceback": [
216-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
217-
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
218-
"\u001b[0;32m<ipython-input-12-fa58d0e49b7b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprov\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
219-
"\u001b[0;31mAttributeError\u001b[0m: 'FairWorkflow' object has no attribute 'prov'"
220-
]
221-
}
222-
],
223-
"source": [
224-
"fw.prov()"
192+
"result, prov = fw.execute(num_threads=2)\n",
193+
"result"
225194
]
226195
},
227196
{
228197
"cell_type": "markdown",
229-
"id": "precious-domain",
198+
"id": "attached-spirit",
230199
"metadata": {},
231200
"source": [
232201
"## Get Plex RDF of workflow"
@@ -235,7 +204,7 @@
235204
{
236205
"cell_type": "code",
237206
"execution_count": null,
238-
"id": "concerned-massage",
207+
"id": "fifteen-floating",
239208
"metadata": {},
240209
"outputs": [],
241210
"source": [
@@ -244,102 +213,102 @@
244213
},
245214
{
246215
"cell_type": "raw",
247-
"id": "continent-editing",
216+
"id": "cooked-ridge",
248217
"metadata": {},
249218
"source": []
250219
},
251220
{
252221
"cell_type": "code",
253222
"execution_count": null,
254-
"id": "capital-minority",
223+
"id": "governing-gauge",
255224
"metadata": {},
256225
"outputs": [],
257226
"source": []
258227
},
259228
{
260229
"cell_type": "code",
261230
"execution_count": null,
262-
"id": "smoking-lebanon",
231+
"id": "ultimate-setup",
263232
"metadata": {},
264233
"outputs": [],
265234
"source": []
266235
},
267236
{
268237
"cell_type": "code",
269238
"execution_count": null,
270-
"id": "controversial-control",
239+
"id": "distant-distance",
271240
"metadata": {},
272241
"outputs": [],
273242
"source": []
274243
},
275244
{
276245
"cell_type": "code",
277246
"execution_count": null,
278-
"id": "alternate-template",
247+
"id": "opening-duration",
279248
"metadata": {},
280249
"outputs": [],
281250
"source": []
282251
},
283252
{
284253
"cell_type": "code",
285254
"execution_count": null,
286-
"id": "ecological-divorce",
255+
"id": "constitutional-stand",
287256
"metadata": {},
288257
"outputs": [],
289258
"source": []
290259
},
291260
{
292261
"cell_type": "code",
293262
"execution_count": null,
294-
"id": "liberal-queen",
263+
"id": "celtic-cookbook",
295264
"metadata": {},
296265
"outputs": [],
297266
"source": []
298267
},
299268
{
300269
"cell_type": "code",
301270
"execution_count": null,
302-
"id": "specific-humanitarian",
271+
"id": "phantom-cowboy",
303272
"metadata": {},
304273
"outputs": [],
305274
"source": []
306275
},
307276
{
308277
"cell_type": "code",
309278
"execution_count": null,
310-
"id": "thick-budapest",
279+
"id": "controlled-premium",
311280
"metadata": {},
312281
"outputs": [],
313282
"source": []
314283
},
315284
{
316285
"cell_type": "code",
317286
"execution_count": null,
318-
"id": "italic-color",
287+
"id": "artistic-quantity",
319288
"metadata": {},
320289
"outputs": [],
321290
"source": []
322291
},
323292
{
324293
"cell_type": "code",
325294
"execution_count": null,
326-
"id": "respiratory-netscape",
295+
"id": "magnetic-lesbian",
327296
"metadata": {},
328297
"outputs": [],
329298
"source": []
330299
},
331300
{
332301
"cell_type": "code",
333302
"execution_count": null,
334-
"id": "marked-shark",
303+
"id": "alpine-ethnic",
335304
"metadata": {},
336305
"outputs": [],
337306
"source": []
338307
},
339308
{
340309
"cell_type": "code",
341310
"execution_count": null,
342-
"id": "material-robertson",
311+
"id": "indoor-dating",
343312
"metadata": {},
344313
"outputs": [],
345314
"source": []

fairworkflows/fairworkflow.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,16 @@ def execute(self, num_threads=1):
350350
if not hasattr(self, 'noodles_promise'):
351351
raise ValueError('Cannot execute workflow as no noodles promise has been constructed.')
352352
import noodles
353-
if num_threads==1:
354-
return noodles.run_single(self.noodles_promise)
355-
elif num_threads>1:
356-
return noodles.run_parallel(self.noodles_promise, num_threads)
353+
result = noodles.run_parallel(self.noodles_promise, num_threads)
354+
retroprov = """Not implemented yet. The sort of info we have looks like
355+
2021-01-19 13:16:44,750 - job 217: mul(22, -3) -> -66
356+
2021-01-19 13:16:44,750 - job 218: weird(5, 3) -> 22
357+
2021-01-19 13:16:44,750 - job 219: add(1, 4) -> 5
358+
2021-01-19 13:16:44,750 - job 220: sub(1, 4) -> -3
359+
2021-01-19 13:16:44,755 - result mul(22, -3) -> -66]: -66
360+
2021-01-19 13:16:44,755 - -end-of-queue-"""
361+
362+
return result, retroprov
357363

358364
def draw(self, filepath):
359365
"""Visualize workflow.

0 commit comments

Comments
 (0)