Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix write_validity #84

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)
fhagemann marked this conversation as resolved.
Show resolved Hide resolved
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 @@
# 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
1 change: 1 addition & 0 deletions src/utils/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using JSON
using Dates
using Measurements
using Measurements: ±
import Distributed

using PropertyFunctions: PropertyFunction, @pf, filterby, props2varsyms
using Tables
Expand Down
Loading