Skip to content

Commit

Permalink
isrunning
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Jun 7, 2018
1 parent 713d42f commit 4397b6a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DFControl.jl
Expand Up @@ -33,7 +33,7 @@ module DFControl
outputdata,

setheaderword!, setserverdir!, setlocaldir!,
save, submit, abort,
save, submit, abort, isrunning,
undo, undo!,
print_info

Expand Down
17 changes: 17 additions & 0 deletions src/job.jl
Expand Up @@ -862,3 +862,20 @@ function outputdata(job::DFJob, inputs::Vector{DFInput}; print=true)
end
outputdata(job::DFJob; kwargs...) = outputdata(job, inputs(job); kwargs...)
outputdata(job::DFJob, filenames...; kwargs...) = outputdata(job, inputs(job, filenames); kwargs...)

function isrunning(job::DFJob)
@assert haskey(job.metadata, :slurmid) error("No slurmid found for job $(job.name)")
cmd = "qstat -f $(job.metadata[:slurmid])"
if runslocal(job)
str = readstring(`$cmd`)
else
str = sshreadstring(job.server, cmd)
end
isempty(str) && return false
splstr = split(str)
for (i,s) in enumerate(splstr)
if s=="job_state"
return any(splstr[i+1] .== ["Q","R"])
end
end
end
2 changes: 1 addition & 1 deletion src/server.jl
Expand Up @@ -112,7 +112,7 @@ function pulloutputs(job::DFJob, server="", server_dir="", local_dir=""; job_fuz
end

sshcmd(server, cmd) = run(`ssh -t $server $cmd`)

sshreadstring(server, cmd) = readstring(`ssh -t $server $cmd`)
"""
qstat(server)
Expand Down

0 comments on commit 4397b6a

Please sign in to comment.