diff --git a/NEWS.md b/NEWS.md index 20b51c3c..ceb3c955 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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. diff --git a/src/GraphsDFG/entities/GraphsDFG.jl b/src/GraphsDFG/entities/GraphsDFG.jl index 2f4c58ee..9463a5b0 100644 --- a/src/GraphsDFG/entities/GraphsDFG.jl +++ b/src/GraphsDFG/entities/GraphsDFG.jl @@ -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} @@ -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) @@ -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, @@ -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 diff --git a/src/GraphsDFG/services/GraphsDFGSerialization.jl b/src/GraphsDFG/services/GraphsDFGSerialization.jl index b229a06b..1cd210f6 100644 --- a/src/GraphsDFG/services/GraphsDFGSerialization.jl +++ b/src/GraphsDFG/services/GraphsDFGSerialization.jl @@ -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() @@ -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}} @@ -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 @@ -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) diff --git a/src/services/AbstractDFG.jl b/src/services/AbstractDFG.jl index 8f716bc7..6270e82d 100644 --- a/src/services/AbstractDFG.jl +++ b/src/services/AbstractDFG.jl @@ -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}` @@ -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) diff --git a/test/data/0_24_0.tar.gz b/test/data/archive/0_24_0.tar.gz similarity index 100% rename from test/data/0_24_0.tar.gz rename to test/data/archive/0_24_0.tar.gz diff --git a/test/iifInterfaceTests.jl b/test/iifInterfaceTests.jl index deca20db..f8fce79d 100644 --- a/test/iifInterfaceTests.jl +++ b/test/iifInterfaceTests.jl @@ -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 = "test@navability.io") + dfg2 = T(; solverParams = SolverParams(), graphLabel = :testGraph) # Build a new in-memory IIF graph to transfer into the new graph. iiffg = initfg() diff --git a/test/interfaceTests.jl b/test/interfaceTests.jl index 7a71643a..516e001d 100644 --- a/test/interfaceTests.jl +++ b/test/interfaceTests.jl @@ -150,7 +150,7 @@ end # order up to here is important, TODO maybe make independant ## @testset "Adjacency Matrices" begin - fg = testDFGAPI(; userLabel = "test@navability.io") + fg = testDFGAPI(; graphLabel = :testGraph) addVariable!(fg, var1) setSolvable!(fg, :a, 1) addVariable!(fg, var2) @@ -192,7 +192,7 @@ end @testset "Copy Functions" begin rand(6) - fg = testDFGAPI(; userLabel = "test@navability.io") + fg = testDFGAPI(; graphLabel = :testGraph) addVariable!(fg, var1) addVariable!(fg, var2) addVariable!(fg, var3) @@ -203,7 +203,7 @@ end # @test getVariableOrder(fg,:f1) == getVariableOrder(fgcopy,:f1) #test copyGraph, deepcopyGraph[!] - fgcopy = testDFGAPI(; userLabel = "test@navability.io") + fgcopy = testDFGAPI(; graphLabel = :testGraph) DFG.deepcopyGraph!(fgcopy, fg) @test getVariableOrder(fg, :abf1) == getVariableOrder(fgcopy, :abf1) diff --git a/test/testBlocks.jl b/test/testBlocks.jl index c004a569..7a3696a9 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -1410,7 +1410,7 @@ function connectivityTestGraph( numNodesType1 = 5 numNodesType2 = 5 - dfg = T(; userLabel = "test@navability.io") + dfg = T(; graphLabel = :testGraph) vars = vcat( map( @@ -1649,7 +1649,7 @@ function ProducingDotFiles( ) # "Producing Dot Files" # create a simpler graph for dot testing - dotdfg = testDFGAPI(; userLabel = "test@navability.io") + dotdfg = testDFGAPI(; graphLabel = :testGraph) if v1 === nothing v1 = VARTYPE(:a, VariableState{TestVariableType1}()) @@ -1775,7 +1775,7 @@ function CopyFunctionsTest(testDFGAPI; kwargs...) dcdfg_part1 = deepcopyGraph(GraphsDFG, dfg, vlbls1) dcdfg_part2 = deepcopyGraph(GraphsDFG, dfg, vlbls2) - mergedGraph = testDFGAPI(; userLabel = "test@navability.io") + mergedGraph = testDFGAPI(; graphLabel = :testGraph) mergeGraph!(mergedGraph, dcdfg_part1) mergeGraph!(mergedGraph, dcdfg_part2) @@ -1840,7 +1840,7 @@ function FileDFGTestBlock(testDFGAPI; kwargs...) # Save and load the graph to test. saveDFG(dfg, filename) - retDFG = testDFGAPI(; userLabel = "test@navability.io") + retDFG = testDFGAPI(; graphLabel = :testGraph) @info "Going to load $filename" @test_throws AssertionError loadDFG!(retDFG, "badfilename")