-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDeprecated.jl
More file actions
810 lines (725 loc) · 27.9 KB
/
Deprecated.jl
File metadata and controls
810 lines (725 loc) · 27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
## ================================================================================
## Deprecated in v0.28
##=================================================================================
abstract type AbstractRelativeMinimize <: RelativeObservation end
abstract type AbstractManifoldMinimize <: RelativeObservation end
const SkeletonDFGVariable = VariableSkeleton
const DFGVariableSummary = VariableSummary
const PackedVariable = VariableDFG
const Variable = VariableDFG
const DFGVariable = VariableCompute
const SkeletonDFGFactor = FactorSkeleton
const DFGFactorSummary = FactorSummary
const DFGFactor = FactorCompute
const PackedFactor = FactorDFG
const Factor = FactorDFG
const SmallDataTypes = MetadataTypes
const AbstractPrior = PriorObservation
const AbstractRelative = RelativeObservation
const AbstractParams = AbstractDFGParams
const InferenceVariable = StateType{Any}
const InferenceType = AbstractPackedObservation
const PackedSamplableBelief = PackedBelief
const getVariableState = getState
const addVariableState! = addState!
const mergeVariableState! = mergeState!
const deleteVariableState! = deleteState!
const listVariableStates = listStates
const VariableState = State
const VariableStateType = StateType
const copytoVariableState! = copytoState!
# """
# $SIGNATURES
# Set solver data structure stored in a variable.
# """
function setSolverData!(v::VariableCompute, data::State, key::Symbol = :default)
Base.depwarn(
"setSolverData!(v::VariableCompute, data::State, key::Symbol = :default) is deprecated, use mergeState! instead.",
:setSolverData!,
)
@assert key == data.solveKey "State.solveKey=:$(data.solveKey) does not match requested :$(key)"
return v.solverDataDict[key] = data
end
@deprecate mergeVariableSolverData!(args...; kwargs...) mergeState!(args...; kwargs...)
function mergeVariableData!(args...)
return error(
"mergeVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
)
end
function mergeGraphVariableData!(args...)
return error(
"mergeGraphVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
)
end
# """
# $(SIGNATURES)
# Gives back all factor labels that fit the bill:
# lsWho(dfg, :Pose3)
# Notes
# - Returns `Vector{Symbol}`
# Dev Notes
# - Cloud versions will benefit from less data transfer
# - `ls(dfg::C, ::T) where {C <: CloudDFG, T <: ..}`
# Related
# ls, lsf, lsfPriors
# """
function lsWho(dfg::AbstractDFG, type::Symbol)
Base.depwarn("lsWho(dfg, type) is deprecated, use ls(dfg, type) instead.", :lsWho)
vars = getVariables(dfg)
labels = Symbol[]
for v in vars
varType = typeof(getVariableType(v)) |> nameof
varType == type && push!(labels, v.label)
end
return labels
end
# solvekey is deprecated and sync!/copyto! is the better verb.
#TODO replace with syncStates! or similar
# """
# $SIGNATURES
# Duplicate a `solveKey`` into a destination from a source.
# Notes
# - Can copy between graphs, or to different solveKeys within one graph.
# """
function cloneSolveKey!(
dest_dfg::AbstractDFG,
dest::Symbol,
src_dfg::AbstractDFG,
src::Symbol;
solvable::Int = 0,
labels = intersect(ls(dest_dfg; solvable = solvable), ls(src_dfg; solvable = solvable)),
verbose::Bool = false,
)
#
for x in labels
sd = deepcopy(getState(getVariable(src_dfg, x), src))
copytoState!(dest_dfg, x, dest, sd)
end
return nothing
end
function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...)
#
@assert dest != src "Must copy to a different solveKey within the same graph, $dest."
return cloneSolveKey!(dfg, dest, dfg, src; kw...)
end
#TODO not a good function, as it's not complete.
# """
# $(SIGNATURES)
# Convenience function to get all the metadata of a DFG
# """
function getDFGInfo(dfg::AbstractDFG)
return (
description = getDescription(dfg),
agentLabel = getAgentLabel(dfg),
graphLabel = getGraphLabel(dfg),
agentMetadata = getAgentMetadata(dfg),
graphMetadata = getGraphMetadata(dfg),
solverParams = getSolverParams(dfg),
)
end
# """
# $TYPEDSIGNATURES
# List all the solvekeys used amongst all variables in the distributed factor graph object.
# Related
# [`listSolveKeys`](@ref), [`getSolverDataDict`](@ref), [`listVariables`](@ref)
# """
function listSolveKeys(
variable::VariableCompute,
filterSolveKeys::Union{Regex, Nothing} = nothing,
skeys = Set{Symbol}(),
)
Base.depwarn("listSolveKeys is deprecated, use listStates instead.", :listSolveKeys)
#
for ky in keys(getSolverDataDict(variable))
push!(skeys, ky)
end
#filter the solveKey set with filterSolveKeys regex
!isnothing(filterSolveKeys) &&
return filter!(k -> occursin(filterSolveKeys, string(k)), skeys)
return skeys
end
function listSolveKeys(
dfg::AbstractDFG,
lbl::Symbol,
filterSolveKeys::Union{Regex, Nothing} = nothing,
skeys = Set{Symbol}(),
)
return listSolveKeys(getVariable(dfg, lbl), filterSolveKeys, skeys)
end
#
function listSolveKeys(
dfg::AbstractDFG,
filterVariables::Union{Type{<:StateType}, Regex, Nothing} = nothing;
filterSolveKeys::Union{Regex, Nothing} = nothing,
tags::Vector{Symbol} = Symbol[],
solvable::Int = 0,
)
#
skeys = Set{Symbol}()
varList = listVariables(dfg, filterVariables; tags = tags, solvable = solvable)
for vs in varList #, ky in keys(getSolverDataDict(getVariable(dfg, vs)))
listSolveKeys(dfg, vs, filterSolveKeys, skeys)
end
# done inside the loop
# #filter the solveKey set with filterSolveKeys regex
# !isnothing(filterSolveKeys) && return filter!(k -> occursin(filterSolveKeys, string(k)), skeys)
return skeys
end
const listSupersolves = listSolveKeys
#TODO mergeBlobentries! does not fit with merge definition, should probably be updated to copyto or sync.
# leaving here until it is done.
# """
# $SIGNATURES
# Add a blob entry into the destination variable which already exists
# in a source variable.
# See also: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`listBlobentries`](@ref), [`getBlob`](@ref)
# """
function mergeBlobentries!(
dst::AbstractDFG,
dlbl::Symbol,
src::AbstractDFG,
slbl::Symbol,
bllb::Union{Symbol, UUID, <:AbstractString, Regex},
)
#
_makevec(s) = [s;]
_makevec(s::AbstractVector) = s
des_ = getBlobentry(src, slbl, bllb)
des = _makevec(des_)
# don't add data entries that already exist
dde = listBlobentries(dst, dlbl)
# HACK, verb list should just return vector of Symbol. NCE36
_getid(s) = s
_getid(s::Blobentry) = s.id
uids = _getid.(dde) # (s->s.id).(dde)
filter!(s -> !(_getid(s) in uids), des)
# add any data entries not already in the destination variable, by uuid
return addBlobentry!.(dst, dlbl, des)
end
function mergeBlobentries!(
dst::AbstractDFG,
dlbl::Symbol,
src::AbstractDFG,
slbl::Symbol,
::Colon = :,
)
des = listBlobentries(src, slbl)
# don't add data entries that already exist
uids = listBlobentries(dst, dlbl)
# verb list should just return vector of Symbol. NCE36
filter!(s -> !(s in uids), des)
if 0 < length(des)
union(((s -> mergeBlobentries!(dst, dlbl, src, slbl, s)).(des))...)
end
end
function mergeBlobentries!(
dest::AbstractDFG,
src::AbstractDFG,
w...;
varList::AbstractVector = listVariables(dest) |> sortDFG,
)
@showprogress 1 "merging data entries" for vl in varList
mergeBlobentries!(dest, vl, src, vl, w...)
end
return varList
end
# """
# $(SIGNATURES)
# Get all blob entries matching a Regex pattern over variables
# Notes
# - Use `dropEmpties=true` to not include empty lists in result.
# - Use keyword `varList` for which variables to search through.
# """
function getBlobentriesVariables(
dfg::AbstractDFG,
bLblPattern::Regex;
varList::AbstractVector{Symbol} = sort(listVariables(dfg); lt = natural_lt),
dropEmpties::Bool = false,
)
Base.depwarn(
"getBlobentriesVariables is deprecated, use gatherBlobentries instead.",
:getBlobentriesVariables,
)
RETLIST = Vector{Vector{Blobentry}}()
@showprogress "Get entries matching $bLblPattern" for vl in varList
bes = filter(s -> occursin(bLblPattern, string(s.label)), listBlobentries(dfg, vl))
# only push to list if there are entries on this variable
(!dropEmpties || 0 < length(bes)) ? nothing : continue
push!(RETLIST, bes)
end
return RETLIST
end
function getBlobentries(dfg::AbstractDFG, label::Symbol, regex::Regex)
Base.depwarn(
"getBlobentries(dfg, label, ::Regex) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.",
:getBlobentries,
)
return entries = getBlobentries(dfg, label; labelFilter = contains(regex))
end
function getBlobentries(
dfg::AbstractDFG,
label::Symbol,
skey::Union{Symbol, <:AbstractString},
)
Base.depwarn(
"getBlobentries(dfg, label, ::Union{Symbol, <:AbstractString}) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.",
:getBlobentries,
)
return getBlobentries(dfg, label, Regex(string(skey)))
end
function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID)
Base.depwarn(
"getfirstBlobentry(var, blobId) is deprecated, use getfirstBlobentry(var; blobIdFilter = ==(string(blobId))) instead.",
:getfirstBlobentry,
)
return getfirstBlobentry(var; blobIdFilter = ==(string(blobId)))
end
function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID)
Base.depwarn(
"getfirstBlobentry(dfg, label, blobId) is deprecated, use getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId))) instead.",
:getfirstBlobentry,
)
return getfirstBlobentry(dfg, label; blobIdFilter = ==(string(blobId)))
end
function getfirstBlobentry(var::AbstractGraphVariable, key::Regex)
Base.depwarn(
"getfirstBlobentry(var, key::Regex) is deprecated, use getfirstBlobentry(var; labelFilter=contains(key)) instead.",
:getfirstBlobentry,
)
return getfirstBlobentry(var; labelFilter = contains(key))
end
function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, key::Regex)
Base.depwarn(
"getfirstBlobentry(dfg, label, key::Regex) is deprecated, use getfirstBlobentry(dfg, label; labelFilter=contains(key)) instead.",
:getfirstBlobentry,
)
return getfirstBlobentry(dfg, label; labelFilter = contains(key))
end
macro defVariable(args...)
return esc(:(DFG.@defStateType $(args...)))
end
@deprecate getFactorFunction(args...) getObservation(args...)
@deprecate getFactorType(args...) getObservation(args...)
#TODO maybe deprecate setMetadata!
function setMetadata!(v::VariableDFG, metadata::Dict{Symbol, MetadataTypes})
return error("FIXME: Metadata is not currently mutable in a Variable")
# v.metadata = base64encode(JSON3.write(metadata))
end
function setMetadata!(v::VariableCompute, metadata::Dict{Symbol, MetadataTypes})
v.smallData !== metadata && empty!(v.smallData)
return merge!(v.smallData, metadata)
end
## ================================================================================
## Deprecated in v0.27
##=================================================================================
const AbstractFactor = AbstractObservation
const AbstractPackedFactor = AbstractPackedObservation
const FactorOperationalMemory = FactorCache
const VariableNodeData = State
@deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...)
@deprecate addBlob!(store::AbstractBlobstore, blobId::UUID, data, ::String) addBlob!(
store,
blobId,
data,
)
@deprecate addBlob!(store::AbstractBlobstore{T}, data::T, ::String) where {T} addBlob!(
store,
uuid4(),
data,
)
@deprecate updateVariable!(args...) mergeVariable!(args...)
@deprecate updateFactor!(args...) mergeFactor!(args...)
@deprecate updateBlobEntry!(args...) mergeBlobentry!(args...)
@deprecate updateGraphBlobEntry!(args...) mergeGraphBlobentry!(args...)
@deprecate updateAgentBlobEntry!(args...) mergeAgentBlobentry!(args...)
@deprecate getBlobStore(args...) getBlobstore(args...)
@deprecate addBlobStore!(args...) addBlobstore!(args...)
@deprecate updateBlobStore!(args...) updateBlobstore!(args...)
@deprecate deleteBlobStore!(args...) deleteBlobstore!(args...)
@deprecate emptyBlobStore!(args...) emptyBlobstore!(args...)
@deprecate listBlobStores(args...) listBlobstores(args...)
@deprecate BlobEntry(args...; kwargs...) Blobentry(args...; kwargs...)
@deprecate getGraphBlobEntry(args...; kwargs...) getGraphBlobentry(args...; kwargs...)
@deprecate getGraphBlobEntries(args...; kwargs...) getGraphBlobentries(args...; kwargs...)
@deprecate addGraphBlobEntry!(args...; kwargs...) addGraphBlobentry!(args...; kwargs...)
@deprecate addGraphBlobEntries!(args...; kwargs...) addGraphBlobentries!(args...; kwargs...)
@deprecate mergeGraphBlobEntry!(args...; kwargs...) mergeGraphBlobentry!(args...; kwargs...)
@deprecate deleteGraphBlobEntry!(args...; kwargs...) deleteGraphBlobentry!(
args...;
kwargs...,
)
@deprecate getAgentBlobEntry(args...; kwargs...) getAgentBlobentry(args...; kwargs...)
@deprecate getAgentBlobEntries(args...; kwargs...) getAgentBlobentries(args...; kwargs...)
@deprecate addAgentBlobEntry!(args...; kwargs...) addAgentBlobentry!(args...; kwargs...)
@deprecate addAgentBlobEntries!(args...; kwargs...) addAgentBlobentries!(args...; kwargs...)
@deprecate mergeAgentBlobEntry!(args...; kwargs...) mergeAgentBlobentry!(args...; kwargs...)
@deprecate deleteAgentBlobEntry!(args...; kwargs...) deleteAgentBlobentry!(
args...;
kwargs...,
)
@deprecate listGraphBlobEntries(args...; kwargs...) listGraphBlobentries(args...; kwargs...)
@deprecate listAgentBlobEntries(args...; kwargs...) listAgentBlobentries(args...; kwargs...)
@deprecate hasBlobEntry(args...; kwargs...) hasBlobentry(args...; kwargs...)
@deprecate getBlobEntry(args...; kwargs...) getBlobentry(args...; kwargs...)
@deprecate getBlobEntryFirst(args...; kwargs...) getfirstBlobentry(args...; kwargs...)
@deprecate getBlobentry(var::AbstractGraphVariable, blobId::UUID) getfirstBlobentry(
var::AbstractGraphVariable,
blobId::UUID,
)
@deprecate addBlobEntry!(args...; kwargs...) addBlobentry!(args...; kwargs...)
@deprecate addBlobEntries!(args...; kwargs...) addBlobentries!(args...; kwargs...)
@deprecate mergeBlobEntry!(args...; kwargs...) mergeBlobentry!(args...; kwargs...)
@deprecate deleteBlobEntry!(args...; kwargs...) deleteBlobentry!(args...; kwargs...)
@deprecate listBlobEntrySequence(args...; kwargs...) listBlobentrySequence(
args...;
kwargs...,
)
@deprecate mergeBlobEntries!(args...; kwargs...) mergeBlobentries!(args...; kwargs...)
@deprecate getVariableSolverData(args...; kwargs...) getState(args...; kwargs...)
@deprecate addVariableSolverData!(args...; kwargs...) addState!(args...; kwargs...)
@deprecate deleteVariableSolverData!(args...; kwargs...) deleteState!(args...; kwargs...)
@deprecate listVariableSolverData(args...; kwargs...) listStates(args...; kwargs...)
@deprecate getVariableSolverDataAll(args...; kwargs...) getStates(args...; kwargs...)
@deprecate getSolverData(v::VariableCompute, solveKey::Symbol = :default) getState(
v,
solveKey,
) false
@deprecate packVariableNodeData(args...; kwargs...) packState(args...; kwargs...)
@deprecate unpackVariableNodeData(args...; kwargs...) unpackState(args...; kwargs...)
#TODO possibly completely deprecated or not exported until update verb is standardized
function updateVariableSolverData!(
dfg::AbstractDFG,
variablekey::Symbol,
vnd::State,
useCopy::Bool = false,
fields::Vector{Symbol} = Symbol[];
warn_if_absent::Bool = true,
)
Base.depwarn(
"updateVariableSolverData! is deprecated, use mergeState! or copytoState! instead",
:updateVariableSolverData!,
)
#This is basically just setSolverData
var = getVariable(dfg, variablekey)
warn_if_absent &&
!haskey(var.solverDataDict, vnd.solveKey) &&
@warn "State '$(vnd.solveKey)' does not exist, adding"
# for InMemoryDFGTypes do memory copy or repointing, for cloud this would be an different kind of update.
usevnd = vnd # useCopy ? deepcopy(vnd) : vnd
# should just one, or many pointers be updated?
useExisting =
haskey(var.solverDataDict, vnd.solveKey) &&
isa(var.solverDataDict[vnd.solveKey], State) &&
length(fields) != 0
# @error useExisting vnd.solveKey
if useExisting
# change multiple pointers inside the VND var.solverDataDict[solvekey]
for field in fields
destField = getfield(var.solverDataDict[vnd.solveKey], field)
srcField = getfield(usevnd, field)
if isa(destField, Array) && size(destField) == size(srcField)
# use broadcast (in-place operation)
destField .= srcField
else
# change pointer of destination VND object member
setfield!(var.solverDataDict[vnd.solveKey], field, srcField)
end
end
else
# change a single pointer in var.solverDataDict
var.solverDataDict[vnd.solveKey] = usevnd
end
return var.solverDataDict[vnd.solveKey]
end
function updateVariableSolverData!(
dfg::AbstractDFG,
variablekey::Symbol,
vnd::State,
solveKey::Symbol,
useCopy::Bool = false,
fields::Vector{Symbol} = Symbol[];
warn_if_absent::Bool = true,
)
# TODO not very clean
if vnd.solveKey != solveKey
Base.depwarn(
"updateVariableSolverData with solveKey is deprecated use copytoState! instead.",
:updateVariableSolverData!,
)
usevnd = useCopy ? deepcopy(vnd) : vnd
usevnd.solveKey = solveKey
return updateVariableSolverData!(
dfg,
variablekey,
usevnd,
useCopy,
fields;
warn_if_absent = warn_if_absent,
)
else
return updateVariableSolverData!(
dfg,
variablekey,
vnd,
useCopy,
fields;
warn_if_absent = warn_if_absent,
)
end
end
function updateVariableSolverData!(
dfg::AbstractDFG,
sourceVariable::VariableCompute,
solveKey::Symbol = :default,
useCopy::Bool = false,
fields::Vector{Symbol} = Symbol[];
warn_if_absent::Bool = true,
)
#
vnd = getSolverData(sourceVariable, solveKey)
# toshow = listSolveKeys(sourceVariable) |> collect
# @info "update DFGVar solveKey" solveKey vnd.solveKey
# @show toshow
@assert solveKey == vnd.solveKey "State's solveKey=:$(vnd.solveKey) does not match requested :$solveKey"
return updateVariableSolverData!(
dfg,
sourceVariable.label,
vnd,
useCopy,
fields;
warn_if_absent = warn_if_absent,
)
end
function updateVariableSolverData!(
dfg::AbstractDFG,
sourceVariables::Vector{<:VariableCompute},
solveKey::Symbol = :default,
useCopy::Bool = false,
fields::Vector{Symbol} = Symbol[];
warn_if_absent::Bool = true,
)
#I think cloud would do this in bulk for speed
for var in sourceVariables
updateVariableSolverData!(
dfg,
var.label,
getSolverData(var, solveKey),
useCopy,
fields;
warn_if_absent = warn_if_absent,
)
end
end
## factor refactor deprecations
Base.@kwdef mutable struct GenericFunctionNodeData{
T <: Union{<:AbstractPackedObservation, <:AbstractObservation, <:FactorCache},
}
eliminated::Bool = false
potentialused::Bool = false
edgeIDs::Vector{Int} = Int[]
fnc::T
multihypo::Vector{Float64} = Float64[] # TODO re-evaluate after refactoring w #477
certainhypo::Vector{Int} = Int[]
nullhypo::Float64 = 0.0
solveInProgress::Int = 0
inflation::Float64 = 0.0
end
function FactorCompute(
label::Symbol,
timestamp::Union{DateTime, ZonedDateTime},
nstime::Nanosecond,
tags::Set{Symbol},
solverData::GenericFunctionNodeData,
solvable::Int,
variableOrder::Union{Vector{Symbol}, Tuple};
observation = getFactorType(solverData),
state::FactorState = FactorState(),
solvercache::Base.RefValue{<:FactorCache} = Ref{FactorCache}(),
id::Union{UUID, Nothing} = nothing,
smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(),
)
error(
"This constructor is deprecated, use FactorCompute(label, variableOrder, solverData; ...) instead",
)
return FactorCompute(
id,
label,
tags,
Tuple(variableOrder),
timestamp,
nstime,
Ref(solverData),
Ref(solvable),
smallData,
observation,
state,
solvercache,
)
end
function getSolverData(f::FactorCompute)
return error(
"getSolverData(f::FactorCompute) is obsolete, use getFactorState, getObservation, or getCache instead",
)
end
function setSolverData!(f::FactorCompute, data::GenericFunctionNodeData)
return error(
"setSolverData!(f::FactorCompute, data::GenericFunctionNodeData) is obsolete, use setState!, or setCache! instead",
)
end
@deprecate unpackFactor(dfg::AbstractDFG, factor::FactorDFG; skipVersionCheck::Bool = false) unpackFactor(
factor;
skipVersionCheck,
) false
@deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorCache!(
args...;
kwargs...,
)
function reconstFactorData end
function decodePackedType(
dfg::AbstractDFG,
varOrder::AbstractVector{Symbol},
::Type{T},
packeddata::GenericFunctionNodeData{PT},
) where {T <: FactorCache, PT}
error("decodePackedType is obsolete")
#
# TODO, to solve IIF 1424
# variables = map(lb->getVariable(dfg, lb), varOrder)
# Also look at parentmodule
usrtyp = convertStructType(PT)
fulltype = DFG.FunctionNodeData{T{usrtyp}}
factordata = reconstFactorData(dfg, varOrder, fulltype, packeddata)
return factordata
end
function _packSolverData(f::FactorCompute, fnctype::AbstractObservation)
#
error("_packSolverData is deprecated, use seperate packing of observation #TODO")
packtype = convertPackedType(fnctype)
try
packed = convert(PackedFunctionNodeData{packtype}, getSolverData(f)) #TODO getSolverData
packedJson = packed
return packedJson
catch ex
io = IOBuffer()
showerror(io, ex, catch_backtrace())
err = String(take!(io))
msg = "Error while packing '$(f.label)' as '$fnctype', please check the unpacking/packing converters for this factor - \r\n$err"
error(msg)
end
end
const PackedFunctionNodeData{T} =
GenericFunctionNodeData{T} where {T <: AbstractPackedObservation}
function PackedFunctionNodeData(args...; kw...)
error("PackedFunctionNodeData is obsolete")
return PackedFunctionNodeData{typeof(args[4])}(args...; kw...)
end
const FunctionNodeData{T} =
GenericFunctionNodeData{T} where {T <: Union{<:AbstractObservation, <:FactorCache}}
FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw...)
# this is the GenericFunctionNodeData for packed types
#TODO deprecate FactorData in favor of FactorState (with no more distinction between packed and compute)
const FactorData = PackedFunctionNodeData{AbstractPackedObservation}
function FactorCompute(
label::Symbol,
variableOrder::Union{Vector{Symbol}, Tuple},
solverData::GenericFunctionNodeData;
tags::Set{Symbol} = Set{Symbol}(),
timestamp::Union{DateTime, ZonedDateTime} = now(localzone()),
solvable::Int = 1,
nstime::Nanosecond = Nanosecond(0),
id::Union{UUID, Nothing} = nothing,
smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(),
)
Base.depwarn(
"`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and solvercache should be provided explicitly.",
:FactorCompute,
)
observation = getFactorType(solverData)
state = FactorState(
solverData.eliminated,
solverData.potentialused,
solverData.multihypo,
solverData.certainhypo,
solverData.nullhypo,
solverData.solveInProgress,
solverData.inflation,
)
if solverData.fnc isa FactorCache
solvercache = solverData.fnc
else
solvercache = nothing
end
return FactorCompute(
label,
Tuple(variableOrder),
observation,
state,
solvercache;
id,
timestamp,
nstime,
tags,
smallData,
solvable,
)
end
# Deprecated check usefull? # packedFnc = fncStringToData(factor.fnctype, factor.data)
# Deprecated check usefull? # decodeType = getFactorOperationalMemoryType(dfg)
# Deprecated check usefull? # fullFactorData = decodePackedType(dfg, factor._variableOrderSymbols, decodeType, packedFnc)
function fncStringToData(args...; kwargs...)
@warn "fncStringToData is obsolete, called with" args kwargs
return error("fncStringToData is obsolete.")
end
#TODO make sure getFactorOperationalMemoryType is obsolete
function getFactorOperationalMemoryType(dummy)
return error(
"Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorCache`",
)
end
function getFactorOperationalMemoryType(dfg::AbstractDFG)
return getFactorOperationalMemoryType(getSolverParams(dfg))
end
function typeModuleName(variableType::StateType)
Base.depwarn("typeModuleName is obsolete", :typeModuleName)
io = IOBuffer()
ioc = IOContext(io, :module => DistributedFactorGraphs)
show(ioc, typeof(variableType))
return String(take!(io))
end
typeModuleName(varT::Type{<:StateType}) = typeModuleName(varT())
## ================================================================================
## Deprecated in v0.25
##=================================================================================
@deprecate getSessionBlobEntry(args...) getGraphBlobEntry(args...)
@deprecate getSessionBlobEntries(args...) getGraphBlobEntries(args...)
@deprecate addSessionBlobEntry!(args...) addGraphBlobEntry!(args...)
@deprecate addSessionBlobEntries!(args...) addGraphBlobEntries!(args...)
@deprecate updateSessionBlobEntry!(args...) updateGraphBlobEntry!(args...)
@deprecate deleteSessionBlobEntry!(args...) deleteGraphBlobEntry!(args...)
@deprecate getRobotBlobEntry(args...) getAgentBlobEntry(args...)
@deprecate getRobotBlobEntries(args...) getAgentBlobEntries(args...)
@deprecate addRobotBlobEntry!(args...) addAgentBlobEntry!(args...)
@deprecate addRobotBlobEntries!(args...) addAgentBlobEntries!(args...)
@deprecate updateRobotBlobEntry!(args...) updateAgentBlobEntry!(args...)
@deprecate deleteRobotBlobEntry!(args...) deleteAgentBlobEntry!(args...)
@deprecate getUserBlobEntry(args...) getAgentBlobEntry(args...)
@deprecate getUserBlobEntries(args...) getAgentBlobEntries(args...)
@deprecate addUserBlobEntry!(args...) addAgentBlobEntry!(args...)
@deprecate addUserBlobEntries!(args...) addAgentBlobEntries!(args...)
@deprecate updateUserBlobEntry!(args...) updateAgentBlobEntry!(args...)
@deprecate deleteUserBlobEntry!(args...) deleteAgentBlobEntry!(args...)
@deprecate listSessionBlobEntries(args...) listGraphBlobEntries(args...)
@deprecate listRobotBlobEntries(args...) listAgentBlobEntries(args...)
@deprecate listUserBlobEntries(args...) listAgentBlobEntries(args...)
@deprecate getUserData(args...) getAgentMetadata(args...)
@deprecate getRobotData(args...) getAgentMetadata(args...)
@deprecate getSessionData(args...) getGraphMetadata(args...)
@deprecate setUserData!(args...) setAgentMetadata!(args...)
@deprecate setRobotData!(args...) setAgentMetadata!(args...)
@deprecate setSessionData!(args...) setGraphMetadata!(args...)
@deprecate getUserLabel(dfg) getAgentLabel(dfg)
@deprecate getRobotLabel(dfg) getAgentLabel(dfg)
@deprecate getSessionLabel(dfg) getGraphLabel(dfg)
DFGSummary(args) = error("DFGSummary is deprecated")
@deprecate getSummary(dfg::AbstractDFG) getSummaryGraph(dfg)
@deprecate getKey(store::AbstractBlobstore) getLabel(store)