MPIFunction

class globus_compute_sdk.sdk.mpi_function.MPIFunction(cmd: str, stdout: str | None = None, stderr: str | None = None, walltime: float | None = None, snippet_lines=1000, name: str | None = None, return_dict: bool = False)

MPIFunction extends ShellFunction, as a thin wrapper that adds an MPI launcher prefix to the ShellFunction command.

Initialize a ShellFunction

Parameters:
  • cmd (str) – formattable command line to execute. For e.g: “lammps -in {input_file}” where {input_file} is formatted with kwargs passed at call time.

  • stdout (str | None) – file path to which stdout should be captured

  • stderr (str | None) – file path to which stderr should be captures

  • walltime (float | None) – duration in seconds after which the command should be interrupted

  • snippet_lines (int) – Number of lines of stdout/err to capture, default=1000

  • name (str | None) – Name used to register function. Defaults to class name ShellFunction if not set.

  • return_dict (bool) – Indicates whether the function will return a JSON-compatible dict (True), or a ShellResult object (False).

__call__(**kwargs) ShellResult | dict

This method is passed from an executor to an endpoint to execute the MPIFunction :

mpi_func = MPIFunction("echo 'Hello'")
executor.resource_specification = {"num_nodes": 2, "ranks_per_node": 2}
future = executor.submit(mpi_func)  # Invokes this method on an endpoint
future.result()                     # returns a ShellResult
Parameters:

**kwargs – arbitrary keyword args will be used to format the cmd string before execution

Returns:

  • ShellResult (ShellResult) – Shell result object that encapsulates outputs from command execution

  • dict – Shell result data as a JSON-compatible dict