Skip to content
Snippets Groups Projects
Commit 07b69622 authored by François  LAURENT's avatar François LAURENT
Browse files

revert locking

parent 3228ce82
No related branches found
No related tags found
No related merge requests found
Pipeline #104139 passed
...@@ -312,7 +312,7 @@ version = "1.9.0" ...@@ -312,7 +312,7 @@ version = "1.9.0"
[[deps.PlanarLarvae]] [[deps.PlanarLarvae]]
deps = ["DelimitedFiles", "HDF5", "JSON3", "LinearAlgebra", "MAT", "Meshes", "OrderedCollections", "Random", "SHA", "StaticArrays", "Statistics", "StatsBase", "StructTypes"] deps = ["DelimitedFiles", "HDF5", "JSON3", "LinearAlgebra", "MAT", "Meshes", "OrderedCollections", "Random", "SHA", "StaticArrays", "Statistics", "StatsBase", "StructTypes"]
git-tree-sha1 = "bff9bdff96050dffcb681e950ac2547e33c53417" git-tree-sha1 = "fe89d5f592c8ba763a13330cde6696f721f828c7"
repo-rev = "dev" repo-rev = "dev"
repo-url = "https://gitlab.pasteur.fr/nyx/planarlarvae.jl" repo-url = "https://gitlab.pasteur.fr/nyx/planarlarvae.jl"
uuid = "c2615984-ef14-4d40-b148-916c85b43307" uuid = "c2615984-ef14-4d40-b148-916c85b43307"
......
...@@ -628,12 +628,7 @@ function new_write_larva_dataset_hdf5(output_dir, input_data; ...@@ -628,12 +628,7 @@ function new_write_larva_dataset_hdf5(output_dir, input_data;
output_file = joinpath(output_dir, output_file) output_file = joinpath(output_dir, output_file)
c = Threads.Condition() c = Threads.Condition()
h5open(output_file, "w") do h5 h5open(output_file, "w") do h5
lock(c) create_group(h5, "samples")
g = try
create_group(h5, "samples")
finally
unlock(c)
end
sample(loader, :spine) do _, file, counts, segments sample(loader, :spine) do _, file, counts, segments
sampleid, nsegments = counts sampleid, nsegments = counts
@assert length(segments) == nsegments @assert length(segments) == nsegments
...@@ -662,45 +657,34 @@ function new_write_larva_dataset_hdf5(output_dir, input_data; ...@@ -662,45 +657,34 @@ function new_write_larva_dataset_hdf5(output_dir, input_data;
name = "sample_$sampleid" name = "sample_$sampleid"
# transpose for compatibility with h5py # transpose for compatibility with h5py
# see issue https://github.com/JuliaIO/HDF5.jl/issues/785 # see issue https://github.com/JuliaIO/HDF5.jl/issues/785
lock(c) g[name] = permutedims(sample, reverse(1:ndims(sample)))
try sampleid += 1
g[name] = permutedims(sample, reverse(1:ndims(sample))) #
sampleid += 1 d = g[name]
# attributes(d)["larva_number"] = convert(Int, trackid)
d = g[name] # we should set `start_point` instead of `reference_time`, to comply with the
attributes(d)["larva_number"] = convert(Int, trackid) # original format, but this would not make sense here due to interpolation:
# we should set `start_point` instead of `reference_time`, to comply with attributes(d)["reference_time"] = anchortime
# the original format, but this would not make sense here due to attributes(d)["behavior"] = string(label)
# interpolation: attributes(d)["path"] = file.source
attributes(d)["reference_time"] = anchortime
attributes(d)["behavior"] = string(label)
attributes(d)["path"] = file.source
finally
unlock(c)
end
end end
end end
lock(c) attributes(g)["len_traj"] = window_length
try attributes(g)["len_pred"] = window_length
attributes(g)["len_traj"] = window_length attributes(g)["n_samples"] = total_sample_size
attributes(g)["len_pred"] = window_length # extensions
attributes(g)["n_samples"] = total_sample_size counts = Dataloaders.total(index.targetcounts)
# extensions if isnothing(labels)
counts = Dataloaders.total(index.targetcounts) h5["labels"] = string.(keys(classcounts))
if isnothing(labels) h5["label_counts"] = collect(values(classcounts))
h5["labels"] = string.(keys(classcounts)) else
h5["label_counts"] = collect(values(classcounts)) # ensure labels are ordered as provided in input;
else # see https://gitlab.pasteur.fr/nyx/TaggingBackends/-/issues/24
# ensure labels are ordered as provided in input; h5["labels"] = labels
# see https://gitlab.pasteur.fr/nyx/TaggingBackends/-/issues/24 h5["label_counts"] = [classcounts[Symbol(label)] for label in labels]
h5["labels"] = labels end
h5["label_counts"] = [classcounts[Symbol(label)] for label in labels] if !isnothing(frameinterval)
end attributes(g)["frame_interval"] = frameinterval
if !isnothing(frameinterval)
attributes(g)["frame_interval"] = frameinterval
end
finally
unlock(c)
end end
end end
return output_file return output_file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment