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 7, 2023
1 parent bb1078d commit 942a68d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
10 changes: 6 additions & 4 deletions pydra/engine/run_pickled_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import pydra
import sys


def run_pickled():
with open('/pydra/pydra/engine/my_function.pkl', 'rb') as file:
with open("/pydra/pydra/engine/my_function.pkl", "rb") as file:
loaded_function = pickle.load(file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L8

Added line #L8 was not covered by tests

result = loaded_function(rerun=False)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L10

Added line #L10 was not covered by tests

print(f'Result: {result}')

if __name__ == '__main__':
print(f"Result: {result}")

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L12

Added line #L12 was not covered by tests


if __name__ == "__main__":
run_pickled()

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function.py#L16

Added line #L16 was not covered by tests
12 changes: 7 additions & 5 deletions pydra/engine/run_pickled_function_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
import pydra
import sys


def run_pickled():
with open('/pydra/pydra/engine/my_function.pkl', 'rb') as file:
with open("/pydra/pydra/engine/my_function.pkl", "rb") as file:
loaded_function = pickle.load(file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L8

Added line #L8 was not covered by tests
with open('/pydra/pydra/engine/taskmain.pkl', 'rb') as file:
with open("/pydra/pydra/engine/taskmain.pkl", "rb") as file:
taskmain = pickle.load(file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L10

Added line #L10 was not covered by tests
with open('/pydra/pydra/engine/ind.pkl', 'rb') as file:
with open("/pydra/pydra/engine/ind.pkl", "rb") as file:
ind = pickle.load(file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L12

Added line #L12 was not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L14

Added line #L14 was not covered by tests

print(f'Result: {result}')
print(f"Result: {result}")

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L16

Added line #L16 was not covered by tests


if __name__ == '__main__':
if __name__ == "__main__":
run_pickled()

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/run_pickled_function_2.py#L20

Added line #L20 was not covered by tests
26 changes: 16 additions & 10 deletions pydra/engine/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,8 @@ def make_spec(self, cmd=None, arg=None):
spec = self.psij.JobSpec()
spec.executable = cmd
spec.arguments = arg
spec.stdout_path = '/pydra/pydra/engine/demo.stdout'
spec.stderr_path = '/pydra/pydra/engine/demo.stderr'
spec.stdout_path = "/pydra/pydra/engine/demo.stdout"
spec.stderr_path = "/pydra/pydra/engine/demo.stderr"

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L910-L914

Added lines #L910 - L914 were not covered by tests

return spec

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L916

Added line #L916 was not covered by tests

Expand All @@ -923,33 +923,39 @@ def make_job(self, spec, attributes):
async def exec_psij(self, runnable, rerun=False):
import psij
import pickle

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L924-L925

Added lines #L924 - L925 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L927-L928

Added lines #L927 - L928 were not covered by tests

if isinstance(runnable, TaskBase):
with open('/pydra/pydra/engine/my_function.pkl', 'wb') as file:
with open("/pydra/pydra/engine/my_function.pkl", "wb") as file:
pickle.dump(runnable._run, file)
spec = self.make_spec("python3.9", ["/pydra/pydra/engine/run_pickled_function.py"])
spec = self.make_spec(

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
"python3.9", ["/pydra/pydra/engine/run_pickled_function.py"]
)
else: # it could be tuple that includes pickle files with tasks and inputs
ind, task_main_pkl, task_orig = runnable

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L937

Added line #L937 was not covered by tests
with open('/pydra/pydra/engine/my_function.pkl', 'wb') as file:
with open("/pydra/pydra/engine/my_function.pkl", "wb") as file:
pickle.dump(load_and_run, file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L939

Added line #L939 was not covered by tests
with open('/pydra/pydra/engine/taskmain.pkl', 'wb') as file:
with open("/pydra/pydra/engine/taskmain.pkl", "wb") as file:
pickle.dump(task_main_pkl, file)

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L941

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

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L943-L944

Added lines #L943 - L944 were not covered by tests
"python3.9", ["/pydra/pydra/engine/run_pickled_function_2.py"]
)

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

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L948-L950

Added lines #L948 - L950 were not covered by tests

return

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L952

Added line #L952 was not covered by tests

def close(self):
"""Finalize the internal pool of tasks."""
pass

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

View check run for this annotation

Codecov / codecov/patch

pydra/engine/workers.py#L956

Added line #L956 was not covered by tests


WORKERS = {
"serial": SerialWorker,
"cf": ConcurrentFuturesWorker,
Expand Down

0 comments on commit 942a68d

Please sign in to comment.