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.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.parse_known_args
parse_known_args()
Parse known command line arguments to update self.args and apply any corrections
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 objectraise_error: (bool) if True, a failed subprocess will raise an error
Returns:
returncode: (int) process returncode fromPopen.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 objectspoll_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 objectraise_error: (bool) if True, a failed subprocess will raise an error
Returns:
returncode: (int) process returncode fromPopen.wait()
This file was automatically generated via lazydocs.