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: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
# 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

# v0.27
- `delete` returns number of nodes deleted and no longer the object that was deleted.
Expand Down
148 changes: 1 addition & 147 deletions src/GraphsDFG/entities/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ mutable struct GraphsDFG{
} <: AbstractDFG{T}
g::FactorGraph{Int, V, F}
description::String
# ------ deprecated fields ---------
userLabel::Union{Nothing, String}
robotLabel::Union{Nothing, String}
sessionLabel::Union{Nothing, String}
userData::Union{Nothing, Dict{Symbol, SmallDataTypes}}
robotData::Union{Nothing, Dict{Symbol, SmallDataTypes}}
sessionData::Union{Nothing, Dict{Symbol, SmallDataTypes}}
userBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}}
robotBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}}
sessionBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}}
# ---------------------------------
addHistory::Vector{Symbol} #TODO: Discuss more - is this an audit trail?
solverParams::T # Solver parameters
blobStores::Dict{Symbol, AbstractBlobstore}
Expand All @@ -45,43 +34,6 @@ function DFG.setMetadata!(dfg::GraphsDFG, metadata::Dict{Symbol, SmallDataTypes}
return merge!(dfg.graphMetadata, metadata)
end

deprecatedDfgFields = [
:userLabel,
:robotLabel,
:sessionLabel,
:userData,
:robotData,
:sessionData,
:userBlobEntries,
:robotBlobEntries,
:sessionBlobEntries,
]

function Base.propertynames(x::GraphsDFG, private::Bool = false)
return setdiff(fieldnames(GraphsDFG), deprecatedDfgFields)
end

# deprected in v0.25
function Base.getproperty(dfg::GraphsDFG, f::Symbol)
if f in deprecatedDfgFields
Base.depwarn(
"Field $f is deprecated as part of removing user/robot/session. Replace with Agent or Factorgraph [Label/Metadata/BlobEntries].",
:getproperty,
)
end
return getfield(dfg, f)
end

function Base.setproperty!(dfg::GraphsDFG, f::Symbol, val)
if f in deprecatedDfgFields
Base.depwarn(
"Field $f is deprecated as part of removing user/robot/session. Replace with Agent or Factorgraph [Label/Metadata/BlobEntries].",
:setproperty!,
)
end
return setfield!(dfg, f, val)
end

"""
$(SIGNATURES)

Expand Down Expand Up @@ -115,52 +67,15 @@ function GraphsDFG{T, V, F}(
agentMetadata,
agentBlobEntries,
),

#Deprecated fields
userLabel::Union{Nothing, String} = nothing,
robotLabel::Union{Nothing, String} = nothing,
sessionLabel::Union{Nothing, String} = nothing,
userData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing,
robotData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing,
sessionData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing,
userBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing,
robotBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing,
sessionBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing,
) where {T <: AbstractParams, V <: AbstractDFGVariable, F <: AbstractDFGFactor}
if any([
!isnothing(userLabel),
!isnothing(robotLabel),
!isnothing(sessionLabel),
!isnothing(userData),
!isnothing(robotData),
!isnothing(sessionData),
!isnothing(userBlobEntries),
!isnothing(robotBlobEntries),
!isnothing(sessionBlobEntries),
])
#deprecated in v0.25
Base.depwarn(
"Kwargs with user/robot/session is deprecated. Replace with agent[Label/Metadata/BlobEntries] or graph[Label/Metadata/BlobEntries].",
:GraphsDFG,
)
end

# Validate the userLabel, robotLabel, and sessionLabel
# Validate the graphLabel and agentLabel
!isValidLabel(graphLabel) && error("'$graphLabel' is not a valid label")
!isValidLabel(agentLabel) && error("'$agentLabel' is not a valid label")

return GraphsDFG{T, V, F}(
g,
graphDescription,
userLabel,
robotLabel,
sessionLabel,
userData,
robotData,
sessionData,
userBlobEntries,
robotBlobEntries,
sessionBlobEntries,
addHistory,
solverParams,
blobStores,
Expand Down Expand Up @@ -196,64 +111,3 @@ function GraphsDFG(
) where {T}
return GraphsDFG{T, VariableCompute, FactorCompute}(g; solverParams, kwargs...)
end

function GraphsDFG(
description::String,
userLabel::String,
robotLabel::String,
sessionLabel::String,
userData::Dict{Symbol, SmallDataTypes},
robotData::Dict{Symbol, SmallDataTypes},
sessionData::Dict{Symbol, SmallDataTypes},
solverParams::AbstractParams,
blobStores = Dict{Symbol, AbstractBlobstore}(),
)
#deprecated in v0.25
Base.depwarn(
"user/robot/session is deprecated. Replace with agent[Label/Metadata/BlobEntries] or graph[Label/Metadata/BlobEntries].",
:GraphsDFG,
)
return GraphsDFG{typeof(solverParams), VariableCompute, FactorCompute}(
FactorGraph{Int, VariableCompute, FactorCompute}();
description,
userLabel,
robotLabel,
sessionLabel,
userData,
robotData,
sessionData,
solverParams,
blobStores,
)
end

function GraphsDFG{T, V, F}(
description::String,
userLabel::String,
robotLabel::String,
sessionLabel::String,
userData::Dict{Symbol, SmallDataTypes},
robotData::Dict{Symbol, SmallDataTypes},
sessionData::Dict{Symbol, SmallDataTypes},
solverParams::T,
blobStores = Dict{Symbol, AbstractBlobstore}(),
) where {T <: AbstractParams, V <: AbstractDFGVariable, F <: AbstractDFGFactor}

#deprecated in v0.25
Base.depwarn(
"user/robot/session is deprecated. Replace with agent[Label/Metadata/BlobEntries] or graph[Label/Metadata/BlobEntries].",
:GraphsDFG,
)
return GraphsDFG{T, V, F}(
FactorGraph{Int, V, F}();
description,
userLabel,
robotLabel,
sessionLabel,
userData,
robotData,
sessionData,
solverParams,
blobStores,
)
end
96 changes: 10 additions & 86 deletions src/GraphsDFG/services/GraphsDFGSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,17 @@ using InteractiveUtils

@kwdef struct PackedGraphsDFG{T <: AbstractParams}
description::String
# ------ deprecated fields v0.25 ---------
userLabel::Union{Nothing, String} = nothing
robotLabel::Union{Nothing, String} = nothing
sessionLabel::Union{Nothing, String} = nothing
userData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing
robotData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing
sessionData::Union{Nothing, Dict{Symbol, SmallDataTypes}} = nothing
userBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing
robotBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing
sessionBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}} = nothing
# ---------------------------------
addHistory::Vector{Symbol}
solverParams::T
solverParams_type::String = string(nameof(typeof(solverParams)))
typePackedVariable::Bool = false # Are variables packed or full
typePackedFactor::Bool = false # Are factors packed or full
blobStores::Union{Nothing, Dict{Symbol, FolderStore{Vector{UInt8}}}}

# new structure to replace URS
#TODO remove union nothing after v0.25
graphLabel::Union{Nothing, Symbol}
graphTags::Union{Nothing, Vector{Symbol}}
graphMetadata::Union{Nothing, Dict{Symbol, SmallDataTypes}}
graphBlobEntries::Union{Nothing, OrderedDict{Symbol, Blobentry}}
agent::Union{Nothing, Agent}
graphLabel::Symbol
graphTags::Vector{Symbol}
graphMetadata::Dict{Symbol, SmallDataTypes}
graphBlobEntries::OrderedDict{Symbol, Blobentry}
agent::Agent
end

StructTypes.StructType(::Type{PackedGraphsDFG}) = StructTypes.AbstractType()
Expand All @@ -49,7 +35,7 @@ Packing function to serialize DFG metadata from.
function packDFGMetadata(fg::GraphsDFG)
commonfields = intersect(fieldnames(PackedGraphsDFG), fieldnames(GraphsDFG))

setdiff!(commonfields, [deprecatedDfgFields; :blobStores])
setdiff!(commonfields, [:blobStores])
blobStores = Dict{Symbol, FolderStore{Vector{UInt8}}}()
foreach(values(fg.blobStores)) do store
if store isa FolderStore{Vector{UInt8}}
Expand All @@ -71,63 +57,10 @@ end
function unpackDFGMetadata(packed::PackedGraphsDFG)
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG))

#FIXME Deprecate remove in DFG v0.24
# setdiff!(commonfields, [:blobStores])
# blobStores = Dict{Symbol, AbstractBlobstore}()
# !isnothing(packed.blobStores) && merge!(blobStores, packed.blobStores)

setdiff!(commonfields, [deprecatedDfgFields; :blobStores])
setdiff!(commonfields, [:blobStores])
blobStores = packed.blobStores

if isnothing(packed.agent)
agentBlobEntries = nothing
agentMetadata = nothing
agentLabel = nothing
graphBlobEntries = nothing
graphMetadata = nothing
graphLabel = nothing

for f in deprecatedDfgFields
if !isnothing(getproperty(packed, f))
if f == :robotBlobEntries
agentBlobEntries = getproperty(packed, f)
@warn "Converting deprecated $f to agentBlobEntries"
elseif f == :robotData
agentMetadata = getproperty(packed, f)
@warn "Converting deprecated $f to agentMetadata"
elseif f == :robotLabel
agentLabel = Symbol(getproperty(packed, f))
@warn "Converting deprecated $f to agentLabel"
elseif f == :sessionBlobEntries
graphBlobEntries = getproperty(packed, f)
@warn "Converting deprecated $f to graphBlobEntries"
elseif f == :sessionData
graphMetadata = getproperty(packed, f)
@warn "onverting deprecated $f to graphMetadata"
elseif f == :sessionLabel
graphLabel = Symbol(getproperty(packed, f))
@warn "Converting deprecated $f to graphLabel"
else
@warn """
Field $f is deprecated as part of removing user/robot/session. Replace with Agent or Factorgraph [Label/Metadata/BlobEntries]
No conversion done for $f
"""
end
end
end

agent = Agent(;
label = agentLabel,
blobEntries = agentBlobEntries,
metadata = agentMetadata,
)
else
agent = packed.agent
graphBlobEntries = packed.graphBlobEntries
graphMetadata = packed.graphMetadata
graphLabel = packed.graphLabel
end

#TODO add 'CanSerialize' trait to blobstores and also serialize NvaBlobStores
_isfolderstorepath(s) = false
_isfolderstorepath(s::FolderStore) = ispath(s.folder)
# FIXME escalate to keyword
Expand Down Expand Up @@ -157,22 +90,13 @@ function unpackDFGMetadata(packed::PackedGraphsDFG)
return !isnothing(v)
end

return GraphsDFG{typeof(packed.solverParams), VT, FT}(;
blobStores,
graphBlobEntries,
graphMetadata,
graphLabel,
agent,
props...,
)
return GraphsDFG{typeof(packed.solverParams), VT, FT}(; blobStores, props...)
end

function unpackDFGMetadata!(dfg::GraphsDFG, packed::PackedGraphsDFG)
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG))

#FIXME Deprecate remove Nothing union in DFG v0.24
#FIXME also remove deprectedDFG fields depr in v0.25
setdiff!(commonfields, [deprecatedDfgFields; :blobStores])
setdiff!(commonfields, [:blobStores])
!isnothing(packed.blobStores) && merge!(dfg.blobStores, packed.blobStores)

props = (k => getproperty(packed, k) for k in commonfields)
Expand Down
13 changes: 3 additions & 10 deletions src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ Base.Broadcast.broadcastable(dfg::AbstractDFG) = Ref(dfg)
##==============================================================================
## Interface for an AbstractDFG
##==============================================================================
# TODO update to remove URS
# TODO update to include graph and agent extras.
# Standard recommended fields to implement for AbstractDFG
# - `description::String`
# - `userLabel::String`
# - `robotLabel::String`
# - `sessionLabel::String`
# - `userData::Dict{Symbol, String}`
# - `robotData::Dict{Symbol, String}`
# - `sessionData::Dict{Symbol, String}`
# - `solverParams::T<:AbstractParams`
# - `addHistory::Vector{Symbol}`
# - `blobStores::Dict{Symbol, AbstractBlobstore}`
Expand Down Expand Up @@ -1582,9 +1576,8 @@ function getSummaryGraph(dfg::G) where {G <: AbstractDFG}
#TODO fix deprecated constructor
summaryDfg = GraphsDFG{NoSolverParams, VariableSummary, FactorSummary}(;
description = "Summary of $(getDescription(dfg))",
userLabel = dfg.userLabel,
robotLabel = dfg.robotLabel,
sessionLabel = dfg.sessionLabel,
agent = dfg.agent,
graphLabel = Symbol(getGraphLabel(dfg), "_summary_$(string(uuid4())[1:6])"),
)
deepcopyGraph!(summaryDfg, dfg)
# for v in getVariables(dfg)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/iifInterfaceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end
# dfg to copy to
# creating a whole new graph with the same labels
T = typeof(dfg)
dfg2 = T(; solverParams = SolverParams(), userLabel = "[email protected]")
dfg2 = T(; solverParams = SolverParams(), graphLabel = :testGraph)

# Build a new in-memory IIF graph to transfer into the new graph.
iiffg = initfg()
Expand Down
6 changes: 3 additions & 3 deletions test/interfaceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end
# order up to here is important, TODO maybe make independant
##
@testset "Adjacency Matrices" begin
fg = testDFGAPI(; userLabel = "[email protected]")
fg = testDFGAPI(; graphLabel = :testGraph)
addVariable!(fg, var1)
setSolvable!(fg, :a, 1)
addVariable!(fg, var2)
Expand Down Expand Up @@ -192,7 +192,7 @@ end

@testset "Copy Functions" begin
rand(6)
fg = testDFGAPI(; userLabel = "[email protected]")
fg = testDFGAPI(; graphLabel = :testGraph)
addVariable!(fg, var1)
addVariable!(fg, var2)
addVariable!(fg, var3)
Expand All @@ -203,7 +203,7 @@ end
# @test getVariableOrder(fg,:f1) == getVariableOrder(fgcopy,:f1)

#test copyGraph, deepcopyGraph[!]
fgcopy = testDFGAPI(; userLabel = "[email protected]")
fgcopy = testDFGAPI(; graphLabel = :testGraph)
DFG.deepcopyGraph!(fgcopy, fg)
@test getVariableOrder(fg, :abf1) == getVariableOrder(fgcopy, :abf1)

Expand Down
Loading
Loading