Skip to content

module myna.core.app.base

Module to define the base behavior of a Myna simulation application


class MynaApp

Myna application base class with functionality that could be used generally by any application.

While applications are not required to inherit this class, using the MynaApp functionality where possible for consistent behavior across apps.

method MynaApp.__init__

__init__()

property MynaApp.component

Return the corresponding component class. This will be None if class name is not in the Component lookup dictionary


property MynaApp.name


property MynaApp.path


property MynaApp.template

Set the path to the template directory based on the path to the app directory


method MynaApp.configure

configure()

Configure the application workflow step.

Subclasses should override this method instead of implementing workflow logic in the stage wrapper scripts.


method MynaApp.copy_template_to_case

copy_template_to_case(case_dir)

Copies the set template directory to a case directory, with existing files being overwritten depending on the app overwrite user setting.

Args:

  • case_dir: (str) path to the case directory

method MynaApp.execute

execute()

Execute the application workflow step.

Subclasses should override this method instead of implementing workflow logic in the stage wrapper scripts.


method MynaApp.get_case_dirs

get_case_dirs(step_name=None, output_paths=None)

Return case directories associated with workflow output files.


method MynaApp.get_output_file_status

get_output_file_status()

Return the component output file paths, existence, and validity flags.


method MynaApp.get_step_output_paths

get_step_output_paths(step_name=None)

Return configured output file paths for a workflow step.


method MynaApp.parse_configure_arguments

parse_configure_arguments()

Register arguments used by the configure stage.

Subclasses can override this method and call self.parse_known_args().


method MynaApp.parse_execute_arguments

parse_execute_arguments()

Register arguments used by the execute stage.

Subclasses can override this method and call self.parse_known_args().


method MynaApp.parse_known_args

parse_known_args()

Parse known command line arguments to update self.args and apply any corrections


method MynaApp.parse_postprocess_arguments

parse_postprocess_arguments()

Register arguments used by the postprocess stage.

Subclasses can override this method and call self.parse_known_args().


method MynaApp.parse_shared_arguments

parse_shared_arguments()

Register arguments shared across multiple app stages.

Subclasses can override this method and call self.parse_known_args() in the relevant stage-specific parse methods.


method MynaApp.postprocess

postprocess()

Postprocess the application workflow step.

Subclasses should override this method instead of implementing workflow logic in the stage wrapper scripts.


method MynaApp.register_argument

register_argument(*name_or_flags, **kwargs)

Register an argument with duplicate detection.


method MynaApp.start_subprocess

start_subprocess(
    cmd_args,
    **kwargs
)  subprocess.Popen | docker.models.containers.Container

Starts a subprocess, activating an environment if present

kwargs are passed to the subprocess launcher, Popen or Docker: - For Popen subprocess, this can be used to redirect stdout & stderr, etc. - For Docker subprocesses, this can be used to pass a volume dictionary, whether to remove container after execution, etc.


method MynaApp.start_subprocess_with_mpi_args

start_subprocess_with_mpi_args(cmd_args, **kwargs)

Starts a subprocess using Popen while taking into account the MynaApp MPI-related options. **kwargs are passed to subprocess.Popen


method MynaApp.validate_executable

validate_executable(default)

Check if the specified executable exists and raise error if not


method MynaApp.wait_for_all_process_success

wait_for_all_process_success(processes, raise_error=True)

Wait for a process to complete successfully, raising an error if the process fails.

Args:

  • process: (subprocess.Popen) subprocess object
  • raise_error: (bool) if True, a failed subprocess will raise an error

Returns:

  • returncode: (int) process returncode from Popen.wait()

method MynaApp.wait_for_open_batch_resources

wait_for_open_batch_resources(
    processes: list[subprocess.Popen | docker.models.containers.Container],
    poll_interval=1
)

Given a list of subprocesses, checks if there are available resources to run another subprocess. If there are no open resources, then will wait to return until there are.

[!warning] > When running in batch mode with MPI options, this will be ignored

Args:

  • processes: (list) of subprocess.Popen objects
  • poll_interval: (float) time to wait between process polls, in seconds

method MynaApp.wait_for_process_success

wait_for_process_success(
    process: subprocess.Popen | docker.models.containers.Container,
    raise_error=True
)

Wait for a process to complete successfully, raising an error if the process fails.

Args:

  • process: (subprocess.Popen) subprocess object
  • raise_error: (bool) if True, a failed subprocess will raise an error

Returns:

  • returncode: (int) process returncode from Popen.wait()

This file was automatically generated via lazydocs.