|
1 | 1 | ## ================================================================================ |
2 | 2 | ## Deprecated in v0.27 |
3 | 3 | ##================================================================================= |
| 4 | +export AbstractFactor |
| 5 | +const AbstractFactor = AbstractFactorObservation |
| 6 | + |
| 7 | +export AbstractPackedFactor |
| 8 | +const AbstractPackedFactor = AbstractPackedFactorObservation |
| 9 | + |
| 10 | +export FactorOperationalMemory |
| 11 | +const FactorOperationalMemory = FactorSolverCache |
4 | 12 |
|
5 | 13 | @deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...) |
6 | 14 | @deprecate addBlob!(store::AbstractBlobstore, blobId::UUID, data, ::String) addBlob!( |
@@ -73,6 +81,10 @@ function updateVariableSolverData!( |
73 | 81 | fields::Vector{Symbol} = Symbol[]; |
74 | 82 | warn_if_absent::Bool = true, |
75 | 83 | ) |
| 84 | + Base.depwarn( |
| 85 | + "updateVariableSolverData! is deprecated, use mergeVariableState! or copytoVariableState! instead", |
| 86 | + :updateVariableSolverData!, |
| 87 | + ) |
76 | 88 | #This is basically just setSolverData |
77 | 89 | var = getVariable(dfg, variablekey) |
78 | 90 | warn_if_absent && |
@@ -190,6 +202,194 @@ function updateVariableSolverData!( |
190 | 202 | end |
191 | 203 | end |
192 | 204 |
|
| 205 | +## factor refactor deprecations |
| 206 | +Base.@kwdef mutable struct GenericFunctionNodeData{ |
| 207 | + T <: Union{ |
| 208 | + <:AbstractPackedFactorObservation, |
| 209 | + <:AbstractFactorObservation, |
| 210 | + <:FactorSolverCache, |
| 211 | + }, |
| 212 | +} |
| 213 | + eliminated::Bool = false |
| 214 | + potentialused::Bool = false |
| 215 | + edgeIDs::Vector{Int} = Int[] |
| 216 | + fnc::T |
| 217 | + multihypo::Vector{Float64} = Float64[] # TODO re-evaluate after refactoring w #477 |
| 218 | + certainhypo::Vector{Int} = Int[] |
| 219 | + nullhypo::Float64 = 0.0 |
| 220 | + solveInProgress::Int = 0 |
| 221 | + inflation::Float64 = 0.0 |
| 222 | +end |
| 223 | + |
| 224 | +function FactorCompute( |
| 225 | + label::Symbol, |
| 226 | + timestamp::Union{DateTime, ZonedDateTime}, |
| 227 | + nstime::Nanosecond, |
| 228 | + tags::Set{Symbol}, |
| 229 | + solverData::GenericFunctionNodeData, |
| 230 | + solvable::Int, |
| 231 | + variableOrder::Union{Vector{Symbol}, Tuple}; |
| 232 | + observation = getFactorType(solverData), |
| 233 | + state::FactorState = FactorState(), |
| 234 | + solvercache::Base.RefValue{<:FactorSolverCache} = Ref{FactorSolverCache}(), |
| 235 | + id::Union{UUID, Nothing} = nothing, |
| 236 | + smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), |
| 237 | +) |
| 238 | + error( |
| 239 | + "This constructor is deprecated, use FactorCompute(label, variableOrder, solverData; ...) instead", |
| 240 | + ) |
| 241 | + return FactorCompute( |
| 242 | + id, |
| 243 | + label, |
| 244 | + tags, |
| 245 | + Tuple(variableOrder), |
| 246 | + timestamp, |
| 247 | + nstime, |
| 248 | + Ref(solverData), |
| 249 | + Ref(solvable), |
| 250 | + smallData, |
| 251 | + observation, |
| 252 | + state, |
| 253 | + solvercache, |
| 254 | + ) |
| 255 | +end |
| 256 | + |
| 257 | +export getSolverData, setSolverData! |
| 258 | + |
| 259 | +function getSolverData(f::FactorCompute) |
| 260 | + return error( |
| 261 | + "getSolverData(f::FactorCompute) is obsolete, use getState, getObservation, or getCache instead", |
| 262 | + ) |
| 263 | +end |
| 264 | + |
| 265 | +function setSolverData!(f::FactorCompute, data::GenericFunctionNodeData) |
| 266 | + return error( |
| 267 | + "setSolverData!(f::FactorCompute, data::GenericFunctionNodeData) is obsolete, use setState!, or setCache! instead", |
| 268 | + ) |
| 269 | +end |
| 270 | + |
| 271 | +@deprecate unpackFactor(dfg::AbstractDFG, factor::FactorDFG; skipVersionCheck::Bool = false) unpackFactor( |
| 272 | + factor; |
| 273 | + skipVersionCheck, |
| 274 | +) |
| 275 | + |
| 276 | +@deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorCache!( |
| 277 | + args...; |
| 278 | + kwargs..., |
| 279 | +) |
| 280 | + |
| 281 | +export reconstFactorData |
| 282 | +function reconstFactorData end |
| 283 | + |
| 284 | +function decodePackedType( |
| 285 | + dfg::AbstractDFG, |
| 286 | + varOrder::AbstractVector{Symbol}, |
| 287 | + ::Type{T}, |
| 288 | + packeddata::GenericFunctionNodeData{PT}, |
| 289 | +) where {T <: FactorSolverCache, PT} |
| 290 | + error("decodePackedType is obsolete") |
| 291 | + # |
| 292 | + # TODO, to solve IIF 1424 |
| 293 | + # variables = map(lb->getVariable(dfg, lb), varOrder) |
| 294 | + |
| 295 | + # Also look at parentmodule |
| 296 | + usrtyp = convertStructType(PT) |
| 297 | + fulltype = DFG.FunctionNodeData{T{usrtyp}} |
| 298 | + factordata = reconstFactorData(dfg, varOrder, fulltype, packeddata) |
| 299 | + return factordata |
| 300 | +end |
| 301 | + |
| 302 | +export _packSolverData |
| 303 | +function _packSolverData(f::FactorCompute, fnctype::AbstractFactorObservation) |
| 304 | + # |
| 305 | + error("_packSolverData is deprecated, use seperate packing of observation #TODO") |
| 306 | + packtype = convertPackedType(fnctype) |
| 307 | + try |
| 308 | + packed = convert(PackedFunctionNodeData{packtype}, getSolverData(f)) #TODO getSolverData |
| 309 | + packedJson = packed |
| 310 | + return packedJson |
| 311 | + catch ex |
| 312 | + io = IOBuffer() |
| 313 | + showerror(io, ex, catch_backtrace()) |
| 314 | + err = String(take!(io)) |
| 315 | + msg = "Error while packing '$(f.label)' as '$fnctype', please check the unpacking/packing converters for this factor - \r\n$err" |
| 316 | + error(msg) |
| 317 | + end |
| 318 | +end |
| 319 | + |
| 320 | +export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData |
| 321 | + |
| 322 | +const PackedFunctionNodeData{T} = |
| 323 | + GenericFunctionNodeData{T} where {T <: AbstractPackedFactorObservation} |
| 324 | +function PackedFunctionNodeData(args...; kw...) |
| 325 | + error("PackedFunctionNodeData is obsolete") |
| 326 | + return PackedFunctionNodeData{typeof(args[4])}(args...; kw...) |
| 327 | +end |
| 328 | + |
| 329 | +const FunctionNodeData{T} = GenericFunctionNodeData{ |
| 330 | + T, |
| 331 | +} where {T <: Union{<:AbstractFactorObservation, <:FactorSolverCache}} |
| 332 | +FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw...) |
| 333 | + |
| 334 | +# this is the GenericFunctionNodeData for packed types |
| 335 | +#TODO deprecate FactorData in favor of FactorState (with no more distinction between packed and compute) |
| 336 | +const FactorData = PackedFunctionNodeData{AbstractPackedFactorObservation} |
| 337 | + |
| 338 | +function FactorCompute( |
| 339 | + label::Symbol, |
| 340 | + variableOrder::Union{Vector{Symbol}, Tuple}, |
| 341 | + solverData::GenericFunctionNodeData; |
| 342 | + tags::Set{Symbol} = Set{Symbol}(), |
| 343 | + timestamp::Union{DateTime, ZonedDateTime} = now(localzone()), |
| 344 | + solvable::Int = 1, |
| 345 | + nstime::Nanosecond = Nanosecond(0), |
| 346 | + id::Union{UUID, Nothing} = nothing, |
| 347 | + smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), |
| 348 | +) |
| 349 | + Base.depwarn( |
| 350 | + "`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and solvercache should be provided explicitly.", |
| 351 | + :FactorCompute, |
| 352 | + ) |
| 353 | + observation = getFactorType(solverData) |
| 354 | + state = FactorState( |
| 355 | + solverData.eliminated, |
| 356 | + solverData.potentialused, |
| 357 | + solverData.multihypo, |
| 358 | + solverData.certainhypo, |
| 359 | + solverData.nullhypo, |
| 360 | + solverData.solveInProgress, |
| 361 | + solverData.inflation, |
| 362 | + ) |
| 363 | + |
| 364 | + if solverData.fnc isa FactorSolverCache |
| 365 | + solvercache = solverData.fnc |
| 366 | + else |
| 367 | + solvercache = nothing |
| 368 | + end |
| 369 | + |
| 370 | + return FactorCompute( |
| 371 | + label, |
| 372 | + Tuple(variableOrder), |
| 373 | + observation, |
| 374 | + state, |
| 375 | + solvercache; |
| 376 | + id, |
| 377 | + timestamp, |
| 378 | + nstime, |
| 379 | + tags, |
| 380 | + smallData, |
| 381 | + solvable, |
| 382 | + ) |
| 383 | +end |
| 384 | + |
| 385 | +# Deprecated check usefull? # packedFnc = fncStringToData(factor.fnctype, factor.data) |
| 386 | +# Deprecated check usefull? # decodeType = getFactorOperationalMemoryType(dfg) |
| 387 | +# Deprecated check usefull? # fullFactorData = decodePackedType(dfg, factor._variableOrderSymbols, decodeType, packedFnc) |
| 388 | +function fncStringToData(args...; kwargs...) |
| 389 | + @warn "fncStringToData is obsolete, called with" args kwargs |
| 390 | + return error("fncStringToData is obsolete.") |
| 391 | +end |
| 392 | + |
193 | 393 | ## ================================================================================ |
194 | 394 | ## Deprecated in v0.25 |
195 | 395 | ##================================================================================= |
|
0 commit comments