@@ -979,31 +979,31 @@ async def exec_psij(self, runnable, rerun=False):
979
979
None
980
980
"""
981
981
import pickle
982
- import os
982
+ from pathlib import Path
983
983
984
984
jex = self .psij .JobExecutor .get_instance (self .subtype )
985
- absolute_path = os . path . dirname (__file__ )
985
+ absolute_path = Path (__file__ ). parent
986
986
987
987
if isinstance (runnable , TaskBase ):
988
988
cache_dir = runnable .cache_dir
989
- file_path = os . path . join ( cache_dir , "my_function.pkl" )
989
+ file_path = cache_dir / "my_function.pkl"
990
990
with open (file_path , "wb" ) as file :
991
991
pickle .dump (runnable ._run , file )
992
- func_path = os . path . join ( absolute_path , "run_pickled.py" )
992
+ func_path = absolute_path / "run_pickled.py"
993
993
spec = self .make_spec ("python" , [func_path , file_path ])
994
994
else : # it could be tuple that includes pickle files with tasks and inputs
995
995
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"
999
999
ind , task_main_pkl , task_orig = runnable
1000
1000
with open (file_path_1 , "wb" ) as file :
1001
1001
pickle .dump (load_and_run , file )
1002
1002
with open (file_path_2 , "wb" ) as file :
1003
1003
pickle .dump (task_main_pkl , file )
1004
1004
with open (file_path_3 , "wb" ) as file :
1005
1005
pickle .dump (ind , file )
1006
- func_path = os . path . join ( absolute_path , "run_pickled.py" )
1006
+ func_path = absolute_path / "run_pickled.py"
1007
1007
spec = self .make_spec (
1008
1008
"python" ,
1009
1009
[
@@ -1017,14 +1017,14 @@ async def exec_psij(self, runnable, rerun=False):
1017
1017
if rerun :
1018
1018
spec .arguments .append ("--rerun" )
1019
1019
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"
1022
1022
1023
1023
job = self .make_job (spec , None )
1024
1024
jex .submit (job )
1025
1025
job .wait ()
1026
1026
1027
- if os . path . getsize ( spec .stderr_path ) > 0 :
1027
+ if spec .stderr_path . stat (). st_size > 0 :
1028
1028
with open (spec .stderr_path , "r" ) as stderr_file :
1029
1029
stderr_contents = stderr_file .read ()
1030
1030
raise Exception (
0 commit comments