Skip to content

Commit 9b7d4e5

Browse files
committed
improve psijworker performance - remove unnecessary pickle dumps
1 parent 07f8107 commit 9b7d4e5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pydra/engine/run_pickled.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pickle
22
import sys
3-
3+
from pydra.engine.helpers import load_and_run
44

55
def run_pickled(*file_paths, rerun=False):
66
loaded_objects = []
@@ -11,8 +11,8 @@ def run_pickled(*file_paths, rerun=False):
1111

1212
if len(loaded_objects) == 1:
1313
result = loaded_objects[0](rerun=rerun)
14-
elif len(loaded_objects) == 3:
15-
result = loaded_objects[0](loaded_objects[1], loaded_objects[2], rerun=rerun)
14+
elif len(loaded_objects) == 2:
15+
result = load_and_run(loaded_objects[0], loaded_objects[1], rerun=rerun)
1616
else:
1717
raise ValueError("Unsupported number of loaded objects")
1818

pydra/engine/workers.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -995,15 +995,12 @@ async def exec_psij(self, runnable, rerun=False):
995995
spec = self.make_spec("python", [func_path, file_path])
996996
else: # it could be tuple that includes pickle files with tasks and inputs
997997
cache_dir = runnable[-1].cache_dir
998-
file_path_1 = cache_dir / "runnable_function.pkl"
999-
file_path_2 = cache_dir / "taskmain.pkl"
1000-
file_path_3 = cache_dir / "ind.pkl"
998+
file_path_1 = cache_dir / "taskmain.pkl"
999+
file_path_2 = cache_dir / "ind.pkl"
10011000
ind, task_main_pkl, task_orig = runnable
10021001
with open(file_path_1, "wb") as file:
1003-
pickle.dump(load_and_run, file)
1004-
with open(file_path_2, "wb") as file:
10051002
pickle.dump(task_main_pkl, file)
1006-
with open(file_path_3, "wb") as file:
1003+
with open(file_path_2, "wb") as file:
10071004
pickle.dump(ind, file)
10081005
func_path = absolute_path / "run_pickled.py"
10091006
spec = self.make_spec(
@@ -1012,7 +1009,6 @@ async def exec_psij(self, runnable, rerun=False):
10121009
func_path,
10131010
file_path_1,
10141011
file_path_2,
1015-
file_path_3,
10161012
],
10171013
)
10181014

0 commit comments

Comments
 (0)