|
1 | 1 | ## ================================================================================ |
2 | 2 | ## Deprecated in v0.29 |
3 | 3 | ##================================================================================= |
| 4 | +export FactorCompute |
| 5 | +const FactorCompute = FactorDFG |
| 6 | + |
4 | 7 | function getHash(entry::Blobentry) |
5 | 8 | return error( |
6 | 9 | "Blobentry field :hash has been deprecated; use :crchash or :shahash instead", |
7 | 10 | ) |
8 | 11 | end |
| 12 | + |
| 13 | +function getMetadata(node) |
| 14 | + return error( |
| 15 | + "getMetadata(node::$(typeof(node))) is deprecated; metadata is now stored in bloblets. Use getBloblets instead.", |
| 16 | + ) |
| 17 | + # return JSON.parse(base64decode(f.metadata), Dict{Symbol, MetadataTypes}) |
| 18 | +end |
| 19 | + |
| 20 | +# getTimestamp |
| 21 | + |
| 22 | +# setTimestamp is deprecated for now we can implement setTimestamp!(dfg, lbl, ts) later. |
| 23 | +function setTimestamp(args...; kwargs...) |
| 24 | + return error("setTimestamp is obsolete, use addVariable!(..., timestamp=...) instead.") |
| 25 | +end |
| 26 | +function setTimestamp!(args...; kwargs...) |
| 27 | + return error( |
| 28 | + "setTimestamp! is not implemented, use addVariable!(..., timestamp=...) instead.", |
| 29 | + ) |
| 30 | +end |
| 31 | + |
| 32 | +##------------------------------------------------------------------------------ |
| 33 | +## solveInProgress |
| 34 | +##------------------------------------------------------------------------------ |
| 35 | + |
| 36 | +# getSolveInProgress and isSolveInProgress is deprecated for DFG v1.0, we can bring it back fully implemented when needed. |
| 37 | +# """ |
| 38 | +# $SIGNATURES |
| 39 | + |
| 40 | +# Which variables or factors are currently being used by an active solver. Useful for ensuring atomic transactions. |
| 41 | + |
| 42 | +# DevNotes: |
| 43 | +# - Will be renamed to `data.solveinprogress` which will be in VND, not AbstractGraphNode -- see DFG #201 |
| 44 | + |
| 45 | +# Related |
| 46 | + |
| 47 | +# isSolvable |
| 48 | +# """ |
| 49 | +function getSolveInProgress( |
| 50 | + var::Union{VariableCompute, FactorCompute}, |
| 51 | + solveKey::Symbol = :default, |
| 52 | +) |
| 53 | + # Variable |
| 54 | + if var isa VariableCompute |
| 55 | + if haskey(getSolverDataDict(var), solveKey) |
| 56 | + return getSolverDataDict(var)[solveKey].solveInProgress |
| 57 | + else |
| 58 | + return 0 |
| 59 | + end |
| 60 | + end |
| 61 | + # Factor |
| 62 | + return getFactorState(var).solveInProgress |
| 63 | +end |
| 64 | + |
| 65 | +#TODO missing set solveInProgress and graph level accessor |
| 66 | + |
| 67 | +function isSolveInProgress( |
| 68 | + node::Union{VariableCompute, FactorCompute}, |
| 69 | + solvekey::Symbol = :default, |
| 70 | +) |
| 71 | + return getSolveInProgress(node, solvekey) > 0 |
| 72 | +end |
| 73 | + |
| 74 | +""" |
| 75 | + $(SIGNATURES) |
| 76 | +Get a type from the serialization module. |
| 77 | +""" |
| 78 | +function getTypeFromSerializationModule(_typeString::AbstractString) |
| 79 | + @debug "DFG converting type string to Julia type" _typeString |
| 80 | + try |
| 81 | + # split the type at last `.` |
| 82 | + split_st = split(_typeString, r"\.(?!.*\.)") |
| 83 | + #if module is specified look for the module in main, otherwise use Main |
| 84 | + if length(split_st) == 2 |
| 85 | + m = getfield(Main, Symbol(split_st[1])) |
| 86 | + else |
| 87 | + m = Main |
| 88 | + end |
| 89 | + noparams = split(split_st[end], r"{") |
| 90 | + ret = if 1 < length(noparams) |
| 91 | + # fix #671, but does not work with specific module yet |
| 92 | + bidx = findfirst(r"{", split_st[end])[1] |
| 93 | + error("getTypeFromSerializationModule eval obsolete") |
| 94 | + # Core.eval(m, Base.Meta.parse("$(noparams[1])$(split_st[end][bidx:end])")) |
| 95 | + else |
| 96 | + getfield(m, Symbol(split_st[end])) |
| 97 | + end |
| 98 | + |
| 99 | + return ret |
| 100 | + |
| 101 | + catch ex |
| 102 | + @error "Unable to deserialize type $(_typeString)" |
| 103 | + io = IOBuffer() |
| 104 | + showerror(io, ex, catch_backtrace()) |
| 105 | + err = String(take!(io)) |
| 106 | + @error(err) |
| 107 | + end |
| 108 | + return nothing |
| 109 | +end |
| 110 | + |
| 111 | +## Version checking |
| 112 | +#NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module) |
| 113 | +function _getDFGVersion() |
| 114 | + return pkgversion(DistributedFactorGraphs) |
| 115 | +end |
| 116 | + |
| 117 | +function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG}) |
| 118 | + if node._version.minor < _getDFGVersion().minor |
| 119 | + @warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog = |
| 120 | + 10 |
| 121 | + end |
| 122 | +end |
| 123 | + |
| 124 | +refMetadata(node) = node.metadata |
| 125 | + |
| 126 | +function packDistribution end |
| 127 | +function unpackDistribution end |
| 128 | + |
| 129 | +getAgentMetadata(args...) = error("getAgentMetadata is obsolete, use Bloblets instead.") |
| 130 | +setAgentMetadata!(args...) = error("setAgentMetadata! is obsolete, use Bloblets instead.") |
| 131 | +getGraphMetadata(args...) = error("getGraphMetadata is obsolete, use Bloblets instead.") |
| 132 | +setGraphMetadata!(args...) = error("setGraphMetadata! is obsolete, use Bloblets instead.") |
| 133 | + |
| 134 | +function setDescription!(args...) |
| 135 | + return error("setDescription! was removed and may be implemented later.") |
| 136 | +end |
| 137 | + |
| 138 | +# TODO find replacement. |
| 139 | +function _getDuplicatedEmptyDFG( |
| 140 | + dfg::GraphsDFG{P, V, F}, |
| 141 | +) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor} |
| 142 | + Base.depwarn("_getDuplicatedEmptyDFG is deprecated.", :_getDuplicatedEmptyDFG) |
| 143 | + newDfg = GraphsDFG{P, V, F}(; |
| 144 | + agentLabel = getAgentLabel(dfg), |
| 145 | + graphLabel = getGraphLabel(dfg), |
| 146 | + solverParams = deepcopy(dfg.solverParams), |
| 147 | + ) |
| 148 | + # DFG.setDescription!(newDfg, "(Copy of) $(DFG.getDescription(dfg))") |
| 149 | + return newDfg |
| 150 | +end |
9 | 151 | ## ================================================================================ |
10 | 152 | ## Deprecated in v0.28 |
11 | 153 | ##================================================================================= |
@@ -124,18 +266,19 @@ function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...) |
124 | 266 | return cloneSolveKey!(dfg, dest, dfg, src; kw...) |
125 | 267 | end |
126 | 268 |
|
127 | | -#TODO not a good function, as it's not complete. |
| 269 | +#TODO make a replacement if used a lot... not a good function, as it's not complete. |
128 | 270 | # """ |
129 | 271 | # $(SIGNATURES) |
130 | 272 | # Convenience function to get all the metadata of a DFG |
131 | 273 | # """ |
132 | 274 | function getDFGInfo(dfg::AbstractDFG) |
| 275 | + Base.depwarn("getDFGInfo is deprecated and needs a replacement.", :getDFGInfo) |
133 | 276 | return ( |
134 | | - description = getDescription(dfg), |
| 277 | + graphDescription = getDescription(dfg), |
135 | 278 | agentLabel = getAgentLabel(dfg), |
136 | 279 | graphLabel = getGraphLabel(dfg), |
137 | | - agentMetadata = getAgentMetadata(dfg), |
138 | | - graphMetadata = getGraphMetadata(dfg), |
| 280 | + # agentBloblets = getAgentBloblets(dfg), |
| 281 | + # graphBloblets = getGraphBloblets(dfg), |
139 | 282 | solverParams = getSolverParams(dfg), |
140 | 283 | ) |
141 | 284 | end |
|
350 | 493 | @deprecate getFactorFunction(args...) getObservation(args...) |
351 | 494 | @deprecate getFactorType(args...) getObservation(args...) |
352 | 495 |
|
353 | | -#TODO maybe deprecate setMetadata! |
354 | | -function setMetadata!(v::VariableDFG, metadata::Dict{Symbol, MetadataTypes}) |
355 | | - return error("FIXME: Metadata is not currently mutable in a Variable") |
356 | | - # v.metadata = base64encode(JSON3.write(metadata)) |
357 | | -end |
358 | | - |
359 | | -function setMetadata!(v::VariableCompute, metadata::Dict{Symbol, MetadataTypes}) |
360 | | - v.smallData !== metadata && empty!(v.smallData) |
361 | | - return merge!(v.smallData, metadata) |
362 | | -end |
| 496 | +setMetadata!(args...) = error("setMetadata is obsolete, use Bloblets instead.") |
363 | 497 |
|
364 | 498 | function updateData!( |
365 | 499 | dfg::AbstractDFG, |
|
999 | 1133 |
|
1000 | 1134 | # # Deprecated check usefull? # packedFnc = fncStringToData(factor.fnctype, factor.data) |
1001 | 1135 | # # Deprecated check usefull? # decodeType = getFactorOperationalMemoryType(dfg) |
1002 | | -# # Deprecated check usefull? # fullFactorData = decodePackedType(dfg, factor._variableOrderSymbols, decodeType, packedFnc) |
| 1136 | +# # Deprecated check usefull? # fullFactorData = decodePackedType(dfg, factor.variableorder, decodeType, packedFnc) |
1003 | 1137 | # function fncStringToData(args...; kwargs...) |
1004 | 1138 | # @warn "fncStringToData is obsolete, called with" args kwargs |
1005 | 1139 | # return error("fncStringToData is obsolete.") |
|
0 commit comments