Interfaces
Abstract classes for handling interfacing with various services.
SchedulerScriptAdapter
Bases: ScriptAdapter
Abstract class representing the interface for scheduling scripts.
This class handles both the construction of scripts (as required by the ScriptAdapter base class) but also includes the necessary methods for constructing parallel commands. The adapter will substitute parallelized commands but also defines how to schedule and check job status.
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
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 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 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
__init__(**kwargs)
Initialize an empty ScriptAdapter object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
Key-value dictionary of arguments. Currently we only support the "shell" keyword. |
{}
|
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
add_batch_parameter(name, value)
Add a parameter to the ScriptAdapter instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
String name of the parameter that's being added. |
required | |
value |
Value associated with the parameter name (should have a str method). |
required |
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
get_header(step)
abstractmethod
Generate the header present at the top of execution scripts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step |
A StudyStep instance. |
required |
Returns:
Type | Description |
---|---|
A string of the header based on internal batch parameters and the parameter step. |
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
get_parallelize_command(procs, nodes, **kwargs)
abstractmethod
Generate the parallelization segment of the command line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
procs |
Number of processors to allocate to the parallel call. |
required | |
nodes |
Number of nodes to allocate to the parallel call (default = 1). |
required |
Returns:
Type | Description |
---|---|
A string of the parallelize command configured using nodes and procs. |
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
get_priority(priority)
Map a fixed enumeration or floating point priority to a batch priority.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
priority |
Float or StepPriority enum representing priorty. |
required |
Returns:
Type | Description |
---|---|
A string, integer, or float value representing the mapped priority to the batch scheduler. |
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
get_scheduler_command(step)
Generate the full parallelized command for use in a batch script.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step |
A StudyStep instance. |
required |
Returns:
Type | Description |
---|---|
|
Source code in maestrowf/abstracts/interfaces/schedulerscriptadapter.py
ScriptAdapter
Bases: object
Abstract class representing the interface for constructing scripts.
The ScriptAdapter abstract class is meant to provide a consistent high level interface to generate scripts automatically based on an ExecutionDAG. Adapters as a whole should only interface with the ExecutionDAG because it is ultimately the DAG that manages the state of tasks. Adapters attempt to bridge the 'how' in an abstract way such that the interface is refined to methods such as: - Generating a script with the proper syntax to submit. - Submitting a script using the proper command. - Checking job status.
Source code in maestrowf/abstracts/interfaces/scriptadapter.py
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 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 |
|
__init__(**kwargs)
Initialize a new instance of a ScriptAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
The key value arguments for the ScriptAdapter instance. |
{}
|
Source code in maestrowf/abstracts/interfaces/scriptadapter.py
cancel_jobs(joblist)
abstractmethod
For the given job list, cancel each job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
joblist |
A list of job identifiers to be cancelled. |
required |
Returns:
Type | Description |
---|---|
The return code to indicate if jobs were cancelled. |
Source code in maestrowf/abstracts/interfaces/scriptadapter.py
check_jobs(joblist)
abstractmethod
For the given job list, query execution status.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
joblist |
A list of job identifiers to be queried. |
required |
Returns:
Type | Description |
---|---|
The return code of the status query, and a dictionary of job identifiers to their status. |
Source code in maestrowf/abstracts/interfaces/scriptadapter.py
extension()
Returns the extension that generated scripts will use.
Returns:
Type | Description |
---|---|
A string of the extension |
key()
Return the key name for a ScriptAdapter..
This is used to register the adapter in the ScriptAdapterFactory and when writing the workflow specification.
submit(step, path, cwd, job_map=None, env=None)
abstractmethod
Submit a script to the scheduler.
If cwd is specified, the submit method will operate outside of the path specified by the 'cwd' parameter. If env is specified, the submit method will set the environment variables for submission to the specified values. The 'env' parameter should be a dictionary of environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step |
An instance of a StudyStep. |
required | |
path |
Path to the script to be executed. |
required | |
cwd |
Path to the current working directory. |
required | |
job_map |
A map of workflow step names to their job identifiers. |
None
|
|
env |
A dict containing a modified environment for execution. |
None
|
Returns:
Type | Description |
---|---|
The return code of the submission command and job identiifer. |
Source code in maestrowf/abstracts/interfaces/scriptadapter.py
write_script(ws_path, step)
Generate the script for the specified StudyStep.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ws_path |
Workspace path for the step. |
required | |
step |
An instance of a StudyStep class. |
required |
Returns:
Type | Description |
---|---|
A tuple containing a boolean set to True if step should be scheduled (False otherwise), path to the generate script, and path to the generated restart script (None if step cannot be restarted). |