diff --git a/executorlib/backend/cache_parallel.py b/executorlib/backend/cache_parallel.py index d5db97a2..1ebdeb4a 100644 --- a/executorlib/backend/cache_parallel.py +++ b/executorlib/backend/cache_parallel.py @@ -39,10 +39,7 @@ def main() -> None: apply_dict = backend_load_file(file_name=file_name) apply_dict = MPI.COMM_WORLD.bcast(apply_dict, root=0) output = apply_dict["fn"].__call__(*apply_dict["args"], **apply_dict["kwargs"]) - if mpi_size_larger_one: - result = MPI.COMM_WORLD.gather(output, root=0) - else: - result = output + result = MPI.COMM_WORLD.gather(output, root=0) if mpi_size_larger_one else output if mpi_rank_zero: backend_write_file( file_name=file_name, diff --git a/executorlib/backend/interactive_parallel.py b/executorlib/backend/interactive_parallel.py index 62c93d65..c1969c00 100644 --- a/executorlib/backend/interactive_parallel.py +++ b/executorlib/backend/interactive_parallel.py @@ -57,17 +57,17 @@ def main() -> None: input_dict = MPI.COMM_WORLD.bcast(input_dict, root=0) # Parse input - if "shutdown" in input_dict.keys() and input_dict["shutdown"]: + if "shutdown" in input_dict and input_dict["shutdown"]: if mpi_rank_zero: interface_send(socket=socket, result_dict={"result": True}) interface_shutdown(socket=socket, context=context) MPI.COMM_WORLD.Barrier() break elif ( - "fn" in input_dict.keys() - and "init" not in input_dict.keys() - and "args" in input_dict.keys() - and "kwargs" in input_dict.keys() + "fn" in input_dict + and "init" not in input_dict + and "args" in input_dict + and "kwargs" in input_dict ): # Execute function try: @@ -87,10 +87,10 @@ def main() -> None: if mpi_rank_zero: interface_send(socket=socket, result_dict={"result": output_reply}) elif ( - "init" in input_dict.keys() + "init" in input_dict and input_dict["init"] - and "args" in input_dict.keys() - and "kwargs" in input_dict.keys() + and "args" in input_dict + and "kwargs" in input_dict ): memory = call_funct(input_dict=input_dict, funct=None) diff --git a/executorlib/backend/interactive_serial.py b/executorlib/backend/interactive_serial.py index b7e2a62f..1bf957c1 100644 --- a/executorlib/backend/interactive_serial.py +++ b/executorlib/backend/interactive_serial.py @@ -1,6 +1,6 @@ import sys from os.path import abspath -from typing import List, Optional +from typing import Optional from executorlib.standalone.interactive.backend import call_funct, parse_arguments from executorlib.standalone.interactive.communication import ( @@ -11,7 +11,7 @@ ) -def main(argument_lst: Optional[List[str]] = None): +def main(argument_lst: Optional[list[str]] = None): """ The main function of the program. @@ -40,15 +40,15 @@ def main(argument_lst: Optional[List[str]] = None): input_dict = interface_receive(socket=socket) # Parse input - if "shutdown" in input_dict.keys() and input_dict["shutdown"]: + if "shutdown" in input_dict and input_dict["shutdown"]: interface_send(socket=socket, result_dict={"result": True}) interface_shutdown(socket=socket, context=context) break elif ( - "fn" in input_dict.keys() - and "init" not in input_dict.keys() - and "args" in input_dict.keys() - and "kwargs" in input_dict.keys() + "fn" in input_dict + and "init" not in input_dict + and "args" in input_dict + and "kwargs" in input_dict ): # Execute function try: @@ -62,10 +62,10 @@ def main(argument_lst: Optional[List[str]] = None): # Send output interface_send(socket=socket, result_dict={"result": output}) elif ( - "init" in input_dict.keys() + "init" in input_dict and input_dict["init"] - and "args" in input_dict.keys() - and "kwargs" in input_dict.keys() + and "args" in input_dict + and "kwargs" in input_dict ): memory = call_funct(input_dict=input_dict, funct=None)