Skip to content

Commit 206c6c0

Browse files
committed
Fix bad _getDFGVersion and small updates
1 parent 69aba28 commit 206c6c0

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export getPPEDict, getVariablePPEDict, getVariablePPE
173173

174174
# CRUD & SET
175175
export getPPE,
176+
getPPEs,
176177
getVariablePPE,
177178
addPPE!,
178179
updatePPE!,

src/entities/DFGVariable.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,33 @@ Base.@kwdef struct PackedVariable <: AbstractDFGVariable
193193
solverData::Vector{PackedVariableNodeData} = PackedVariableNodeData[]
194194
end
195195

196+
#IIF like contruction helper for packed variable
197+
function PackedVariable(
198+
label::Symbol,
199+
variableType::String;
200+
tags::Vector{Symbol} = Symbol[],
201+
timestamp::ZonedDateTime = now(tz"UTC"),
202+
solvable::Int = 1,
203+
nanosecondtime::Int64 = 0,
204+
smalldata::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
205+
kwargs...
206+
)
207+
union!(tags, [:VARIABLE])
208+
209+
pacvar = PackedVariable(;
210+
label,
211+
variableType,
212+
nstime = string(nanosecondtime),
213+
solvable,
214+
tags,
215+
metadata = base64encode(JSON3.write(smalldata)),
216+
timestamp,
217+
kwargs...
218+
)
219+
220+
return pacvar
221+
end
222+
196223
StructTypes.StructType(::Type{PackedVariable}) = StructTypes.UnorderedStruct()
197224
StructTypes.idproperty(::Type{PackedVariable}) = :id
198225
StructTypes.omitempties(::Type{PackedVariable}) = (:id,)
@@ -265,7 +292,7 @@ DFGVariable(label::Symbol,
265292
solverDataDict::Dict{Symbol, VariableNodeData{T,P}}=Dict{Symbol, VariableNodeData{T,getPointType(T)}}(),
266293
kw...) where {T <: InferenceVariable, P} = DFGVariable(label, T; solverDataDict=solverDataDict, kw...)
267294
#
268-
@deprecate DFGVariable(label::Symbol, T_::Type{<:InferenceVariable},w...; timestamp::DateTime=now(),kw...) DFGVariable(label, T_, w...; timestamp=ZonedDateTime(timestamp), kw...)
295+
# @deprecate DFGVariable(label::Symbol, T_::Type{<:InferenceVariable},w...; timestamp::DateTime=now(),kw...) DFGVariable(label, T_, w...; timestamp=ZonedDateTime(timestamp), kw...)
269296
#
270297

271298

src/services/AbstractDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ function copyGraph!(destDFG::AbstractDFG,
952952
# And then all factors to the destDFG.
953953
for factor in sourceFactors
954954
# Get the original factor variables (we need them to create it)
955-
sourceFactorVariableIds = getNeighbors(sourceDFG, factor)
955+
sourceFactorVariableIds = collect(factor._variableOrderSymbols)
956956
# Find the labels and associated variables in our new subgraph
957957
factVariableIds = Symbol[]
958958
for variable in sourceFactorVariableIds

src/services/DFGVariable.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ function getPPE(vari::VariableDataLevel1, solveKey::Symbol=:default)
389389
# return haskey(ppeDict, solveKey) ? ppeDict[solveKey] : nothing
390390
end
391391

392+
"""
393+
$SIGNATURES
394+
395+
Get all the parametric point estimate (PPE) for a variable in the factor graph.
396+
"""
397+
function getPPEs end
398+
392399
# afew more aliases on PPE, brought back from deprecated DF
393400

394401
"""

src/services/Serialization.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ export _packSolverData
66
const TYPEKEY = "_type"
77

88
## Version checking
9-
# FIXME return VersionNumber
9+
#NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module)
1010
function _getDFGVersion()
11-
if haskey(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"))
12-
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version) |> VersionNumber
11+
12+
pkgorigin = get(Base.pkgorigins, Base.PkgId(DistributedFactorGraphs), nothing)
13+
if !isnothing(pkgorigin)
14+
return pkgorigin.version
15+
end
16+
dep = get(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"), nothing)
17+
if !isnothing(dep)
18+
return dep.version
1319
else
1420
# This is arguably slower, but needed for Travis.
1521
return Pkg.TOML.parse(read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String))["version"] |> VersionNumber
@@ -18,7 +24,7 @@ end
1824

1925
function _versionCheck(node::Union{<:PackedVariable, <:PackedFactor})
2026
if VersionNumber(node._version) < _getDFGVersion()
21-
@warn "This data was serialized using DFG $(props["_version"]) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog=10
27+
@warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog=10
2228
end
2329
end
2430

0 commit comments

Comments
 (0)