-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDeprecated.jl
More file actions
1155 lines (1039 loc) · 37.7 KB
/
Deprecated.jl
File metadata and controls
1155 lines (1039 loc) · 37.7 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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## ================================================================================
## Deprecated in v0.29
##=================================================================================
export FactorCompute
const FactorCompute = FactorDFG
function getHash(entry::Blobentry)
return error(
"Blobentry field :hash has been deprecated; use :crchash or :shahash instead",
)
end
function getMetadata(node)
error(
"getMetadata(node::$(typeof(node))) is deprecated; metadata is now stored in bloblets. Use getBloblets instead.",
)
# return JSON.parse(base64decode(f.metadata), Dict{Symbol, MetadataTypes})
end
# getTimestamp
# setTimestamp is deprecated for now we can implement setTimestamp!(dfg, lbl, ts) later.
setTimestamp(args...; kwargs...) = error("setTimestamp is obsolete, use addVariable!(..., timestamp=...) instead.")
setTimestamp!(args...; kwargs...) = error("setTimestamp! is not implemented, use addVariable!(..., timestamp=...) instead.")
##------------------------------------------------------------------------------
## solveInProgress
##------------------------------------------------------------------------------
# getSolveInProgress and isSolveInProgress is deprecated for DFG v1.0, we can bring it back fully implemented when needed.
# """
# $SIGNATURES
# Which variables or factors are currently being used by an active solver. Useful for ensuring atomic transactions.
# DevNotes:
# - Will be renamed to `data.solveinprogress` which will be in VND, not AbstractGraphNode -- see DFG #201
# Related
# isSolvable
# """
function getSolveInProgress(
var::Union{VariableCompute, FactorCompute},
solveKey::Symbol = :default,
)
# Variable
if var isa VariableCompute
if haskey(getSolverDataDict(var), solveKey)
return getSolverDataDict(var)[solveKey].solveInProgress
else
return 0
end
end
# Factor
return getFactorState(var).solveInProgress
end
#TODO missing set solveInProgress and graph level accessor
function isSolveInProgress(
node::Union{VariableCompute, FactorCompute},
solvekey::Symbol = :default,
)
return getSolveInProgress(node, solvekey) > 0
end
"""
$(SIGNATURES)
Get a type from the serialization module.
"""
function getTypeFromSerializationModule(_typeString::AbstractString)
@debug "DFG converting type string to Julia type" _typeString
try
# split the type at last `.`
split_st = split(_typeString, r"\.(?!.*\.)")
#if module is specified look for the module in main, otherwise use Main
if length(split_st) == 2
m = getfield(Main, Symbol(split_st[1]))
else
m = Main
end
noparams = split(split_st[end], r"{")
ret = if 1 < length(noparams)
# fix #671, but does not work with specific module yet
bidx = findfirst(r"{", split_st[end])[1]
error("getTypeFromSerializationModule eval obsolete")
# Core.eval(m, Base.Meta.parse("$(noparams[1])$(split_st[end][bidx:end])"))
else
getfield(m, Symbol(split_st[end]))
end
return ret
catch ex
@error "Unable to deserialize type $(_typeString)"
io = IOBuffer()
showerror(io, ex, catch_backtrace())
err = String(take!(io))
@error(err)
end
return nothing
end
## Version checking
#NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module)
function _getDFGVersion()
return pkgversion(DistributedFactorGraphs)
end
function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG})
if node._version.minor < _getDFGVersion().minor
@warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog =
10
end
end
refMetadata(node) = node.metadata
function packDistribution end
function unpackDistribution end
getAgentMetadata(args...) = error("getAgentMetadata is obsolete, use Bloblets instead.")
setAgentMetadata!(args...) = error("setAgentMetadata! is obsolete, use Bloblets instead.")
getGraphMetadata(args...) = error("getGraphMetadata is obsolete, use Bloblets instead.")
setGraphMetadata!(args...) = error("setGraphMetadata! is obsolete, use Bloblets instead.")
setDescription!(args...) = error("setDescription! was removed and may be implemented later.")
# TODO find replacement.
function _getDuplicatedEmptyDFG(
dfg::GraphsDFG{P, V, F},
) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor}
Base.depwarn(
"_getDuplicatedEmptyDFG is deprecated.",
:_getDuplicatedEmptyDFG,
)
newDfg = GraphsDFG{P, V, F}(;
agentLabel = getAgentLabel(dfg),
graphLabel = getGraphLabel(dfg),
solverParams = deepcopy(dfg.solverParams),
)
# DFG.setDescription!(newDfg, "(Copy of) $(DFG.getDescription(dfg))")
return newDfg
end
## ================================================================================
## 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 make a replacement if used a lot... not a good function, as it's not complete.
# """
# $(SIGNATURES)
# Convenience function to get all the metadata of a DFG
# """
function getDFGInfo(dfg::AbstractDFG)
Base.depwarn("getDFGInfo is deprecated and needs a replacement.", :getDFGInfo)
return (
graphDescription = getDescription(dfg),
agentLabel = getAgentLabel(dfg),
graphLabel = getGraphLabel(dfg),
# agentBloblets = getAgentBloblets(dfg),
# graphBloblets = getGraphBloblets(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...)
setMetadata!(args...) = error("setMetadata is obsolete, use Bloblets instead.")
function updateData!(
dfg::AbstractDFG,
label::Symbol,
entry::Blobentry,
blob::Vector{UInt8};
hashfunction = sha256,
checkhash::Bool = true,
)
@warn "updateData! is obsolete."
checkhash && assertHash(entry, blob; hashfunction)
# order of ops with unknown new blobId not tested
mergeBlobentry!(dfg, label, entry)
db = updateBlob!(dfg, de, blob)
return 2
end
function updateData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
label::Symbol,
entry::Blobentry,
blob::Vector{UInt8};
hashfunction = sha256,
)
@warn "updateData! is obsolete."
# Recalculate the hash - NOTE Assuming that this is going to be a Blobentry. TBD.
# order of operations with unknown new blobId not tested
newEntry = Blobentry(
entry; # and kwargs to override new values
blobstore = getLabel(blobstore),
hash = string(bytes2hex(hashfunction(blob))),
origin = buildSourceString(dfg, label),
_version = _getDFGVersion(),
)
mergeBlobentry!(dfg, label, newEntry)
updateBlob!(blobstore, newEntry, blob)
return 2
end
function updateBlob!(store::RowBlobstore{T}, blobId::UUID, blob::T) where {T}
@warn "updateBlob! is obsolete."
if haskey(store.blobs, blobId)
@warn "Key '$blobId' doesn't exist."
end
return store.blobs[blobId] = RowBlob(blobId, blob)
end
function getData(
dfg::AbstractDFG,
vlabel::Symbol,
key::Union{Symbol, UUID, <:AbstractString, Regex};
hashfunction = sha256,
checkhash::Bool = true,
getlast::Bool = true,
)
Base.depwarn("getData is deprecated, use loadBlob_Variable instead.", :getData)
_getblobentr(g, v, k) = getBlobentries(g, v, k)
_getblobentr(g, v, k::UUID) = [getfirstBlobentry(g, v, k);]
de_ = _getblobentr(dfg, vlabel, key)
lbls = (s -> s.label).(de_)
idx = sortperm(lbls; rev = getlast)
_first(s) = s
_first(s::AbstractVector) = 0 < length(s) ? s[1] : nothing
de = _first(de_[idx])
if isnothing(de)
@error "Could not find in $vlabel the key $key"
return nothing
end
db = getBlob(dfg, de)
checkhash && assertHash(de, db; hashfunction = hashfunction)
return de => db
end
# This is the normal one
function getData(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
var_label::Symbol,
entry_label::Symbol;
hashfunction = sha256,
checkhash::Bool = true,
getlast::Bool = true,
)
Base.depwarn("getData is deprecated, use loadBlob_Variable instead.", :getData)
de = getBlobentry(dfg, var_label, entry_label)
db = getBlob(blobstore, de)
checkhash && assertHash(de, db; hashfunction)
return de => db
end
#FIXME Should `addData!`` not return entry=>blob pair?
function addData!(
dfg::AbstractDFG,
label::Symbol,
entry::Blobentry,
blob::Vector{UInt8};
hashfunction = sha256,
checkhash::Bool = false,
)
Base.depwarn("addData! is obsolete, use saveBlob_Variable! instead.", :addData!)
checkhash && assertHash(entry, blob; hashfunction)
blobId = addBlob!(dfg, entry, blob) |> UUID
newEntry = Blobentry(entry; blobId) #, size=length(blob))
return addBlobentry!(dfg, label, newEntry)
end
function addData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
label::Symbol,
entry::Blobentry,
blob::Vector{UInt8};
hashfunction = sha256,
checkhash::Bool = false,
)
Base.depwarn("addData! is obsolete, use saveBlob_Variable! instead.", :addData!)
checkhash && assertHash(entry, blob; hashfunction)
blobId = addBlob!(blobstore, entry, blob) |> UUID
newEntry = Blobentry(entry; blobId) #, size=length(blob))
return addBlobentry!(dfg, label, newEntry)
end
function addData!(
dfg::AbstractDFG,
blobstorekey::Symbol,
vLbl::Symbol,
bLbl::Symbol,
blob::Vector{UInt8},
timestamp = now(localzone());
kwargs...,
)
Base.depwarn("addData! is obsolete, use saveBlob_Variable! instead.", :addData!)
return addData!(
dfg,
getBlobstore(dfg, blobstorekey),
vLbl,
bLbl,
blob,
timestamp;
kwargs...,
)
end
function addData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
vLbl::Symbol,
bLbl::Symbol,
blob::Vector{UInt8},
timestamp = now(localzone());
description = "",
metadata = "",
mimeType::String = "application/octet-stream",
id::Union{UUID, Nothing} = nothing,
blobId::UUID = uuid4(),
hashfunction = sha256,
)
Base.depwarn("addData! is obsolete, use saveBlob_Variable! instead.", :addData!)
#
entry = Blobentry(;
id,
blobId,
label = bLbl,
blobstore = getLabel(blobstore),
hash = string(bytes2hex(hashfunction(blob))),
origin = buildSourceString(dfg, vLbl),
description,
mimeType,
metadata,
timestamp,
)
return addData!(dfg, blobstore, vLbl, entry, blob; hashfunction)
end
function addData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore{T},
vLbl::Symbol,
blobLabel::Symbol,
blob::T,
timestamp = now(localzone());
description = "",
metadata = "",
mimeType::String = "application/octet-stream",
origin = buildSourceString(dfg, vLbl),
# hashfunction = sha256,
) where {T}
Base.depwarn("addData! is obsolete, use saveBlob_Variable! instead.", :addData!)
#
# checkhash && assertHash(entry, blob; hashfunction)
blobId = addBlob!(blobstore, blob)
entry = Blobentry(;
blobId,
label = blobLabel,
blobstore = getLabel(blobstore),
# hash = string(bytes2hex(hashfunction(blob))),
hash = "",
origin,
description,
mimeType,
metadata,
timestamp,
)
addBlobentry!(dfg, vLbl, entry)
return entry => blob
end
function deleteData!(dfg::AbstractDFG, vLbl::Symbol, bLbl::Symbol)
Base.depwarn(
"deleteData! is deprecated, use deleteBlob_Variable! instead.",
:deleteData!,
)
de = getBlobentry(dfg, vLbl, bLbl)
deleteBlobentry!(dfg, vLbl, bLbl)
deleteBlob!(dfg, de)
return 2
end
function deleteData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
vLbl::Symbol,
entry::Blobentry,
)
Base.depwarn(
"deleteData! is deprecated, use deleteBlob_Variable! instead.",
:deleteData!,
)
return deleteData!(dfg, blobstore, vLbl, entry.label)
end
function deleteData!(
dfg::AbstractDFG,
blobstore::AbstractBlobstore,
vLbl::Symbol,
bLbl::Symbol,
)
Base.depwarn(
"deleteData! is deprecated, use deleteBlob_Variable! instead.",
:deleteData!,
)
de = getBlobentry(dfg, vLbl, bLbl)
deleteBlobentry!(dfg, vLbl, bLbl)
deleteBlob!(blobstore, de)
return 2
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),