Skip to content

Commit 7a1e423

Browse files
authored
getStateKind and fix tests (#1198)
* getStateKind and fix tests * test IIF again
1 parent bddf79d commit 7a1e423

20 files changed

+148
-122
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
- name: Run tests
5353
env:
54-
IIF_TEST: false #FIXME skipping until IIF stable again
54+
IIF_TEST: true
5555
uses: julia-actions/julia-runtest@latest
5656
- name: Process Coverage
5757
uses: julia-actions/julia-processcoverage@v1

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
2+
3+
# v0.29
4+
- `AbstractPointParametricEst` (`MeanMaxPPE`) and related `PPE` functions are obsolete, see #1133.
5+
26
# v0.28
37
- Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session
48
- Deprecated AbstractRelativeMinimize and AbstractManifoldsMinimize

src/Deprecated.jl

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -85,41 +85,10 @@ function isSolveInProgress(
8585
return getSolveInProgress(node, solvekey) > 0
8686
end
8787

88-
"""
89-
$(SIGNATURES)
90-
Get a type from the serialization module.
91-
"""
92-
function getTypeFromSerializationModule(_typeString::AbstractString)
93-
@debug "DFG converting type string to Julia type" _typeString
94-
try
95-
# split the type at last `.`
96-
split_st = split(_typeString, r"\.(?!.*\.)")
97-
#if module is specified look for the module in main, otherwise use Main
98-
if length(split_st) == 2
99-
m = getfield(Main, Symbol(split_st[1]))
100-
else
101-
m = Main
102-
end
103-
noparams = split(split_st[end], r"{")
104-
ret = if 1 < length(noparams)
105-
# fix #671, but does not work with specific module yet
106-
bidx = findfirst(r"{", split_st[end])[1]
107-
error("getTypeFromSerializationModule eval obsolete")
108-
# Core.eval(m, Base.Meta.parse("$(noparams[1])$(split_st[end][bidx:end])"))
109-
else
110-
getfield(m, Symbol(split_st[end]))
111-
end
112-
113-
return ret
114-
115-
catch ex
116-
@error "Unable to deserialize type $(_typeString)"
117-
io = IOBuffer()
118-
showerror(io, ex, catch_backtrace())
119-
err = String(take!(io))
120-
@error(err)
121-
end
122-
return nothing
88+
function getTypeFromSerializationModule(::AbstractString)
89+
return error(
90+
"getTypeFromSerializationModule is obsolete, use DFG.parseVariableType or IIF.getTypeFromSerializationModule.",
91+
)
12392
end
12493

12594
## Version checking
@@ -137,8 +106,8 @@ end
137106

138107
refMetadata(node) = node.metadata
139108

140-
function packDistribution end
141-
function unpackDistribution end
109+
@deprecate packDistribution(d) pack(d)
110+
@deprecate unpackDistribution(d) unpack(d)
142111

143112
function setDescription!(args...)
144113
return error("setDescription! was removed and may be implemented later.")
@@ -158,8 +127,8 @@ function _getDuplicatedEmptyDFG(
158127
return newDfg
159128
end
160129

161-
#TODO is Type correct
162-
@deprecate getVariableType(args...) getStateType(args...)
130+
#Type gets confused with returning a DataType, Kind is an instance of StateType
131+
@deprecate getVariableType(args...) getStateKind(args...)
163132

164133
function getVariableTypeName(v::VariableSummary)
165134
Base.depwarn("getVariableTypeName is deprecated.", :getVariableTypeName)
@@ -274,7 +243,9 @@ const PackedObservation = AbstractPackedObservation
274243
abstract type AbstractPackedBelief end
275244
const PackedBelief = AbstractPackedBelief
276245

277-
getAddHistory(dfg::AbstractDFG) = error("getAddHistory is obsolete.")
246+
#TODO maybe replace with `listVariablesAddOrder` or using sort on `listVariables`
247+
getAddHistory(dfg::AbstractDFG) = error("getAddHistory is deprecated.")
248+
getAddHistory(dfg::GraphsDFG) = listVariables(dfg) #default listVariables on GraphsDFG is ordered
278249

279250
## Utility functions for getting type names and modules (from IncrementalInference)
280251
_getmodule(t::T) where {T} = T.name.module
@@ -342,6 +313,31 @@ function hasTagsNeighbors(
342313
return length(filter(x -> x in alltags, tags)) >= (matchAll ? length(tags) : 1)
343314
end
344315

316+
#Obsolete PPEs
317+
abstract type AbstractPointParametricEst end
318+
function _ppe_obsolete()
319+
return error(
320+
"PPEs are obsolete and will be replaced soon (IIF.calcMeanMaxSuggested can be used in some cases), see #1133.",
321+
)
322+
end
323+
getPPEMax(args...) = _ppe_obsolete()
324+
getPPEMean(args...) = _ppe_obsolete()
325+
getPPESuggested(args...) = _ppe_obsolete()
326+
getLastUpdatedTimestamp(est::AbstractPointParametricEst) = _ppe_obsolete()
327+
getPPE(args...) = _ppe_obsolete()
328+
addPPE!(args...) = _ppe_obsolete()
329+
addPPEs!(args...) = _ppe_obsolete()
330+
updatePPE!(args...) = _ppe_obsolete()
331+
deletePPE!(args...) = _ppe_obsolete()
332+
listPPEs(args...) = _ppe_obsolete()
333+
mergePPEs!(args...) = _ppe_obsolete()
334+
getPPEDict(args...) = _ppe_obsolete()
335+
getPPEs(args...) = _ppe_obsolete()
336+
getVariablePPEDict(args...) = _ppe_obsolete()
337+
getVariablePPE(args...) = _ppe_obsolete()
338+
MeanMaxPPE(args...; kwargs...) = _ppe_obsolete()
339+
getEstimateFields(args...) = _ppe_obsolete()
340+
345341
## ================================================================================
346342
## Deprecated in v0.28
347343
##=================================================================================
@@ -421,7 +417,7 @@ function lsWho(dfg::AbstractDFG, type::Symbol)
421417
vars = getVariables(dfg)
422418
labels = Symbol[]
423419
for v in vars
424-
varType = typeof(getVariableType(v)) |> nameof
420+
varType = typeof(getStateKind(v)) |> nameof
425421
varType == type && push!(labels, v.label)
426422
end
427423
return labels

src/DistributedFactorGraphs.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export addStates!
109109
export mergeStates!
110110
export deleteStates!
111111

112+
export hasState
113+
112114
## list
113115
export listVariables
114116
export listFactors
@@ -345,6 +347,7 @@ export @format_str # exported from FileIO
345347
export @defStateType #TODO Should this be exported?
346348

347349
public refStates
350+
public getStateKind
348351

349352
# list of unstable functions not exported any more
350353
# will move to public or deprecate over time
@@ -407,13 +410,11 @@ const unstable_functions::Vector{Symbol} = [
407410
:printNode,
408411
:plotDFG,
409412
:pack,
410-
:packDistribution,
411413
# :packVariable,
412414
# :packFactor,
413415
:packBlob,
414416
:packState,
415417
:unpack,
416-
:unpackDistribution,
417418
:hasTags,
418419
# :unpackVariable,
419420
# :unpackFactor,
@@ -440,13 +441,15 @@ const unstable_functions::Vector{Symbol} = [
440441
# no set on these
441442

442443
#deprecated in v0.29
444+
:packDistribution,
445+
:unpackDistribution,
443446
:hasTagsNeighbors,
444447
# :updateBlobstore!,## TODO deprecated or obsolete
445448
:emptyMetadata!, #TODO maybe deprecate for just deleteMetadata!
446449
# :emptyBlobstore!, #TODO maybe deprecate for just deleteBlobstore!
447450
:MetadataTypes, #maybe make public after metadata stable
448451
:getVariableTypeName,
449-
:getVariableType,
452+
:getStateKind,
450453
:setTimestamp,
451454
:setMetadata!, # no set, use add merge
452455
:setAgentMetadata!,
@@ -577,7 +580,7 @@ include("DataBlobs/services/BlobWrappers.jl")
577580

578581
#FIXME
579582
function getSolvable end
580-
function getVariableType end
583+
function getStateKind end
581584
function isInitialized end
582585
function listTags end
583586
# In Memory Types

src/GraphsDFG/GraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using ...DistributedFactorGraphs:
1717
NoSolverParams,
1818
filterDFG!,
1919
getSolvable,
20-
getVariableType,
20+
getStateKind,
2121
getAgentLabel,
2222
getGraphLabel,
2323
isInitialized,

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function getVariables(
187187
filterDFG!(variables, labelFilter, getLabel)
188188
filterDFG!(variables, solvableFilter, getSolvable)
189189
filterDFG!(variables, tagsFilter, refTags)
190-
filterDFG!(variables, typeFilter, getVariableType)
190+
filterDFG!(variables, typeFilter, getStateKind)
191191

192192
return variables
193193
end

src/entities/Bloblet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function addBloblet!(node, bloblet::Bloblet)
6565
end
6666

6767
function addBloblets!(node, bloblets::Vector{Bloblet})
68-
addBloblet!.(node, bloblets)
68+
foreach(bl -> addBloblet!(node, bl), bloblets)
6969
return bloblets
7070
end
7171

src/entities/DFGVariable.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ end
7878
function State{T}(; kwargs...) where {T <: StateType}
7979
return State{T, getPointType(T), getDimension(T)}(; kwargs...)
8080
end
81-
function State(label, variableType::StateType; kwargs...)
81+
function State(label::Symbol, variableType::StateType; kwargs...)
8282
return State{typeof(variableType)}(; label, kwargs...)
8383
end
8484

8585
function State(state::State; kwargs...)
86-
return State{typeof(getVariableType(state))}(;
86+
return State{typeof(getStateKind(state))}(;
8787
(key => deepcopy(getproperty(state, key)) for key in fieldnames(State))...,
8888
kwargs...,
8989
)
@@ -255,7 +255,7 @@ end
255255
function VariableDFG(label::Symbol, state::State; kwargs...)
256256
return VariableDFG(
257257
label,
258-
getStateType(state);
258+
getStateKind(state);
259259
states = OrderedDict(state.label => state),
260260
kwargs...,
261261
)
@@ -299,8 +299,7 @@ $(TYPEDFIELDS)
299299
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
300300
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
301301
tags::Set{Symbol}
302-
"""Symbol for the state type for the underlying variable.
303-
Accessor: [`getStateType`](@ref)"""
302+
"""Symbol for the state type for the underlying variable."""
304303
statetype::Symbol
305304
"""Dictionary of large data associated with this variable.
306305
Accessors: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`mergeBlobentry!`](@ref), and [`deleteBlobentry!`](@ref)"""

src/serialization/PackedSerialization.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ function resolvePackedType(obj::JSON.Object)
6767
return Packed{getfield(pkg, Symbol(type.name))}
6868
end
6969

70+
function resolveType(obj::DFG.JSON.Object)
71+
type = obj.type
72+
pkg = Base.require(Main, Symbol(type.pkg))
73+
if !isdefined(Main, Symbol(type.pkg))
74+
throw(SerializationError("Module $(pkg) is available, but not loaded in `Main`."))
75+
end
76+
return getfield(pkg, Symbol(type.name))
77+
end
78+
7079
@choosetype Packed resolvePackedType
7180

7281
# Stash optional TypeMetadata expansion function.

src/serialization/StateSerialization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function packState(state::State{T}) where {T <: StateType}
9999
vecbw = state.bw[:],
100100
dimbw = size(state.bw, 1),
101101
separator = state.separator,
102-
statetype = stringVariableType(getStateType(state)),
102+
statetype = stringVariableType(getStateKind(state)),
103103
initialized = state.initialized,
104104
observability = state.observability,
105105
marginalized = state.marginalized,

0 commit comments

Comments
 (0)