Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 12, 2023
1 parent d9bca02 commit 86b4377
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pydra/engine/run_pickled_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def run_pickled():
file_path = sys.argv[1]

Check warning on line 7 in pydra/engine/run_pickled_function.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L7

Added line #L7 was not covered by tests
with open(file_path, 'rb') as file:
with open(file_path, "rb") as file:
loaded_function = pickle.load(file)

Check warning on line 9 in pydra/engine/run_pickled_function.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L9

Added line #L9 was not covered by tests

result = loaded_function(rerun=False)

Check warning on line 11 in pydra/engine/run_pickled_function.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L11

Added line #L11 was not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions pydra/engine/run_pickled_function_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def run_pickled():
file_path_1 = sys.argv[1]
file_path_2 = sys.argv[2]
file_path_3 = sys.argv[3]

Check warning on line 9 in pydra/engine/run_pickled_function_2.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L7-L9

Added lines #L7 - L9 were not covered by tests
with open(file_path_1, 'rb') as file:
with open(file_path_1, "rb") as file:
loaded_function = pickle.load(file)

Check warning on line 11 in pydra/engine/run_pickled_function_2.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L11

Added line #L11 was not covered by tests
with open(file_path_2, 'rb') as file:
with open(file_path_2, "rb") as file:
taskmain = pickle.load(file)

Check warning on line 13 in pydra/engine/run_pickled_function_2.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L13

Added line #L13 was not covered by tests
with open(file_path_3, 'rb') as file:
with open(file_path_3, "rb") as file:
ind = pickle.load(file)

Check warning on line 15 in pydra/engine/run_pickled_function_2.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L15

Added line #L15 was not covered by tests

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

Check warning on line 17 in pydra/engine/run_pickled_function_2.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L17

Added line #L17 was not covered by tests
Expand Down
35 changes: 23 additions & 12 deletions pydra/engine/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,28 +924,39 @@ async def exec_psij(self, runnable, rerun=False):
import psij
import pickle
import os

Check warning on line 926 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L924-L926

Added lines #L924 - L926 were not covered by tests

self.psij = psij
jex = psij.JobExecutor.get_instance('slurm')
jex = psij.JobExecutor.get_instance("slurm")

Check warning on line 929 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L928-L929

Added lines #L928 - L929 were not covered by tests

if isinstance(runnable, TaskBase):
cache_dir = runnable.cache_dir
file_path = os.path.join(cache_dir, 'my_function.pkl')
with open(file_path, 'wb') as file:
file_path = os.path.join(cache_dir, "my_function.pkl")

Check warning on line 933 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L932-L933

Added lines #L932 - L933 were not covered by tests
with open(file_path, "wb") as file:
pickle.dump(runnable._run, file)
spec = self.make_spec("python3.9", ["/pydra/pydra/engine/run_pickled_function.py", file_path])
spec = self.make_spec(

Check warning on line 936 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L935-L936

Added lines #L935 - L936 were not covered by tests
"python3.9", ["/pydra/pydra/engine/run_pickled_function.py", file_path]
)
else: # it could be tuple that includes pickle files with tasks and inputs
cache_dir = runnable[-1].cache_dir
file_path_1 = os.path.join(cache_dir, 'my_function.pkl')
file_path_2 = os.path.join(cache_dir, 'taskmain.pkl')
file_path_3 = os.path.join(cache_dir, 'ind.pkl')
file_path_1 = os.path.join(cache_dir, "my_function.pkl")
file_path_2 = os.path.join(cache_dir, "taskmain.pkl")
file_path_3 = os.path.join(cache_dir, "ind.pkl")
ind, task_main_pkl, task_orig = runnable

Check warning on line 944 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L940-L944

Added lines #L940 - L944 were not covered by tests
with open(file_path_1, 'wb') as file:
with open(file_path_1, "wb") as file:
pickle.dump(load_and_run, file)

Check warning on line 946 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L946

Added line #L946 was not covered by tests
with open(file_path_2, 'wb') as file:
with open(file_path_2, "wb") as file:
pickle.dump(task_main_pkl, file)

Check warning on line 948 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L948

Added line #L948 was not covered by tests
with open(file_path_3, 'wb') as file:
with open(file_path_3, "wb") as file:
pickle.dump(ind, file)
spec = self.make_spec("python3.9", ["/pydra/pydra/engine/run_pickled_function_2.py", file_path_1, file_path_2, file_path_3])
spec = self.make_spec(

Check warning on line 951 in pydra/engine/workers.py

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L950-L951

Added lines #L950 - L951 were not covered by tests
"python3.9",
[
"/pydra/pydra/engine/run_pickled_function_2.py",
file_path_1,
file_path_2,
file_path_3,
],
)

job = self.make_job(spec, None)
jex.submit(job)
Expand Down

0 comments on commit 86b4377

Please sign in to comment.