Skip to content

Commit

Permalink
Only print messages when on main worker
Browse files Browse the repository at this point in the history
  • Loading branch information
theHenks committed Dec 8, 2024
1 parent 19ef8e4 commit 39b6714
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/pars_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check warning on line 41 in src/utils/pars_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/pars_utils.jl#L41

Added line #L41 was not covered by tests
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)

Check warning on line 44 in src/utils/pars_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/pars_utils.jl#L44

Added line #L44 was not covered by tests
# write validity
@lock _writevalidity_lock begin
# get timestamp from filekey
Expand All @@ -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

Check warning on line 58 in src/utils/pars_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/pars_utils.jl#L58

Added line #L58 was not covered by tests
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

Check warning on line 61 in src/utils/pars_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/pars_utils.jl#L61

Added line #L61 was not covered by tests
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
Expand Down

0 comments on commit 39b6714

Please sign in to comment.