Skip to content

Commit

Permalink
execute_parallel returns client object with .close method
Browse files Browse the repository at this point in the history
  • Loading branch information
comane committed Mar 7, 2024
1 parent bff2455 commit f28609f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/reportengine/resourcebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def execute_parallel(self, scheduler=None):
# gather futures once all jobs have been submitted
self.gather_results(leaf_callspecs, client)

return client


def set_future(self, future, callspec):
"""
Expand Down
4 changes: 3 additions & 1 deletion src/reportengine/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ def test_collect(self):
builder.resolve_fuzzytargets()
d = namespaces.resolve(builder.rootns, [('lists',1)])
assert d['restaurant_collect'] == list("123")
builder.execute_parallel()
client = builder.execute_parallel()
# since it is using dask it returns a future
assert namespaces.resolve(builder.rootns, ('UK',))['score'].result() == -1
# close the client
client.close()

def test_collect_raises(self):
with self.assertRaises(TypeError):
Expand Down
5 changes: 3 additions & 2 deletions src/reportengine/tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def node_2_2(node_1_result):


def node_3(node_2_1_result, node_2_2_result, param=None):
print("executing node_3")
print("Executing node_3")
return (node_2_1_result + node_2_2_result) * (param // 2)


Expand Down Expand Up @@ -116,8 +116,9 @@ def test_parallel_execute(self):
This test will execute the DAG in parallel, using
dask distributed scheduler.
"""
self.execute_parallel()
client = self.execute_parallel()
self._test_ns(promise=True)
client.close()


if __name__ == "__main__":
Expand Down

0 comments on commit f28609f

Please sign in to comment.