Runner Module¶
This section documents the runner components of the Nextmv Python SDK - Local experience.
runner
¶
Runner module for executing local runs.
This module provides functionality to execute local runs.
FUNCTION | DESCRIPTION |
---|---|
run |
Function to execute a local run. |
new_run |
Function to initialize a new run. |
record_input |
Function to write the input to the appropriate location. |
calculate_files_size |
Function to calculate the total size of files in a directory. |
calculate_files_size
¶
calculate_files_size(
run_dir: str,
run_id: str,
dir_path: str,
metadata_key: str,
) -> None
Calculates the total size of the files in a directory, in bytes.
The calculated size is stored in the run information metadata under the specified key.
PARAMETER | DESCRIPTION |
---|---|
|
The path to the run directory.
TYPE:
|
|
The ID of the run.
TYPE:
|
|
The path to the directory whose size is to be calculated.
TYPE:
|
|
The key under which to store the calculated size in the run information metadata.
TYPE:
|
Source code in nextmv/nextmv/local/runner.py
new_run
¶
new_run(
app_id: str,
src: str,
run_id: str,
run_config: dict[str, Any],
name: Optional[str] = None,
description: Optional[str] = None,
) -> str
Initializes a new run.
The run information is recorded in a JSON file within the run directory.
PARAMETER | DESCRIPTION |
---|---|
|
The ID of the application.
TYPE:
|
|
The path to the application source code.
TYPE:
|
|
The ID of the run.
TYPE:
|
|
The run configuration.
TYPE:
|
|
The name for the run, by default None.
TYPE:
|
|
The description for the run, by default None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The path to the new run directory. |
Source code in nextmv/nextmv/local/runner.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
record_input
¶
record_input(
run_dir: str,
run_id: str,
input_data: Optional[Union[dict[str, Any], str]] = None,
inputs_dir_path: Optional[str] = None,
) -> None
Writes the input to the appropriate location.
The size of the input is calculated and recorded in the run information.
PARAMETER | DESCRIPTION |
---|---|
|
The path to the run directory.
TYPE:
|
|
The ID of the run.
TYPE:
|
|
The input data for the run, by default None. If
TYPE:
|
|
The path to the directory containing input files, by default None. If
provided, this parameter takes precedence over
TYPE:
|
Source code in nextmv/nextmv/local/runner.py
run
¶
run(
app_id: str,
src: str,
manifest: Manifest,
run_config: dict[str, Any],
name: Optional[str] = None,
description: Optional[str] = None,
input_data: Optional[Union[dict[str, Any], str]] = None,
inputs_dir_path: Optional[str] = None,
options: Optional[dict[str, Any]] = None,
) -> str
Execute a local run.
This method recreates, partially, what the Nextmv Cloud does in the backend when running an application. A run ID is generated, a run directory is created, and the input data is recorded. Then, a subprocess is started to execute the application run in a detached manner. This means that the application run is not waited upon.
PARAMETER | DESCRIPTION |
---|---|
|
The ID of the application.
TYPE:
|
|
The path to the application source code.
TYPE:
|
|
The application manifest.
TYPE:
|
|
The run configuration.
TYPE:
|
|
The name for the run, by default None.
TYPE:
|
|
The description for the run, by default None.
TYPE:
|
|
The input data for the run, by default None. If
TYPE:
|
|
The path to the directory containing input files, by default None. If
provided, this parameter takes precedence over
TYPE:
|
|
Additional options for the run, by default None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The ID of the created run. |
Source code in nextmv/nextmv/local/runner.py
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 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 |
|