Skip to content

Commit

Permalink
feat: move getiftversion-to-__init__
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaniaguam committed Aug 18, 2023
1 parent 2b3d215 commit 313e78d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
34 changes: 33 additions & 1 deletion src/IFTPipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@ 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[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"
end

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

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

export IceFloeTracker
end
27 changes: 1 addition & 26 deletions src/h5.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
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[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"
end

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

iftversion = getiftversion()
iftversion = iftversion[1]

ptpath = joinpath(resdir, "passtimes.jls")
passtimes = deserialize(ptpath)
Expand Down

0 comments on commit 313e78d

Please sign in to comment.