Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- name: Run tests
env:
IIF_TEST: false #FIXME skipping until IIF stable again
IIF_TEST: true
uses: julia-actions/julia-runtest@latest
- name: Process Coverage
uses: julia-actions/julia-processcoverage@v1
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.

# v0.29
- `AbstractPointParametricEst` (`MeanMaxPPE`) and related `PPE` functions are obsolete, see #1133.

# v0.28
- Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session
- Deprecated AbstractRelativeMinimize and AbstractManifoldsMinimize
Expand Down
78 changes: 37 additions & 41 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,10 @@ function isSolveInProgress(
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
function getTypeFromSerializationModule(::AbstractString)
return error(
"getTypeFromSerializationModule is obsolete, use DFG.parseVariableType or IIF.getTypeFromSerializationModule.",
)
end

## Version checking
Expand All @@ -137,8 +106,8 @@ end

refMetadata(node) = node.metadata

function packDistribution end
function unpackDistribution end
@deprecate packDistribution(d) pack(d)
@deprecate unpackDistribution(d) unpack(d)

function setDescription!(args...)
return error("setDescription! was removed and may be implemented later.")
Expand All @@ -158,8 +127,8 @@ function _getDuplicatedEmptyDFG(
return newDfg
end

#TODO is Type correct
@deprecate getVariableType(args...) getStateType(args...)
#Type gets confused with returning a DataType, Kind is an instance of StateType
@deprecate getVariableType(args...) getStateKind(args...)

function getVariableTypeName(v::VariableSummary)
Base.depwarn("getVariableTypeName is deprecated.", :getVariableTypeName)
Expand Down Expand Up @@ -274,7 +243,9 @@ const PackedObservation = AbstractPackedObservation
abstract type AbstractPackedBelief end
const PackedBelief = AbstractPackedBelief

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

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

#Obsolete PPEs
abstract type AbstractPointParametricEst end
function _ppe_obsolete()
return error(
"PPEs are obsolete and will be replaced soon (IIF.calcMeanMaxSuggested can be used in some cases), see #1133.",
)
end
getPPEMax(args...) = _ppe_obsolete()
getPPEMean(args...) = _ppe_obsolete()
getPPESuggested(args...) = _ppe_obsolete()
getLastUpdatedTimestamp(est::AbstractPointParametricEst) = _ppe_obsolete()
getPPE(args...) = _ppe_obsolete()
addPPE!(args...) = _ppe_obsolete()
addPPEs!(args...) = _ppe_obsolete()
updatePPE!(args...) = _ppe_obsolete()
deletePPE!(args...) = _ppe_obsolete()
listPPEs(args...) = _ppe_obsolete()
mergePPEs!(args...) = _ppe_obsolete()
getPPEDict(args...) = _ppe_obsolete()
getPPEs(args...) = _ppe_obsolete()
getVariablePPEDict(args...) = _ppe_obsolete()
getVariablePPE(args...) = _ppe_obsolete()
MeanMaxPPE(args...; kwargs...) = _ppe_obsolete()
getEstimateFields(args...) = _ppe_obsolete()

## ================================================================================
## Deprecated in v0.28
##=================================================================================
Expand Down Expand Up @@ -421,7 +417,7 @@ function lsWho(dfg::AbstractDFG, type::Symbol)
vars = getVariables(dfg)
labels = Symbol[]
for v in vars
varType = typeof(getVariableType(v)) |> nameof
varType = typeof(getStateKind(v)) |> nameof
varType == type && push!(labels, v.label)
end
return labels
Expand Down
11 changes: 7 additions & 4 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export addStates!
export mergeStates!
export deleteStates!

export hasState

## list
export listVariables
export listFactors
Expand Down Expand Up @@ -345,6 +347,7 @@ export @format_str # exported from FileIO
export @defStateType #TODO Should this be exported?

public refStates
public getStateKind

# list of unstable functions not exported any more
# will move to public or deprecate over time
Expand Down Expand Up @@ -407,13 +410,11 @@ const unstable_functions::Vector{Symbol} = [
:printNode,
:plotDFG,
:pack,
:packDistribution,
# :packVariable,
# :packFactor,
:packBlob,
:packState,
:unpack,
:unpackDistribution,
:hasTags,
# :unpackVariable,
# :unpackFactor,
Expand All @@ -440,13 +441,15 @@ const unstable_functions::Vector{Symbol} = [
# no set on these

#deprecated in v0.29
:packDistribution,
:unpackDistribution,
:hasTagsNeighbors,
# :updateBlobstore!,## TODO deprecated or obsolete
:emptyMetadata!, #TODO maybe deprecate for just deleteMetadata!
# :emptyBlobstore!, #TODO maybe deprecate for just deleteBlobstore!
:MetadataTypes, #maybe make public after metadata stable
:getVariableTypeName,
:getVariableType,
:getStateKind,
:setTimestamp,
:setMetadata!, # no set, use add merge
:setAgentMetadata!,
Expand Down Expand Up @@ -577,7 +580,7 @@ include("DataBlobs/services/BlobWrappers.jl")

#FIXME
function getSolvable end
function getVariableType end
function getStateKind end
function isInitialized end
function listTags end
# In Memory Types
Expand Down
2 changes: 1 addition & 1 deletion src/GraphsDFG/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using ...DistributedFactorGraphs:
NoSolverParams,
filterDFG!,
getSolvable,
getVariableType,
getStateKind,
getAgentLabel,
getGraphLabel,
isInitialized,
Expand Down
2 changes: 1 addition & 1 deletion src/GraphsDFG/services/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function getVariables(
filterDFG!(variables, labelFilter, getLabel)
filterDFG!(variables, solvableFilter, getSolvable)
filterDFG!(variables, tagsFilter, refTags)
filterDFG!(variables, typeFilter, getVariableType)
filterDFG!(variables, typeFilter, getStateKind)

return variables
end
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Bloblet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function addBloblet!(node, bloblet::Bloblet)
end

function addBloblets!(node, bloblets::Vector{Bloblet})
addBloblet!.(node, bloblets)
foreach(bl -> addBloblet!(node, bl), bloblets)
return bloblets
end

Expand Down
9 changes: 4 additions & 5 deletions src/entities/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ end
function State{T}(; kwargs...) where {T <: StateType}
return State{T, getPointType(T), getDimension(T)}(; kwargs...)
end
function State(label, variableType::StateType; kwargs...)
function State(label::Symbol, variableType::StateType; kwargs...)
return State{typeof(variableType)}(; label, kwargs...)
end

function State(state::State; kwargs...)
return State{typeof(getVariableType(state))}(;
return State{typeof(getStateKind(state))}(;
(key => deepcopy(getproperty(state, key)) for key in fieldnames(State))...,
kwargs...,
)
Expand Down Expand Up @@ -255,7 +255,7 @@ end
function VariableDFG(label::Symbol, state::State; kwargs...)
return VariableDFG(
label,
getStateType(state);
getStateKind(state);
states = OrderedDict(state.label => state),
kwargs...,
)
Expand Down Expand Up @@ -299,8 +299,7 @@ $(TYPEDFIELDS)
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
tags::Set{Symbol}
"""Symbol for the state type for the underlying variable.
Accessor: [`getStateType`](@ref)"""
"""Symbol for the state type for the underlying variable."""
statetype::Symbol
"""Dictionary of large data associated with this variable.
Accessors: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`mergeBlobentry!`](@ref), and [`deleteBlobentry!`](@ref)"""
Expand Down
9 changes: 9 additions & 0 deletions src/serialization/PackedSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ function resolvePackedType(obj::JSON.Object)
return Packed{getfield(pkg, Symbol(type.name))}
end

function resolveType(obj::DFG.JSON.Object)
type = obj.type
pkg = Base.require(Main, Symbol(type.pkg))
if !isdefined(Main, Symbol(type.pkg))
throw(SerializationError("Module $(pkg) is available, but not loaded in `Main`."))
end
return getfield(pkg, Symbol(type.name))
end

@choosetype Packed resolvePackedType

# Stash optional TypeMetadata expansion function.
Expand Down
2 changes: 1 addition & 1 deletion src/serialization/StateSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function packState(state::State{T}) where {T <: StateType}
vecbw = state.bw[:],
dimbw = size(state.bw, 1),
separator = state.separator,
statetype = stringVariableType(getStateType(state)),
statetype = stringVariableType(getStateKind(state)),
initialized = state.initialized,
observability = state.observability,
marginalized = state.marginalized,
Expand Down
49 changes: 30 additions & 19 deletions src/services/CompareUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,36 @@ implement compare if needed.
const GeneratedCompareUnion = Union{
State,
Blobentry,
VariableCompute,
VariableDFG,
Bloblet,
VariableSummary,
VariableSkeleton,
FactorDFG,
FactorSummary,
FactorSkeleton,
FactorState,
}

@generated function ==(x::T, y::T) where {T <: GeneratedCompareUnion}
ignored = [:solvercache, :solverData, :solvable] #FIXME solvable stopped working- skipping for now (removed getproperty overload)
return mapreduce(
n -> :(x.$n == y.$n),
(a, b) -> :($a && $b),
setdiff(fieldnames(x), ignored),
return mapreduce(n -> :(x.$n == y.$n), (a, b) -> :($a && $b), fieldnames(x))
end

function ==(x::FactorDFG, y::FactorDFG)
ignored = [:solvercache, :solvable]
tp = mapreduce(
n -> getproperty(x, n) == getproperty(y, n),
(a, b) -> a && b,
setdiff(propertynames(x), ignored),
)
return tp && getSolvable(x) == getSolvable(y)
end

function ==(x::VariableDFG, y::VariableDFG)
ignored = [:solvable]
tp = mapreduce(
n -> getproperty(x, n) == getproperty(y, n),
(a, b) -> a && b,
setdiff(propertynames(x), ignored),
)
return tp && getSolvable(x) == getSolvable(y)
end

##==============================================================================
Expand Down Expand Up @@ -76,7 +89,7 @@ function compareFields(
for field in fieldnames(T1)
(field in skip) && continue
tp = compareField(Al, Bl, field)
show && @debug(" $tp : $field") === nothing
show && !tp && @debug(" $tp : $field")
show &&
!tp &&
(@debug " $field" a = getproperty(Al, field) b = getproperty(Bl, field))
Expand Down Expand Up @@ -220,7 +233,7 @@ function compare(a::State, b::State)
# a.dontmargin != b.dontmargin &&
# @debug("dontmargin is not equal") === nothing &&
# return false
getVariableType(a) != getVariableType(b) &&
getStateKind(a) != getStateKind(b) &&
@debug("variableType is not equal") === nothing &&
return false
return true
Expand All @@ -241,20 +254,19 @@ function compareVariable(
#
skiplist = union(
[
:attributes;
:states;
:createdTimestamp;
:lastUpdatedTimestamp;
:timezone;
:zone
:atzone;
:inzone;
:blobentries;
:bloblets
],
skip,
)
TP = compareAll(A, B; skip = skiplist, show = show)
varskiplist = skipsamples ? [:val; :bw] : Symbol[]
skiplist = union([:variableType;], varskiplist)
union!(skiplist, skip)
TP = TP && compareAll(A.states, B.states; skip = skiplist, show = show)
# TP = TP && compareAll(A.states, B.states; skip = skiplist, show = show)

Ad = getState(A, :default) #FIXME why onlly comparing default?
Bd = getState(B, :default)
Expand All @@ -263,9 +275,8 @@ function compareVariable(
varskiplist = union(varskiplist, [:variableType])
union!(varskiplist, skip)
TP = TP && compareAll(Ad, Bd; skip = varskiplist, show = show)
TP = TP && typeof(getVariableType(Ad)) == typeof(getVariableType(Bd))
TP =
TP && compareAll(getVariableType(Ad), getVariableType(Bd); show = show, skip = skip)
TP = TP && typeof(getStateKind(Ad)) == typeof(getStateKind(Bd))
TP = TP && compareAll(getStateKind(Ad), getStateKind(Bd); show = show, skip = skip)
return TP::Bool
end

Expand Down
4 changes: 2 additions & 2 deletions src/services/CustomPrinting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function printVariable(
ioc = IOContext(io, :limit => limit, :compact => compact)

if short
# opmemt = (getVariableType(vert) |> typeof ).name
vari = getStateType(vert) |> typeof
# opmemt = (getStateKind(vert) |> typeof ).name
vari = getStateKind(vert) |> typeof
printstyled(ioc, nameof((typeof(vert))), "{"; bold = true)
printstyled(ioc, vari; bold = true, color = :blue)
printstyled(ioc, "...}"; bold = true)
Expand Down
Loading
Loading