Skip to content

Commit b410204

Browse files
committed
Output graph statistics
1 parent d8ee766 commit b410204

2 files changed

Lines changed: 27 additions & 25 deletions

File tree

‎arl/graphs/execute.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"""
44

55
from dask import delayed
6+
import logging
7+
8+
log = logging.getLogger(__name__)
9+
610

711
class ARLExecuteBase():
812

@@ -23,7 +27,7 @@ def execute(self, func, *args, **kwargs):
2327
return func
2428

2529
def type(self):
26-
""" Get the name of the execution system
30+
""" Get the type of the execution system
2731
2832
:return:
2933
"""
@@ -39,7 +43,13 @@ def get(self, value):
3943
:return:
4044
"""
4145
if self.use_dask:
42-
return value.compute()
46+
log.debug("arlexecute.get: Executing %d nodes in graph" % len(value.dask.dicts))
47+
import time
48+
start=time.time()
49+
result = value.compute()
50+
duration = time.time()-start
51+
log.debug("arlexecute.get: Execution took %.3f seconds" % duration)
52+
return result
4353
else:
4454
return value
4555

‎examples/arl/simple-dask.ipynb‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,14 @@
2121
"\n",
2222
"import numpy\n",
2323
"\n",
24-
"sys.path.append(os.path.join('..', '..'))\n",
25-
"\n",
2624
"import astropy.units as u\n",
27-
"\n",
28-
"from arl.graphs.execute import arlexecute\n",
29-
"\n",
3025
"from astropy.coordinates import SkyCoord\n",
3126
"\n",
27+
"from arl.graphs.execute import arlexecute\n",
3228
"from arl.data.polarisation import PolarisationFrame\n",
3329
"from arl.graphs.generic_graphs import create_generic_image_graph\n",
3430
"from arl.graphs.dask_init import get_dask_Client\n",
35-
"from arl.image.iterators import image_raster_iter\n",
36-
"from arl.image.operations import qa_image\n",
37-
"from arl.util.testing_support import create_test_image\n",
38-
"\n"
31+
"from arl.util.testing_support import create_test_image"
3932
]
4033
},
4134
{
@@ -48,14 +41,10 @@
4841
"outputs": [],
4942
"source": [
5043
"frequency = numpy.array([1e8])\n",
51-
"\n",
5244
"phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000')\n",
53-
"test_image = create_test_image(frequency=frequency, phasecentre=phasecentre,\n",
54-
" cellsize=0.001,\n",
55-
" polarisation_frame=PolarisationFrame('stokesI'))\n",
56-
"\n",
57-
"image_graph = arlexecute.execute(create_test_image)(frequency=frequency, phasecentre=phasecentre, cellsize=0.001,\n",
58-
" polarisation_frame=PolarisationFrame('stokesI'))"
45+
"model_graph = arlexecute.execute(create_test_image)(frequency=frequency, phasecentre=phasecentre, cellsize=0.001,\n",
46+
" polarisation_frame=PolarisationFrame('stokesI'))\n",
47+
"model = arlexecute.get(model_graph)\n"
5948
]
6049
},
6150
{
@@ -77,11 +66,7 @@
7766
" im.data = numpy.sqrt(numpy.abs(im.data))\n",
7867
" return im\n",
7968
"\n",
80-
"root = create_generic_image_graph(imagerooter, test_image, facets=4)\n",
81-
"if arlexecute.use_dask:\n",
82-
" root.visualize()\n",
83-
"\n",
84-
"print(root)"
69+
"root = create_generic_image_graph(imagerooter, model_graph, facets=4)"
8570
]
8671
},
8772
{
@@ -98,7 +83,7 @@
9883
"outputs": [],
9984
"source": [
10085
"result = arlexecute.get(root)\n",
101-
"numpy.testing.assert_array_almost_equal_nulp(result.data**2, numpy.abs(test_image.data), 7)"
86+
"numpy.testing.assert_array_almost_equal_nulp(result.data**2, numpy.abs(model.data), 7)"
10287
]
10388
},
10489
{
@@ -116,9 +101,16 @@
116101
"source": [
117102
"client = get_dask_Client()\n",
118103
"result=client.compute(root, sync=True)\n",
119-
"numpy.testing.assert_array_almost_equal_nulp(result.data**2, numpy.abs(test_image.data), 7)\n",
104+
"numpy.testing.assert_array_almost_equal_nulp(result.data**2, numpy.abs(model.data), 7)\n",
120105
"client.close()"
121106
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": null,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": []
122114
}
123115
],
124116
"metadata": {

0 commit comments

Comments
 (0)