Skip to content
Snippets Groups Projects
Commit 676bc7c8 authored by pswain's avatar pswain
Browse files

refactor(pipeline): cleaned multiprocessing in run

parent 0801f4a2
No related branches found
No related tags found
No related merge requests found
...@@ -293,17 +293,14 @@ class Pipeline(ProcessABC): ...@@ -293,17 +293,14 @@ class Pipeline(ProcessABC):
# multiple cores # multiple cores
with Pool(distributed) as p: with Pool(distributed) as p:
results = p.map( results = p.map(
lambda x: self.run_one_position(*x), self.run_one_position,
[ [position_id for position_id in position_ids.items()],
(position_id, i)
for i, position_id in enumerate(position_ids.items())
],
) )
else: else:
# single core # single core
results = [ results = [
self.run_one_position((position_id, position_id_path), 1) self.run_one_position(position_id)
for position_id, position_id_path in tqdm(position_ids.items()) for position_id in tqdm(position_ids.items())
] ]
# results is binary giving the success for each position # results is binary giving the success for each position
return results return results
...@@ -323,9 +320,7 @@ class Pipeline(ProcessABC): ...@@ -323,9 +320,7 @@ class Pipeline(ProcessABC):
return out_file return out_file
def run_one_position( def run_one_position(
self, self, name_image_id: t.Tuple[str, str or Path or int]
name_image_id: t.Tuple[str, str or Path or int],
index: t.Optional[int] = None,
): ):
"""Run a pipeline for one position.""" """Run a pipeline for one position."""
name, image_id = name_image_id name, image_id = name_image_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment