Skip to content

Commit 942a68d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bb1078d commit 942a68d

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

pydra/engine/run_pickled_function.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import pydra
33
import sys
44

5+
56
def run_pickled():
6-
with open('/pydra/pydra/engine/my_function.pkl', 'rb') as file:
7+
with open("/pydra/pydra/engine/my_function.pkl", "rb") as file:
78
loaded_function = pickle.load(file)
89

910
result = loaded_function(rerun=False)
10-
11-
print(f'Result: {result}')
1211

13-
if __name__ == '__main__':
12+
print(f"Result: {result}")
13+
14+
15+
if __name__ == "__main__":
1416
run_pickled()

pydra/engine/run_pickled_function_2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
import pydra
33
import sys
44

5+
56
def run_pickled():
6-
with open('/pydra/pydra/engine/my_function.pkl', 'rb') as file:
7+
with open("/pydra/pydra/engine/my_function.pkl", "rb") as file:
78
loaded_function = pickle.load(file)
8-
with open('/pydra/pydra/engine/taskmain.pkl', 'rb') as file:
9+
with open("/pydra/pydra/engine/taskmain.pkl", "rb") as file:
910
taskmain = pickle.load(file)
10-
with open('/pydra/pydra/engine/ind.pkl', 'rb') as file:
11+
with open("/pydra/pydra/engine/ind.pkl", "rb") as file:
1112
ind = pickle.load(file)
1213

1314
result = loaded_function(taskmain, ind, rerun=False)
1415

15-
print(f'Result: {result}')
16+
print(f"Result: {result}")
17+
1618

17-
if __name__ == '__main__':
19+
if __name__ == "__main__":
1820
run_pickled()

pydra/engine/workers.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,8 @@ def make_spec(self, cmd=None, arg=None):
910910
spec = self.psij.JobSpec()
911911
spec.executable = cmd
912912
spec.arguments = arg
913-
spec.stdout_path = '/pydra/pydra/engine/demo.stdout'
914-
spec.stderr_path = '/pydra/pydra/engine/demo.stderr'
913+
spec.stdout_path = "/pydra/pydra/engine/demo.stdout"
914+
spec.stderr_path = "/pydra/pydra/engine/demo.stderr"
915915

916916
return spec
917917

@@ -923,33 +923,39 @@ def make_job(self, spec, attributes):
923923
async def exec_psij(self, runnable, rerun=False):
924924
import psij
925925
import pickle
926+
926927
self.psij = psij
927-
jex = psij.JobExecutor.get_instance('slurm')
928+
jex = psij.JobExecutor.get_instance("slurm")
928929

929930
if isinstance(runnable, TaskBase):
930-
with open('/pydra/pydra/engine/my_function.pkl', 'wb') as file:
931+
with open("/pydra/pydra/engine/my_function.pkl", "wb") as file:
931932
pickle.dump(runnable._run, file)
932-
spec = self.make_spec("python3.9", ["/pydra/pydra/engine/run_pickled_function.py"])
933+
spec = self.make_spec(
934+
"python3.9", ["/pydra/pydra/engine/run_pickled_function.py"]
935+
)
933936
else: # it could be tuple that includes pickle files with tasks and inputs
934937
ind, task_main_pkl, task_orig = runnable
935-
with open('/pydra/pydra/engine/my_function.pkl', 'wb') as file:
938+
with open("/pydra/pydra/engine/my_function.pkl", "wb") as file:
936939
pickle.dump(load_and_run, file)
937-
with open('/pydra/pydra/engine/taskmain.pkl', 'wb') as file:
940+
with open("/pydra/pydra/engine/taskmain.pkl", "wb") as file:
938941
pickle.dump(task_main_pkl, file)
939-
with open('/pydra/pydra/engine/ind.pkl', 'wb') as file:
942+
with open("/pydra/pydra/engine/ind.pkl", "wb") as file:
940943
pickle.dump(ind, file)
941-
spec = self.make_spec("python3.9", ["/pydra/pydra/engine/run_pickled_function_2.py"])
944+
spec = self.make_spec(
945+
"python3.9", ["/pydra/pydra/engine/run_pickled_function_2.py"]
946+
)
942947

943948
job = self.make_job(spec, None)
944949
jex.submit(job)
945950
job.wait()
946-
951+
947952
return
948953

949954
def close(self):
950955
"""Finalize the internal pool of tasks."""
951956
pass
952957

958+
953959
WORKERS = {
954960
"serial": SerialWorker,
955961
"cf": ConcurrentFuturesWorker,

0 commit comments

Comments
 (0)