From c40e3cc6173657b4f635dc480e0e54eb810c089a Mon Sep 17 00:00:00 2001 From: singularitti Date: Sat, 14 Oct 2023 22:36:34 -0400 Subject: [PATCH] Fix `ExtractData` in src/ConvergenceTestWorkflow/actions.jl --- src/ConvergenceTestWorkflow/actions.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ConvergenceTestWorkflow/actions.jl b/src/ConvergenceTestWorkflow/actions.jl index 4b54398..f2537a6 100644 --- a/src/ConvergenceTestWorkflow/actions.jl +++ b/src/ConvergenceTestWorkflow/actions.jl @@ -12,13 +12,22 @@ using UnitfulAtomic import Express.ConvergenceTestWorkflow: CreateInput, ExtractData import ExpressBase: RunCmd +struct DataExtractionFailed <: Exception + msg::String +end + function (::ExtractData)(file) str = read(file, String) + preamble = tryparse(Preamble, str) e = try parse_electrons_energies(str, :converged) catch end - return e.ε[end] * u"Ry" + if preamble !== nothing && !isempty(e) + return preamble.ecutwfc * u"Ry" => e.ε[end] * u"Ry" # volume, energy + else + throw(DataExtractionFailed("no data found in file $file.")) + end end (::CreateInput)(template::PWInput, args...) = (customizer(args...) ∘ normalizer())(template)