ShellFunction

class globus_compute_sdk.sdk.shell_function.ShellFunction(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)

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 ShellFunction :

bf = ShellFunction("echo 'Hello'")
future = executor.submit(bf)  # 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

class globus_compute_sdk.sdk.shell_function.ShellResult(cmd: str, stdout: str, stderr: str, returncode: int, exception_name: str | None = None)
Parameters:
  • cmd (str) – formatted command line string that was executed on the endpoint

  • stdout (str) – multiline (default 1K) snippet of stdout

  • stderr (str) – multiline (default 1K) snippet of stderr

  • returncode (int) – Return code from command execution

  • exception_name