From 19ef8e4f3bdb1ee61cb0ee8f5906decb8a0c7260 Mon Sep 17 00:00:00 2001 From: Florian Henkes Date: Sun, 8 Dec 2024 00:44:23 +0100 Subject: [PATCH 1/2] Fixed import of Distributed for validity creation --- src/utils/pars_utils.jl | 2 +- src/utils/utils.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/pars_utils.jl b/src/utils/pars_utils.jl index 5f26c048..084cfdee 100644 --- a/src/utils/pars_utils.jl +++ b/src/utils/pars_utils.jl @@ -38,7 +38,7 @@ Write validity for a given filekey. function writevalidity end export writevalidity function writevalidity(props_db::LegendDataManagement.MaybePropsDB, filekey::FileKey, apply::Vector{String}; category::DataCategoryLike=:all) - remotecall_fetch(_writevalidity_impl, 1, props_db, filekey, apply; category=category) + Distributed.remotecall_fetch(_writevalidity_impl, 1, props_db, filekey, apply; category=category) end const _writevalidity_lock = ReentrantLock() function _writevalidity_impl(props_db::LegendDataManagement.MaybePropsDB, filekey::FileKey, apply::Vector{String}; category::DataCategoryLike=:all) diff --git a/src/utils/utils.jl b/src/utils/utils.jl index 12d7024f..ea632152 100644 --- a/src/utils/utils.jl +++ b/src/utils/utils.jl @@ -14,6 +14,7 @@ using JSON using Dates using Measurements using Measurements: ± +import Distributed using PropertyFunctions: PropertyFunction, @pf, filterby, props2varsyms using Tables From 39b6714f407ef66fe7ab6eacd9fe9d8943df59ec Mon Sep 17 00:00:00 2001 From: Florian Henkes Date: Mon, 9 Dec 2024 00:20:54 +0100 Subject: [PATCH 2/2] Only print messages when on main worker --- src/utils/pars_utils.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/pars_utils.jl b/src/utils/pars_utils.jl index 084cfdee..556e42ad 100644 --- a/src/utils/pars_utils.jl +++ b/src/utils/pars_utils.jl @@ -38,10 +38,10 @@ Write validity for a given filekey. function writevalidity end export writevalidity function writevalidity(props_db::LegendDataManagement.MaybePropsDB, filekey::FileKey, apply::Vector{String}; category::DataCategoryLike=:all) - Distributed.remotecall_fetch(_writevalidity_impl, 1, props_db, filekey, apply; category=category) + Distributed.remotecall_fetch(_writevalidity_impl, 1, props_db, filekey, apply; category=category, write_from_master= (Distributed.myid() == 1)) end const _writevalidity_lock = ReentrantLock() -function _writevalidity_impl(props_db::LegendDataManagement.MaybePropsDB, filekey::FileKey, apply::Vector{String}; category::DataCategoryLike=:all) +function _writevalidity_impl(props_db::LegendDataManagement.MaybePropsDB, filekey::FileKey, apply::Vector{String}; category::DataCategoryLike=:all, write_from_master::Bool=true) # write validity @lock _writevalidity_lock begin # get timestamp from filekey @@ -55,10 +55,10 @@ function _writevalidity_impl(props_db::LegendDataManagement.MaybePropsDB, fileke # check if given validity already exists is_validity = findall(x -> contains(x, "$pars_validTimeStamp") && contains(x, "$(string(category))"), validity_lines) if isempty(is_validity) - @info "Write new validity for $pars_validTimeStamp" + if write_from_master @info "Write new validity for $pars_validTimeStamp" end push!(validity_lines, "{\"valid_from\":\"$pars_validTimeStamp\", \"category\":\"$(string(category))\", \"apply\":[\"$(join(sort(apply), "\", \""))\"]}") elseif length(is_validity) == 1 - @info "Merge old $pars_validTimeStamp $(string(category)) validity entry" + if write_from_master @info "Merge old $pars_validTimeStamp $(string(category)) validity entry" end apply = unique(append!(Vector{String}(JSON.parse(validity_lines[first(is_validity)])["apply"]), apply)) validity_lines[first(is_validity)] = "{\"valid_from\":\"$pars_validTimeStamp\", \"category\":\"$(string(category))\", \"apply\":[\"$(join(sort(apply), "\", \""))\"]}" end