Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Feb 3, 2025
1 parent 0b11837 commit ca07512
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
5 changes: 1 addition & 4 deletions executorlib/backend/cache_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions executorlib/backend/interactive_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
20 changes: 10 additions & 10 deletions executorlib/backend/interactive_serial.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit ca07512

Please sign in to comment.