Skip to content

Commit

Permalink
fix: revert to 95f3e371928
Browse files Browse the repository at this point in the history
because things retrieving the IFT version number didn't work
  • Loading branch information
cpaniaguam committed Aug 19, 2023
1 parent 0634a98 commit b843f4e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 37 deletions.
34 changes: 1 addition & 33 deletions src/IFTPipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,6 @@ include("feature-extraction.jl")
include("tracker.jl")
include("h5.jl")

const iftversion = []
function __init__()
function getiftversion()
deps = Pkg.dependencies()
iftversion = []
for (_, dep) in deps
dep.is_direct_dep || continue
dep.version === nothing && continue
dep.name != "IceFloeTracker" && continue
push!(iftversion, dep.version)
break
end

# For CI tests where IceFloeTracker is not a dependency
try
ift = iftversion[]
catch
return "unknown"
end

ift = iftversion[]
maj = Int(ift.major)
min = Int(ift.minor)
patch = Int(ift.patch)
return "v$maj.$min.$patch"
end

push!(iftversion, getiftversion())
return nothing
end

export cache_vector, sharpen,
sharpen_gray,
preprocess,
Expand All @@ -71,8 +40,7 @@ export cache_vector, sharpen,
mkclitrack!,
mkfilenames,
makeh5files,
getlatlon,
iftversion
getlatlon

export IceFloeTracker
end
29 changes: 27 additions & 2 deletions src/h5.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
function getiftversion()
deps = Pkg.dependencies()
iftversion = []
for (_, dep) in deps
dep.is_direct_dep || continue
dep.version === nothing && continue
dep.name != "IceFloeTracker" && continue
push!(iftversion, dep.version)
break

Check warning on line 9 in src/h5.jl

View check run for this annotation

Codecov / codecov/patch

src/h5.jl#L8-L9

Added lines #L8 - L9 were not covered by tests
end

# For CI tests where IceFloeTracker is not a dependency
try
ift = iftversion[1]
catch
return "unknown"
end

ift = iftversion[1]
maj = Int(ift.major)
min = Int(ift.minor)
patch = Int(ift.patch)
return "v$maj.$min.$patch"

Check warning on line 23 in src/h5.jl

View check run for this annotation

Codecov / codecov/patch

src/h5.jl#L19-L23

Added lines #L19 - L23 were not covered by tests
end

"""
makeh5filename(imgfname, ts)
Expand Down Expand Up @@ -100,7 +125,7 @@ The `index` group contains the spatial coordinates in the source image coordinat
function makeh5files(; pathtosampleimg::String, resdir::String)
latlondata = getlatlon(pathtosampleimg)

iftver = iftversion[]
iftversion = getiftversion()

ptpath = joinpath(resdir, "passtimes.jls")
passtimes = deserialize(ptpath)
Expand Down Expand Up @@ -128,7 +153,7 @@ function makeh5files(; pathtosampleimg::String, resdir::String)
# Add top-level attributes
attrs(file)["fname_reflectance"] = reflectance_refs[i]
attrs(file)["fname_truecolor"] = truecolor_refs[i]
attrs(file)["iftversion"] = iftver
attrs(file)["iftversion"] = iftversion
attrs(file)["crs"] = latlondata["crs"]
attrs(file)["reference"] = "https://doi.org/10.1016/j.rse.2019.111406"
attrs(file)["contact"] = "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions test/test-h5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ getcorners(m) = [m[1, 1], m[end, end]]
latcorners = getcorners(latlondata["latitude"])
loncorners = getcorners(latlondata["longitude"])

_iftversion = IFTPipeline.iftversion[]
iftversion = IFTPipeline.getiftversion()

ptpath = joinpath(resdir, "passtimes.jls")
passtimes = deserialize(ptpath)
Expand Down Expand Up @@ -44,7 +44,7 @@ h5path = joinpath(resdir, "hdf5-files", "20220914T1244.aqua.labeled_image.250m.h
@test typeof(fid) == HDF5.File

# top level attributes
@test attrs(fid)["iftversion"] == _iftversion
@test attrs(fid)["iftversion"] == iftversion
@test attrs(fid)["fname_reflectance"] == reflectance_refs[1]
@test attrs(fid)["fname_truecolor"] == truecolor_refs[1]
@test attrs(fid)["crs"] == latlondata["crs"]
Expand Down

0 comments on commit b843f4e

Please sign in to comment.