distribute
Module for Distribution of commands found for individual poses to SLURM/PBS computational cluster
is_sbatch_available
is_sbatch_available() -> bool
Ensure the sbatch executable is available and executable
Source code in symdesign/resources/distribute.py
35 36 37 38 39 40 41 42 43 |
|
create_file
create_file(file: AnyStr = None)
If file doesn't exist, create a blank one
Source code in symdesign/resources/distribute.py
144 145 146 147 148 |
|
run
run(cmd: list[str] | AnyStr, log_file_name: str, program: str = None, srun: str = None) -> bool
Executes specified command and appends command results to log file
Parameters:
-
cmd
(list[str] | AnyStr
) –The name of a command file which should be executed by the system
-
log_file_name
(str
) –Location on disk of log file
-
program
(str
, default:None
) –The interpreter for said command
-
srun
(str
, default:None
) –Whether to utilize a job step prefix during command issuance
Returns: Whether the command executed successfully
Source code in symdesign/resources/distribute.py
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 |
|
check_scripts_exist
check_scripts_exist(directives: Iterable[str] = None, file: AnyStr = None)
Check for the existence of scripts provided by an Iterable or present in a file
Parameters:
-
directives
(Iterable[str]
, default:None
) –The locations of scripts which should be executed
-
file
(AnyStr
, default:None
) –The location of a file containing the location(s) of scripts/commands
Raises: InputError: When the scripts/commands passed are malformed or do not exist Returns: None
Source code in symdesign/resources/distribute.py
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 |
|
distribute
distribute(file: AnyStr, scale: protocols_literal, number_of_commands: int, out_path: AnyStr = os.getcwd(), success_file: AnyStr = None, failure_file: AnyStr = None, log_file: AnyStr = None, max_jobs: int = 80, mpi: int = None, finishing_commands: Iterable[str] = None, batch: bool = is_sbatch_available(), **kwargs) -> str
Take a file of commands formatted for execution in the SLURM environment and process into a script
Parameters:
-
file
(AnyStr
) –The location of the file which contains your commands to distribute through a sbatch array
-
scale
(protocols_literal
) –The stage of design to distribute. Works with CommandUtils and PathUtils to allocate jobs
-
number_of_commands
(int
) –The size of the job array
-
out_path
(AnyStr
, default:getcwd()
) –Where to write out the sbatch script
-
success_file
(AnyStr
, default:None
) –What file to write the successful jobs to for job organization
-
failure_file
(AnyStr
, default:None
) –What file to write the failed jobs to for job organization
-
log_file
(AnyStr
, default:None
) –The name of a log file to write command results to
-
max_jobs
(int
, default:80
) –The size of the job array limiter. This caps the number of commands executed at once
-
mpi
(int
, default:None
) –The number of processes to run concurrently with MPI
-
finishing_commands
(Iterable[str]
, default:None
) –Commands to run once all sbatch processes are completed
-
batch
(bool
, default:is_sbatch_available()
) –Whether the distribution file should be formatted as a SLURM sbatch script
Returns: The name of the script that was written
Source code in symdesign/resources/distribute.py
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 |
|
commands
commands(commands: Sequence[str], name: str, protocol: protocols_literal, out_path: AnyStr = os.getcwd(), commands_out_path: AnyStr = None, **kwargs) -> str
Given a batch of commands, write them to a file and distribute that work for completion using specified computational resources
Parameters:
-
commands
(Sequence[str]
) –The commands which should be written to a file and then formatted for distribution
-
name
(str
) –The name of the collection of commands. Will be applied to commands file and distribution file(s)
-
protocol
(protocols_literal
) –The type of protocol to distribute
-
out_path
(AnyStr
, default:getcwd()
) –Where should the distributed script be written?
-
commands_out_path
(AnyStr
, default:None
) –Where should the commands file be written? If not specified, is written to out_path
Other Parameters:
-
success_file
–AnyStr = None - What file to write the successful jobs to for job organization
-
failure_file
–AnyStr = None - What file to write the failed jobs to for job organization
-
log_file
–AnyStr = None - The name of a log file to write command results to
-
max_jobs
–int = 80 - The size of the job array limiter. This caps the number of commands executed at once
-
mpi
–bool = False - The number of processes to run concurrently with MPI
-
finishing_commands
–Iterable[str] = None - Commands to run once all sbatch processes are completed
-
batch
–bool = is_sbatch_available() - Whether the distribution file should be formatted as a SLURM sbatch script
Returns:
-
str
–The name of the distribution script that was written
Source code in symdesign/resources/distribute.py
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 343 344 |
|
write_script
write_script(command: str, name: str = 'script', out_path: AnyStr = os.getcwd(), additional: list = None, shell: str = 'bash', status_wrap: str = None) -> AnyStr
Take a command and write to a name.sh script. By default, bash is used as the shell interpreter
Parameters:
-
command
(str
) –The command formatted using subprocess.list2cmdline(list())
-
name
(str
, default:'script'
) –The name of the output shell script
-
out_path
(AnyStr
, default:getcwd()
) –The location where the script will be written
-
additional
(list
, default:None
) –Additional commands also formatted using subprocess.list2cmdline()
-
shell
(str
, default:'bash'
) –The shell which should interpret the script
-
status_wrap
(str
, default:None
) –The name of a file in which to check and set the status of the command in the shell
Returns: The name of the file
Source code in symdesign/resources/distribute.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
write_commands
write_commands(commands: Iterable[str], name: str = 'all_commands', out_path: AnyStr = os.getcwd()) -> AnyStr
Write a list of commands out to a file
Parameters:
-
commands
(Iterable[str]
) –An iterable with the commands as values
-
name
(str
, default:'all_commands'
) –The name of the file. Will be appended with '.cmd(s)'
-
out_path
(AnyStr
, default:getcwd()
) –The directory where the file will be written
Returns: The filename of the new file
Source code in symdesign/resources/distribute.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|