|
1 | 1 | ## Version checking |
2 | 2 | #NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module) |
3 | 3 | function _getDFGVersion() |
4 | | - if VERSION >= v"1.9" |
5 | | - return pkgversion(DistributedFactorGraphs) |
6 | | - end |
7 | | - #TODO when we drop jl<1.9 remove the rest here |
8 | | - pkgorigin = get(Base.pkgorigins, Base.PkgId(DistributedFactorGraphs), nothing) |
9 | | - if !isnothing(pkgorigin) && !isnothing(pkgorigin.version) |
10 | | - return pkgorigin.version |
11 | | - end |
12 | | - dep = |
13 | | - get(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"), nothing) |
14 | | - if !isnothing(dep) |
15 | | - return dep.version |
16 | | - else |
17 | | - # This is arguably slower, but needed for Travis. |
18 | | - return Pkg.TOML.parse( |
19 | | - read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String), |
20 | | - )["version"] |> VersionNumber |
21 | | - end |
| 4 | + return pkgversion(DistributedFactorGraphs) |
22 | 5 | end |
23 | 6 |
|
24 | 7 | function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG}) |
25 | | - if VersionNumber(node._version).minor < _getDFGVersion().minor |
| 8 | + if node._version.minor < _getDFGVersion().minor |
26 | 9 | @warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog = |
27 | 10 | 10 |
28 | 11 | end |
@@ -159,7 +142,7 @@ function packVariableState(d::VariableState{T}) where {T <: VariableStateType} |
159 | 142 | d.solvedCount, |
160 | 143 | d.solveKey, |
161 | 144 | isempty(d.covar) ? Float64[] : vec(d.covar[1]), |
162 | | - string(_getDFGVersion()), |
| 145 | + _getDFGVersion(), |
163 | 146 | ) |
164 | 147 | end |
165 | 148 |
|
@@ -234,7 +217,7 @@ function packVariable( |
234 | 217 | solvable = v.solvable, |
235 | 218 | variableType = stringVariableType(DFG.getVariableType(v)), |
236 | 219 | blobEntries = collect(values(v.dataDict)), |
237 | | - _version = string(DFG._getDFGVersion()), |
| 220 | + _version = _getDFGVersion(), |
238 | 221 | ) |
239 | 222 | end |
240 | 223 |
|
@@ -312,7 +295,7 @@ function packFactor(f::FactorCompute) |
312 | 295 | solvable = getSolvable(f), |
313 | 296 | metadata = base64encode(JSON3.write(f.smallData)), |
314 | 297 | # Pack the node data |
315 | | - _version = string(_getDFGVersion()), |
| 298 | + _version = _getDFGVersion(), |
316 | 299 | state = f.state, |
317 | 300 | observJSON = JSON3.write(packObservation(f)), |
318 | 301 | ) |
|
0 commit comments