Index
Job management utilities for simulation servers.
Provides sample generation, output handling, and run management utilities adapted from mada-job-management jobkit.
FolderOutputHandler
Bases: BaseOutputHandler
Output handler for writing samples to a folder.
Attributes:
| Name | Type | Description |
|---|---|---|
settings_class |
The settings class for this output handler. |
|
supported_kwargs |
The full set of supported keyword arguments for the |
|
required_kwargs |
The set of required keyword arguments for the |
Methods:
| Name | Description |
|---|---|
write |
Writes samples to a folder structure. |
Source code in src/mada_tools/simulation/simutils/samples/output/folder_output_handler.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
write(samples, parameter_names=None, **kwargs)
Creates a folder structure for each sample, writes the parameters to individual files,
and dumps all RunInstances to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
ndarray
|
A list of samples, where each sample is a list of floats. |
required |
parameter_names
|
List[str] | None
|
List of parameter names. |
None
|
**kwargs
|
Dict[str, Any]
|
Additional keyword arguments for output configuration. |
{}
|
Returns:
| Type | Description |
|---|---|
SampleOutputResult
|
A |
Source code in src/mada_tools/simulation/simutils/samples/output/folder_output_handler.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
LHSampleGenerator
Bases: BaseSampleGenerator
Latin Hypercube Sample generator component.
Attributes:
| Name | Type | Description |
|---|---|---|
settings_class |
The settings class for this output handler. |
|
supported_kwargs |
The full set of supported keyword arguments for the |
|
required_kwargs |
The set of required keyword arguments for the |
Methods:
| Name | Description |
|---|---|
find_missing_required_kwargs |
Validates that all required keyword arguments are present. |
build_settings_from_kwargs |
Validates the keyword arguments and builds the settings object. |
generate |
Generate a list of samples from the provided data. |
Source code in src/mada_tools/simulation/simutils/samples/generation/lhs_sample_generator.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
generate(**kwargs)
Generate a list of samples from the provided data.
This method will convert the keyword arguments into a LHSampleSettings object
for validation and logging purposes. It will then use these settings to generate
samples using the Latin Hypercube Sampling method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Dict[str, int | List[float]]
|
Keyword arguments for sample generation. For LHS sampling, this must include: - dims: int, number of dimensions - n_samples: int, number of samples to generate - lower_bounds: List[float], lower bounds for each dimension - upper_bounds: List[float], upper bounds for each dimension |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A numpy array of generated samples. |
Source code in src/mada_tools/simulation/simutils/samples/generation/lhs_sample_generator.py
RunInstance
dataclass
Represents a single instance of a computational run, storing relevant data and metadata associated with the run.
Attributes:
| Name | Type | Description |
|---|---|---|
run_location |
str
|
The directory where the run will be executed. |
id |
str
|
The identifier for a run instance. |
command |
str
|
The executable command to run (optional). |
args |
List[str]
|
The arguments to pass to the command (optional). |
Methods:
| Name | Description |
|---|---|
to_dict |
Converts the RunInstance object into a JSON-serializable dictionary. |
get_command_with_args |
Returns the command and arguments for execution. |
Source code in src/mada_tools/simulation/simutils/models.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__repr__()
Returns a detailed string representation of the RunInstance object for debugging.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A detailed string representation of the object. |
Source code in src/mada_tools/simulation/simutils/models.py
__str__()
Returns a human-readable string representation of the RunInstance object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string describing the run instance. |
Source code in src/mada_tools/simulation/simutils/models.py
from_dict(data)
classmethod
Creates a RunInstance object from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict
|
Dictionary containing run instance data |
required |
Returns:
| Type | Description |
|---|---|
RunInstance
|
RunInstance object with data from the dictionary |
Source code in src/mada_tools/simulation/simutils/models.py
get_command_with_args()
Returns the command and arguments for execution.
Returns:
| Type | Description |
|---|---|
Tuple[str, List[str]]
|
Tuple[str, List[str]]: The command and its arguments. |
Source code in src/mada_tools/simulation/simutils/models.py
get_run_command()
Constructs the shell command to execute this run instance.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The shell command to execute this run. |
Source code in src/mada_tools/simulation/simutils/models.py
to_dict()
Converts the RunInstance object into a JSON-serializable dictionary.
Returns:
| Type | Description |
|---|---|
Dict
|
A dictionary representation of the RunInstance object. |
Source code in src/mada_tools/simulation/simutils/models.py
SampleOutputResult
dataclass
Represents the result of sample output generation, storing the output path, output type, and optionally the run instances (if necessary).
Attributes:
| Name | Type | Description |
|---|---|---|
output_path |
str
|
The path where the samples are written. For "csv" output, this is the path to the CSV file. For "folder" output, this is the path to the directory. |
output_type |
str
|
The type of output generated (e.g., "csv", "folder"). |
run_instances |
List[RunInstance]
|
A list of RunInstance objects if the output type is "folder". |
Source code in src/mada_tools/simulation/simutils/models.py
__repr__()
Returns a detailed string representation of the SampleOutputResult object for debugging.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A detailed string representation of the object. |
Source code in src/mada_tools/simulation/simutils/models.py
__str__()
Returns a human-readable string representation of the SampleOutputResult object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string describing the sample output result. |
Source code in src/mada_tools/simulation/simutils/models.py
get_run_instances(run_instances_json_path)
Reads the run_instances.json file from the specified study directory and converts it into a list of RunInstance objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_instances_json_path
|
str
|
The path to the run_instances.json file. |
required |
Returns:
| Type | Description |
|---|---|
List[RunInstance]
|
A list of RunInstance objects. |