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__(name)
method MynaApp.copy
copy(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.mpiargs_to_current
mpiargs_to_current()
Function to convert the deprecated --mpiargs option to the current --mpiexec, --np, and --mpiflags options
TODO: Remove this function in next release
method MynaApp.parse_known_args
parse_known_args()
Parse known command line arguments to update self.args and apply any corrections
method MynaApp.set_procs
set_procs()
Set processor information based on the maxproc and np inputs. Regardless of user inputs, the CPU count will be capped at os.cpu_count()
method MynaApp.set_template_path
set_template_path(*path_args)
Set the path to the template directory
Args:
path_args: list of path parts to append toself.pathif no template is specified. For example,path_args=["exaca", "microstructure_region"]gives a template with path "{self.path}/exaca/microstructure_region/template"
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.