|
1 | 1 | const VERSION_DIR_NAME = ".versions" |
2 | 2 | const TEMP_CALC_DIR = "outputs" |
| 3 | +const JOB_SCRIPT_NAME = "job.sh" |
3 | 4 |
|
4 | 5 | @enum JobState BootFail Pending Running Completed Configuring Completing Cancelled Deadline Failed NodeFail OutOfMemory Preempted Requeued Resizing Revoked Suspended Timeout Submitted Unknown PostProcessing Saved |
5 | 6 |
|
@@ -343,18 +344,63 @@ function sanitize_cutoffs!(job::Job) |
343 | 344 | end |
344 | 345 | end |
345 | 346 |
|
346 | | -function RemoteHPC.pull(j::Job, f, t) |
347 | | - @assert ispath(j, f) "File $f not found in jobdir." |
348 | | - RemoteHPC.pull(Server(j.server), joinpath(j, f), t) |
| 347 | +""" |
| 348 | + pull(j::Job, local_dir; calcs=j.calculations, scriptfile=true, infiles=true, versions=false) |
| 349 | + |
| 350 | +Pulls output and input files of a given job to a local directory. |
| 351 | +""" |
| 352 | +function RemoteHPC.pull(j::Job, local_dir; calcs=j.calculations, scriptfile=true, infiles=true, versions=false) |
| 353 | + if !isdir(local_dir) && ispath(local_dir) |
| 354 | + error("$local_dir is not a directory") |
| 355 | + end |
| 356 | + mkpath(local_dir) |
| 357 | + |
| 358 | + s = Server(j.server) |
| 359 | + outfiles = String[] |
| 360 | + for c in calcs |
| 361 | + files = Calculations.outfiles(c) |
| 362 | + if infiles |
| 363 | + push!(files, c.infile) |
| 364 | + end |
| 365 | + for f in files |
| 366 | + remote_files = searchdir(j, f) |
| 367 | + for rem in remote_files |
| 368 | + loc = joinpath(local_dir, splitdir(rem)[end]) |
| 369 | + RemoteHPC.pull(s, rem, loc) |
| 370 | + push!(outfiles, loc) |
| 371 | + end |
| 372 | + end |
| 373 | + end |
| 374 | + if scriptfile |
| 375 | + jdir = joinpath(local_dir, JOB_SCRIPT_NAME) |
| 376 | + RemoteHPC.pull(s, joinpath(j, JOB_SCRIPT_NAME), jdir) |
| 377 | + push!(outfiles, jdir) |
| 378 | + end |
| 379 | + if versions |
| 380 | + rdir = joinpath(j, VERSION_DIR_NAME) |
| 381 | + if ispath(rdir) |
| 382 | + vdir = joinpath(local_dir, VERSION_DIR_NAME) |
| 383 | + if isdir(vdir) |
| 384 | + rm(vdir, recursive=true) |
| 385 | + end |
| 386 | + RemoteHPC.pull(s, rdir, vdir) |
| 387 | + push!(outfiles, vdir) |
| 388 | + end |
| 389 | + end |
| 390 | + tp = joinpath(j, ".remotehpc_info") |
| 391 | + if ispath(s, tp) |
| 392 | + lp = joinpath(local_dir, ".remotehpc_info") |
| 393 | + RemoteHPC.pull(s, tp, lp) |
| 394 | + push!(outfiles, lp) |
| 395 | + end |
| 396 | + return outfiles |
349 | 397 | end |
350 | 398 |
|
351 | 399 | function timestamp(jobdir::AbstractString) |
352 | | - scriptpath = joinpath(jobdir, "job.sh") |
| 400 | + scriptpath = joinpath(jobdir, JOB_SCRIPT_NAME) |
353 | 401 | if ispath(scriptpath) |
354 | 402 | return unix2datetime(mtime(scriptpath)) |
355 | 403 | else |
356 | 404 | return DateTime(0) |
357 | 405 | end |
358 | 406 | end |
359 | | - |
360 | | - |
|
0 commit comments