Skip to content

Commit 789800e

Browse files
committed
use pathlib
1 parent 99a8b3d commit 789800e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pydra/engine/workers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -979,31 +979,31 @@ async def exec_psij(self, runnable, rerun=False):
979979
None
980980
"""
981981
import pickle
982-
import os
982+
from pathlib import Path
983983

984984
jex = self.psij.JobExecutor.get_instance(self.subtype)
985-
absolute_path = os.path.dirname(__file__)
985+
absolute_path = Path(__file__).parent
986986

987987
if isinstance(runnable, TaskBase):
988988
cache_dir = runnable.cache_dir
989-
file_path = os.path.join(cache_dir, "my_function.pkl")
989+
file_path = cache_dir / "my_function.pkl"
990990
with open(file_path, "wb") as file:
991991
pickle.dump(runnable._run, file)
992-
func_path = os.path.join(absolute_path, "run_pickled.py")
992+
func_path = absolute_path / "run_pickled.py"
993993
spec = self.make_spec("python", [func_path, file_path])
994994
else: # it could be tuple that includes pickle files with tasks and inputs
995995
cache_dir = runnable[-1].cache_dir
996-
file_path_1 = os.path.join(cache_dir, "my_function.pkl")
997-
file_path_2 = os.path.join(cache_dir, "taskmain.pkl")
998-
file_path_3 = os.path.join(cache_dir, "ind.pkl")
996+
file_path_1 = cache_dir / "my_function.pkl"
997+
file_path_2 = cache_dir / "taskmain.pkl"
998+
file_path_3 = cache_dir / "ind.pkl"
999999
ind, task_main_pkl, task_orig = runnable
10001000
with open(file_path_1, "wb") as file:
10011001
pickle.dump(load_and_run, file)
10021002
with open(file_path_2, "wb") as file:
10031003
pickle.dump(task_main_pkl, file)
10041004
with open(file_path_3, "wb") as file:
10051005
pickle.dump(ind, file)
1006-
func_path = os.path.join(absolute_path, "run_pickled.py")
1006+
func_path = absolute_path / "run_pickled.py"
10071007
spec = self.make_spec(
10081008
"python",
10091009
[
@@ -1017,14 +1017,14 @@ async def exec_psij(self, runnable, rerun=False):
10171017
if rerun:
10181018
spec.arguments.append("--rerun")
10191019

1020-
spec.stdout_path = os.path.join(cache_dir, "demo.stdout")
1021-
spec.stderr_path = os.path.join(cache_dir, "demo.stderr")
1020+
spec.stdout_path = cache_dir / "demo.stdout"
1021+
spec.stderr_path = cache_dir / "demo.stderr"
10221022

10231023
job = self.make_job(spec, None)
10241024
jex.submit(job)
10251025
job.wait()
10261026

1027-
if os.path.getsize(spec.stderr_path) > 0:
1027+
if spec.stderr_path.stat().st_size > 0:
10281028
with open(spec.stderr_path, "r") as stderr_file:
10291029
stderr_contents = stderr_file.read()
10301030
raise Exception(

0 commit comments

Comments
 (0)