Skip to content

Commit

Permalink
last_submission get(calc, flag, asdf)
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Jun 28, 2021
1 parent b89ccce commit 04d4d42
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/src/guide/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set_flow!
save(::DFJob)
submit
isrunning
last_submission
last_running_calculation
abort
```
Expand Down
1 change: 1 addition & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export gencalc_scf, gencalc_vcrelax, gencalc_nscf, gencalc_bands, gencalc_projwf
include("jobAPI.jl")
#Basic Job Control Functionality
export save, submit, abort, set_flow!, set_headerword!, isrunning, last_running_calculation,
last_submission,
progressreport, set_serverdir!, set_localdir!, structure, scale_cell!, volume,
switch_version!, version, versions, registered_jobs, rm_version!, rm_versions!,
rm_tmp_dirs!, cleanup, load_jobs, last_version
Expand Down
11 changes: 7 additions & 4 deletions src/calculation.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#these are all the control data, they hold the flags that guide the calculation
name(data::InputData) = data.name
function Base.:(==)(d1::InputData, d2::InputData)
return all(x -> getfield(d1, x) == getfield(d2, x), fieldnames(InputData))
end

name(c::DFCalculation) = c.name
dir(c::DFCalculation) = c.dir
flags(c::DFCalculation) = c.flags
Expand All @@ -29,6 +25,13 @@ function flag(calculation::DFCalculation, flag::Symbol)
end
end

function Base.:(==)(d1::InputData, d2::InputData)
return all(x -> getfield(d1, x) == getfield(d2, x), fieldnames(InputData))
end

Base.get(c::DFCalculation, args...) = get(flags(c), args...)


Base.eltype(::DFCalculation{P}) where {P} = P
package(::DFCalculation{P}) where {P} = P

Expand Down
10 changes: 10 additions & 0 deletions src/jobAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,13 @@ function pdos(job::DFJob, atoms::Vector{AbstractAtom} = atoms(job), args...)
end
return (energies = t_energies, pdos = t_pdos)
end

"""
last_submission(job::DFJob)
If a job was ever submitted, the last submission date is returned.
Otherwise 0 date is returned.
"""
function last_submission(job::DFJob)
return get(job.metadata, :timestap, DateTime(0))
end

0 comments on commit 04d4d42

Please sign in to comment.