Skip to content

Commit 47524fc

Browse files
committed
improved pulling of output files
1 parent d017642 commit 47524fc

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "DFControl"
22
uuid = "1e31e15d-4957-550d-a244-318eced754ae"
33
authors = ["Louis Ponet <[email protected]>"]
44
repo = "https://github.com/louisponet/DFControl.jl.git"
5-
version = "0.5.27"
5+
version = "0.5.28"
66

77
[deps]
88
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"

src/Jobs/job.jl

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const VERSION_DIR_NAME = ".versions"
22
const TEMP_CALC_DIR = "outputs"
3+
const JOB_SCRIPT_NAME = "job.sh"
34

45
@enum JobState BootFail Pending Running Completed Configuring Completing Cancelled Deadline Failed NodeFail OutOfMemory Preempted Requeued Resizing Revoked Suspended Timeout Submitted Unknown PostProcessing Saved
56

@@ -343,18 +344,63 @@ function sanitize_cutoffs!(job::Job)
343344
end
344345
end
345346

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
349397
end
350398

351399
function timestamp(jobdir::AbstractString)
352-
scriptpath = joinpath(jobdir, "job.sh")
400+
scriptpath = joinpath(jobdir, JOB_SCRIPT_NAME)
353401
if ispath(scriptpath)
354402
return unix2datetime(mtime(scriptpath))
355403
else
356404
return DateTime(0)
357405
end
358406
end
359-
360-

0 commit comments

Comments
 (0)