Skip to content

Commit

Permalink
Added barrier so running jobs don't get version switched and metadata…
Browse files Browse the repository at this point in the history
… loading saving
  • Loading branch information
Louis Ponet committed Jun 10, 2021
1 parent dfe8a54 commit 2871c0c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Media = "e89f7d12-3494-54d1-8411-f7d8b9ae1f27"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Expand Down
3 changes: 2 additions & 1 deletion src/DFControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module DFControl
using Parameters
using FileIO
import FileIO: save

using JLD2

using spglib_jll
const SPGLIB = spglib_jll.libsymspg

Expand Down
1 change: 1 addition & 0 deletions src/fileio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ function writejobfiles(job::DFJob; kwargs...)
end
write_job_postamble(f, job)
end
jldsave(joinpath(job, ".metadata.jld2"); metadata=job.metadata)
end

function read_job_line(line)
Expand Down
14 changes: 14 additions & 0 deletions src/job.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Represents a full DFT job with multiple input files and calculations.
structure.name = split(name, "_")[1]
end
last_version = last_job_version(local_dir)
if isempty(metadata)
mpath = joinpath(local_dir, ".metadata.jld2")
if ispath(mpath)
metadata = load(mpath, "metadata")
end
end
out = new(name, structure, calculations, local_dir, server, server_dir, header, metadata, version)
# TODO add check_version, and if it doesn't match the one that's currently in the main directory,
# load the previous one from the versions
Expand Down Expand Up @@ -268,4 +274,12 @@ for f in (:cp, :mv)
end
end

is_slurm_job(job::DFJob) = haskey(job.metadata, :slurmid)

function isrunning(job::DFJob; print=true)
if is_slurm_job(job)
return slurm_isrunning(job)
end
print && @warn "Job scheduler unknown."
return false
end
1 change: 1 addition & 0 deletions src/versioning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function maybe_increment_version(job::DFJob)
end

function switch_version(job::DFJob, version)
@assert !isrunning(job; print=false) "Can't switch job versions on a running job."
cur_version = job.version
if version != cur_version
verpath = version_path(job.local_dir, version)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testdir = @__DIR__
@time @testset "constants" begin @suppress include("constant_tests.jl") end
@time @testset "documenation" begin @suppress include("documentation_tests.jl") end
@time @testset "Setting defaults" begin @suppress include("defaults_tests.jl") end
@time @testset "Job from CIF file" begin include("jobfromcif_tests.jl") end
@time @testset "Job from CIF file" begin @suppress include("jobfromcif_tests.jl") end
@time @testset "Job control tests" begin @suppress include("job_control_tests.jl") end
@time @testset "Remove defaults" begin @suppress include("rmdefaults_tests.jl") end
end

0 comments on commit 2871c0c

Please sign in to comment.