From 3c5320c1bce5d2b354808b69be0c87b145367382 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 10 Sep 2025 19:16:26 +0200 Subject: [PATCH 1/4] Rename SmallDataTypes -> MetadataTypes and update to @defStateType --- NEWS.md | 7 +++++-- src/GraphsDFG/GraphsDFG.jl | 5 ++++- src/GraphsDFG/entities/GraphsDFG.jl | 6 +++--- src/GraphsDFG/services/GraphsDFGSerialization.jl | 2 +- src/entities/AbstractDFG.jl | 2 +- src/entities/Agent_and_Graph.jl | 4 ++-- src/entities/DFGFactor.jl | 6 +++--- src/entities/DFGVariable.jl | 16 +++------------- src/services/AbstractDFG.jl | 6 +++--- src/services/DFGVariable.jl | 12 ++++-------- src/services/Serialization.jl | 2 +- test/fileDFGTests.jl | 4 ++-- test/iifInterfaceTests.jl | 4 ++-- test/plottingTest.jl | 2 +- test/runtests.jl | 2 ++ test/testBlocks.jl | 16 ++++++++-------- test/test_defVariable.jl | 8 ++++---- 17 files changed, 49 insertions(+), 55 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0ddfa300..babfdb21 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ Listing news on any major breaking changes in DFG. For regular changes, see int - 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 - Rename `VariableState` -> `State` +- @defVariable -> @defStateType +- All deprecated and unstable function exports have been removed. Use the new macro `@usingDFG true` to import all exports. In the future, stable but non-exported functions will be marked as `public`. +- Rename SmallDataTypes -> MetadataTypes Abstract Types Standardized, see #1153: - AbstractParams -> [Abstract]DFGParams @@ -18,8 +21,8 @@ Abstract Types Standardized, see #1153: # v0.27 - `delete` returns number of nodes deleted and no longer the object that was deleted. -- Deprecate `updateVariable!` for `mergeVariable!`, note `merege` returns number of nodes updated/added. -- Deprecate `updateFactor!` for `mergeFactor!`, note `merege` returns number of nodes updated/added. +- Deprecate `updateVariable!` for `mergeVariable!`, note `merge` returns number of nodes updated/added. +- Deprecate `updateFactor!` for `mergeFactor!`, note `merge` returns number of nodes updated/added. - Rename BlobEntry to Blobentry, see #1123. - Rename BlobStore to Blobstore, see #1124. - Refactor the Factor solver data structure, see #1127: diff --git a/src/GraphsDFG/GraphsDFG.jl b/src/GraphsDFG/GraphsDFG.jl index 61a75647..68246524 100644 --- a/src/GraphsDFG/GraphsDFG.jl +++ b/src/GraphsDFG/GraphsDFG.jl @@ -16,7 +16,10 @@ using ...DistributedFactorGraphs: AbstractGraphVariable, AbstractGraphFactor, NoSolverParams, - filterDFG! + filterDFG!, + getSolvable, + getVariableType, + MetadataTypes # import DFG functions to extend import ...DistributedFactorGraphs: diff --git a/src/GraphsDFG/entities/GraphsDFG.jl b/src/GraphsDFG/entities/GraphsDFG.jl index 2064f933..b854a79a 100644 --- a/src/GraphsDFG/entities/GraphsDFG.jl +++ b/src/GraphsDFG/entities/GraphsDFG.jl @@ -24,7 +24,7 @@ DFG.getGraphLabel(dfg::GraphsDFG) = dfg.graph.label DFG.getMetadata(dfg::GraphsDFG) = dfg.graph.metadata DFG.getDescription(dfg::GraphsDFG) = dfg.graph.description -function DFG.setMetadata!(dfg::GraphsDFG, metadata::Dict{Symbol, SmallDataTypes}) +function DFG.setMetadata!(dfg::GraphsDFG, metadata::Dict{Symbol, MetadataTypes}) # with set old data should be removed, but care is taken to make sure its not the same object dfg.graph.metadata !== metadata && empty!(dfg.graph.metadata) return merge!(dfg.graph.metadata, metadata) @@ -50,7 +50,7 @@ function GraphsDFG{T, V, F}( # factor graph TODO maybe move to FactorGraph or make a new Graph struct to hold these (similar to Agent) graphLabel::Symbol = Symbol("factorgraph_", string(uuid4())[1:6]), graphTags::Vector{Symbol} = Symbol[], - graphMetadata = Dict{Symbol, SmallDataTypes}(), + graphMetadata = Dict{Symbol, MetadataTypes}(), graphBlobEntries = OrderedDict{Symbol, Blobentry}(), description::String = "", graphDescription::String = description, @@ -65,7 +65,7 @@ function GraphsDFG{T, V, F}( agentLabel::Symbol = :DefaultAgent, agentDescription::String = "", agentTags::Vector{Symbol} = Symbol[], - agentMetadata = Dict{Symbol, SmallDataTypes}(), + agentMetadata = Dict{Symbol, MetadataTypes}(), agentBlobEntries = OrderedDict{Symbol, Blobentry}(), agent::Agent = Agent( agentLabel, diff --git a/src/GraphsDFG/services/GraphsDFGSerialization.jl b/src/GraphsDFG/services/GraphsDFGSerialization.jl index b26a850c..87e09352 100644 --- a/src/GraphsDFG/services/GraphsDFGSerialization.jl +++ b/src/GraphsDFG/services/GraphsDFGSerialization.jl @@ -10,7 +10,7 @@ using InteractiveUtils blobStores::Union{Nothing, Dict{Symbol, FolderStore{Vector{UInt8}}}} graphLabel::Symbol graphTags::Vector{Symbol} - graphMetadata::Dict{Symbol, SmallDataTypes} + graphMetadata::Dict{Symbol, MetadataTypes} graphBlobEntries::OrderedDict{Symbol, Blobentry} agent::Agent end diff --git a/src/entities/AbstractDFG.jl b/src/entities/AbstractDFG.jl index 71b2a25e..1609d384 100644 --- a/src/entities/AbstractDFG.jl +++ b/src/entities/AbstractDFG.jl @@ -57,7 +57,7 @@ StructTypes.StructType(::NoSolverParams) = StructTypes.Struct() """ Types valid for small data. """ -const SmallDataTypes = Union{ +const MetadataTypes = Union{ Int, Float64, String, diff --git a/src/entities/Agent_and_Graph.jl b/src/entities/Agent_and_Graph.jl index 93561dd2..9c6d8205 100644 --- a/src/entities/Agent_and_Graph.jl +++ b/src/entities/Agent_and_Graph.jl @@ -3,7 +3,7 @@ label::Symbol = :DefaultAgent description::String = "" tags::Vector{Symbol} = Symbol[] - metadata::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}() + metadata::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}() blobEntries::OrderedDict{Symbol, Blobentry} = OrderedDict{Symbol, Blobentry}() end @@ -11,6 +11,6 @@ end label::Symbol = :DefaultFactorgraph description::String = "" tags::Vector{Symbol} = Symbol[] - metadata::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}() + metadata::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}() blobEntries::OrderedDict{Symbol, Blobentry} = OrderedDict{Symbol, Blobentry}() end diff --git a/src/entities/DFGFactor.jl b/src/entities/DFGFactor.jl index e9987912..4813c77f 100644 --- a/src/entities/DFGFactor.jl +++ b/src/entities/DFGFactor.jl @@ -146,7 +146,7 @@ function FactorDFG( inflation::Real = 3.0, label::Symbol = assembleFactorName(xisyms), nstime::Int = 0, - metadata::Dict{Symbol, DFG.SmallDataTypes} = Dict{Symbol, DFG.SmallDataTypes}(), + metadata::Dict{Symbol, DFG.MetadataTypes} = Dict{Symbol, DFG.MetadataTypes}(), ) # create factor data state = FactorState(; multihypo, nullhypo, inflation) @@ -208,7 +208,7 @@ Base.@kwdef struct FactorCompute{FT <: AbstractObservation, N} <: AbstractGraphF solvable::Base.RefValue{Int} """Dictionary of small data associated with this variable. Accessors: [`getMetadata`](@ref), [`setMetadata!`](@ref)""" - smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}() + smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}() #refactor fields """Observation function or measurement for this factor. @@ -241,7 +241,7 @@ function FactorCompute( solvable::Int = 1, nstime::Nanosecond = Nanosecond(0), id::Union{UUID, Nothing} = nothing, - smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), + smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(), solverData = nothing, ) if !isnothing(solverData) diff --git a/src/entities/DFGVariable.jl b/src/entities/DFGVariable.jl index f3e84eac..dfd3b98b 100644 --- a/src/entities/DFGVariable.jl +++ b/src/entities/DFGVariable.jl @@ -250,7 +250,7 @@ function VariableDFG( timestamp::ZonedDateTime = now(tz"UTC"), solvable::Int = 1, nanosecondtime::Int64 = 0, - smalldata::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), + smalldata::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(), kwargs..., ) union!(tags, [:VARIABLE]) @@ -274,12 +274,7 @@ StructTypes.idproperty(::Type{VariableDFG}) = :id StructTypes.omitempties(::Type{VariableDFG}) = (:id,) function getMetadata(v::VariableDFG) - return JSON3.read(base64decode(v.metadata), Dict{Symbol, SmallDataTypes}) -end - -function setMetadata!(v::VariableDFG, metadata::Dict{Symbol, SmallDataTypes}) - return error("FIXME: Metadata is not currently mutable in a Variable") - # v.metadata = base64encode(JSON3.write(metadata)) + return JSON3.read(base64decode(v.metadata), Dict{Symbol, MetadataTypes}) end ##------------------------------------------------------------------------------ @@ -316,7 +311,7 @@ Base.@kwdef struct VariableCompute{T <: StateType, P, N} <: AbstractGraphVariabl solverDataDict::Dict{Symbol, State{T, P, N}} = Dict{Symbol, State{T, P, N}}() """Dictionary of small data associated with this variable. Accessors: [`getMetadata`](@ref), [`setMetadata!`](@ref)""" - smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}() + smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}() """Dictionary of large data associated with this variable. Accessors: [`addBlobentry!`](@ref), [`getBlobentry`](@ref), [`mergeBlobentry!`](@ref), and [`deleteBlobentry!`](@ref)""" dataDict::Dict{Symbol, Blobentry} = Dict{Symbol, Blobentry}() @@ -380,11 +375,6 @@ end getMetadata(v::VariableCompute) = v.smallData -function setMetadata!(v::VariableCompute, metadata::Dict{Symbol, SmallDataTypes}) - v.smallData !== metadata && empty!(v.smallData) - return merge!(v.smallData, metadata) -end - ##------------------------------------------------------------------------------ ## VariableSummary lv1 ##------------------------------------------------------------------------------ diff --git a/src/services/AbstractDFG.jl b/src/services/AbstractDFG.jl index 44630414..17886ee5 100644 --- a/src/services/AbstractDFG.jl +++ b/src/services/AbstractDFG.jl @@ -108,7 +108,7 @@ function getTypeDFGFactors end $SIGNATURES Set the metadata of the node. """ -function setMetadata!(node, metadata::Dict{Symbol, SmallDataTypes}) +function setMetadata!(node, metadata::Dict{Symbol, MetadataTypes}) # with set old data should be removed, but care is taken to make sure its not the same object node.metadata !== metadata && empty!(node.metadata) return merge!(node.metadata, metadata) @@ -142,7 +142,7 @@ $SIGNATURES Set the metadata of the agent in the AbstractDFG. """ -function setAgentMetadata!(dfg::AbstractDFG, data::Dict{Symbol, SmallDataTypes}) +function setAgentMetadata!(dfg::AbstractDFG, data::Dict{Symbol, MetadataTypes}) agent = getAgent(dfg) return setMetadata!(agent, data) end @@ -159,7 +159,7 @@ $SIGNATURES Set the metadata of the factorgraph in the AbstractDFG. """ -function setGraphMetadata!(dfg::AbstractDFG, data::Dict{Symbol, SmallDataTypes}) +function setGraphMetadata!(dfg::AbstractDFG, data::Dict{Symbol, MetadataTypes}) return setMetadata!(dfg, data) end diff --git a/src/services/DFGVariable.jl b/src/services/DFGVariable.jl index f134cc7e..6980cde1 100644 --- a/src/services/DFGVariable.jl +++ b/src/services/DFGVariable.jl @@ -92,7 +92,7 @@ See the [Manifolds.jl documentation on creating your own manifolds](https://juli Example: ``` -DFG.@defVariable Pose2 SpecialEuclideanGroup(2) ArrayPartition([0;0.0],[1 0; 0 1.0]) +DFG.@defStateType Pose2 SpecialEuclideanGroup(2) ArrayPartition([0;0.0],[1 0; 0 1.0]) ``` """ macro defStateType(structname, manifold, point_identity) @@ -101,7 +101,7 @@ macro defStateType(structname, manifold, point_identity) Base.@__doc__ struct $structname <: StateType{Any} end # user manifold must be a <:Manifold - @assert ($manifold isa AbstractManifold) "@defVariable of " * + @assert ($manifold isa AbstractManifold) "defStateType of " * string($structname) * " requires that the " * string($manifold) * @@ -116,10 +116,6 @@ macro defStateType(structname, manifold, point_identity) ) end -macro defVariable(args...) - return esc(:(DFG.@defStateType $(args...))) -end - """ @defStateTypeN StructName manifold point_identity @@ -551,7 +547,7 @@ end $(SIGNATURES) Add a Metadata pair `key=>value` for variable `label` in `dfg` """ -function addMetadata!(dfg::AbstractDFG, label::Symbol, pair::Pair{Symbol, <:SmallDataTypes}) +function addMetadata!(dfg::AbstractDFG, label::Symbol, pair::Pair{Symbol, <:MetadataTypes}) v = getVariable(dfg, label) haskey(v.smallData, pair.first) && throw(LabelExistsError("Metadata", pair.first)) push!(v.smallData, pair) @@ -566,7 +562,7 @@ Update a Metadata pair `key=>value` for variable `label` in `dfg` function updateMetadata!( dfg::AbstractDFG, label::Symbol, - pair::Pair{Symbol, <:SmallDataTypes}; + pair::Pair{Symbol, <:MetadataTypes}; warn_if_absent::Bool = true, ) v = getVariable(dfg, label) diff --git a/src/services/Serialization.jl b/src/services/Serialization.jl index bc36733f..f2598ecf 100644 --- a/src/services/Serialization.jl +++ b/src/services/Serialization.jl @@ -251,7 +251,7 @@ function unpackVariable(variable::VariableDFG; skipVersionCheck::Bool = false) dataDict = Dict{Symbol, Blobentry}( map(de -> de.label, variable.blobEntries) .=> variable.blobEntries, ) - metadata = JSON3.read(base64decode(variable.metadata), Dict{Symbol, DFG.SmallDataTypes}) + metadata = JSON3.read(base64decode(variable.metadata), Dict{Symbol, DFG.MetadataTypes}) return VariableCompute( variable.label, diff --git a/test/fileDFGTests.jl b/test/fileDFGTests.jl index 5de516ee..b6092a1c 100644 --- a/test/fileDFGTests.jl +++ b/test/fileDFGTests.jl @@ -108,8 +108,8 @@ using UUIDs addGraphBlobentry!(dfg, be) #TODO addAgentBlobentry!(dfg, be) - smallRobotData = Dict{Symbol, SmallDataTypes}(:a => "43", :b => "small_robot") - smallSessionData = Dict{Symbol, SmallDataTypes}(:a => "44", :b => "small_session") + smallRobotData = Dict{Symbol, MetadataTypes}(:a => "43", :b => "small_robot") + smallSessionData = Dict{Symbol, MetadataTypes}(:a => "44", :b => "small_session") setAgentMetadata!(dfg, smallRobotData) setGraphMetadata!(dfg, smallSessionData) diff --git a/test/iifInterfaceTests.jl b/test/iifInterfaceTests.jl index 1700399f..8fc05891 100644 --- a/test/iifInterfaceTests.jl +++ b/test/iifInterfaceTests.jl @@ -205,8 +205,8 @@ end @test_throws LabelNotFoundError isInitialized(v2, :second) # Session, robot, and user small data tests - smallRobotData = Dict{Symbol, SmallDataTypes}(:a => "43", :b => "Hello") - smallSessionData = Dict{Symbol, SmallDataTypes}(:a => "44", :b => "Hello") + smallRobotData = Dict{Symbol, MetadataTypes}(:a => "43", :b => "Hello") + smallSessionData = Dict{Symbol, MetadataTypes}(:a => "44", :b => "Hello") setAgentMetadata!(dfg, deepcopy(smallRobotData)) setGraphMetadata!(dfg, deepcopy(smallSessionData)) @test getAgentMetadata(dfg) == smallRobotData diff --git a/test/plottingTest.jl b/test/plottingTest.jl index 487dfa18..96a47573 100644 --- a/test/plottingTest.jl +++ b/test/plottingTest.jl @@ -7,7 +7,7 @@ using Manifolds ## # struct TestInferenceVariable1 <: StateType end -@defVariable TestInferenceVariable1 Euclidean(1) [0.0;] +@defStateType TestInferenceVariable1 Euclidean(1) [0.0;] # Now make a complex graph for connectivity tests numNodes = 10 diff --git a/test/runtests.jl b/test/runtests.jl index 6dbf241b..3319bd72 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,8 @@ using Aqua using DistributedFactorGraphs: ArrayPartition, OrderedDict +DFG.@usingDFG true + # If you want to enable debugging logging (very verbose!) # using Logging # logger = SimpleLogger(stdout, Logging.Debug) diff --git a/test/testBlocks.jl b/test/testBlocks.jl index afea6dbb..d9ee7b0b 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -19,7 +19,7 @@ import Base: convert # Base.convert(::Type{<:Tuple}, ::typeof(TranslationGroup(2))) = (:Euclid, :Euclid) # define a few varaible to use -@defVariable TestVariableType1 TranslationGroup(1) [0.0;] +@defStateType TestVariableType1 TranslationGroup(1) [0.0;] DFG.@defStateTypeN TestVariableType{N} TranslationGroup(N) zeros(N) const TestVariableType2 = TestVariableType{2} @@ -98,8 +98,8 @@ function DFGStructureAndAccessors( des = "description for runtest" rId = :testRobotId sId = :testSessionId - rd = Dict{Symbol, SmallDataTypes}(:rd => "rdEntry") - sd = Dict{Symbol, SmallDataTypes}(:sd => "sdEntry") + rd = Dict{Symbol, MetadataTypes}(:rd => "rdEntry") + sd = Dict{Symbol, MetadataTypes}(:sd => "sdEntry") fg = T(; description = des, agentLabel = rId, @@ -123,9 +123,9 @@ function DFGStructureAndAccessors( @test getSolverParams(fg) == NoSolverParams() - smallUserData = Dict{Symbol, SmallDataTypes}(:a => "42", :b => "Hello") - smallRobotData = Dict{Symbol, SmallDataTypes}(:a => "43", :b => "Hello") - smallSessionData = Dict{Symbol, SmallDataTypes}(:a => "44", :b => "Hello") + smallUserData = Dict{Symbol, MetadataTypes}(:a => "42", :b => "Hello") + smallRobotData = Dict{Symbol, MetadataTypes}(:a => "43", :b => "Hello") + smallSessionData = Dict{Symbol, MetadataTypes}(:a => "44", :b => "Hello") #TODO CRUD vs set @test setAgentMetadata!(fg, deepcopy(smallRobotData)) == smallRobotData @@ -215,7 +215,7 @@ function DFGVariableSCA() v1_lbl = :a v1_tags = Set([:VARIABLE, :POSE]) - small = Dict{Symbol, SmallDataTypes}(:small => "data") + small = Dict{Symbol, MetadataTypes}(:small => "data") testTimestamp = now(localzone()) # Constructors v1 = VariableCompute( @@ -262,7 +262,7 @@ function DFGVariableSCA() @test getPPEDict(v1) == v1.ppeDict - @test getMetadata(v1) == Dict{Symbol, SmallDataTypes}() + @test getMetadata(v1) == Dict{Symbol, MetadataTypes}() @test getVariableType(v1) == TestVariableType1() diff --git a/test/test_defVariable.jl b/test/test_defVariable.jl index 450a9adc..2b54b8f9 100644 --- a/test/test_defVariable.jl +++ b/test/test_defVariable.jl @@ -3,17 +3,17 @@ using Manifolds using Test using LinearAlgebra -@testset "Testing @defVariable" begin +@testset "Testing @defStateType" begin ## struct NotAManifold end - @test_throws AssertionError @defVariable(MyVar, NotAManifold(), zeros(3, 3)) + @test_throws AssertionError @defStateType(MyVar, NotAManifold(), zeros(3, 3)) ## - @defVariable(TestVarType1, Euclidean(3), zeros(3)) - @defVariable( + @defStateType(TestVarType1, Euclidean(3), zeros(3)) + @defStateType( TestVarType2, SpecialEuclideanGroup(3), ArrayPartition(zeros(3), diagm(ones(3))) From 0b0606e8d1140673446267560e7453b7a46bca83 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 10 Sep 2025 19:18:05 +0200 Subject: [PATCH 2/4] Cleanup exports and new `@usingDFG` macro to help with transition --- src/Deprecated.jl | 92 +++--- src/DistributedFactorGraphs.jl | 585 ++++++++++++++++++++------------- src/services/DFGFactor.jl | 24 +- 3 files changed, 390 insertions(+), 311 deletions(-) diff --git a/src/Deprecated.jl b/src/Deprecated.jl index 48d00c89..dcfc5c80 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -1,37 +1,26 @@ ## ================================================================================ ## Deprecated in v0.28 ##================================================================================= -export AbstractRelativeMinimize, - AbstractManifoldMinimize, - AbstractPrior, - AbstractRelative, - InferenceVariable, - InferenceType, - PackedSamplableBelief - -#TODO: maybe just remove these -export NoSolverParams -const AbstractPrior = PriorObservation -const AbstractRelative = RelativeObservation -export AbstractParams -const AbstractParams = AbstractDFGParams - abstract type AbstractRelativeMinimize <: RelativeObservation end abstract type AbstractManifoldMinimize <: RelativeObservation end +const SkeletonDFGVariable = VariableSkeleton +const DFGVariableSummary = VariableSummary +const PackedVariable = VariableDFG +const Variable = VariableDFG +const DFGVariable = VariableCompute +const SkeletonDFGFactor = FactorSkeleton +const DFGFactorSummary = FactorSummary +const DFGFactor = FactorCompute +const PackedFactor = FactorDFG +const Factor = FactorDFG +const SmallDataTypes = MetadataTypes +const AbstractPrior = PriorObservation +const AbstractRelative = RelativeObservation +const AbstractParams = AbstractDFGParams const InferenceVariable = StateType{Any} const InferenceType = AbstractPackedObservation - const PackedSamplableBelief = PackedBelief - -export getVariableState -export addVariableState! -export mergeVariableState! -export deleteVariableState! -export listVariableStates -export VariableState -export VariableStateType -export copytoVariableState! const getVariableState = getState const addVariableState! = addState! const mergeVariableState! = mergeState! @@ -41,7 +30,6 @@ const VariableState = State const VariableStateType = StateType const copytoVariableState! = copytoState! -export setSolverData! # """ # $SIGNATURES # Set solver data structure stored in a variable. @@ -57,7 +45,6 @@ end @deprecate mergeVariableSolverData!(args...; kwargs...) mergeState!(args...; kwargs...) -export mergeVariableData!, mergeGraphVariableData! function mergeVariableData!(args...) return error( "mergeVariableData! is obsolete, use mergeState! for state, PPEs are obsolete", @@ -129,14 +116,11 @@ function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...) return cloneSolveKey!(dfg, dest, dfg, src; kw...) end -export getData, addData!, updateData!, deleteData! - #TODO not a good function, as it's not complete. # """ # $(SIGNATURES) # Convenience function to get all the metadata of a DFG # """ -# export getDFGInfo function getDFGInfo(dfg::AbstractDFG) return ( description = getDescription(dfg), @@ -148,10 +132,6 @@ function getDFGInfo(dfg::AbstractDFG) ) end -export DFGVariable -const DFGVariable = VariableCompute - -export listSolveKeys, listSupersolves # """ # $TYPEDSIGNATURES # List all the solvekeys used amongst all variables in the distributed factor graph object. @@ -207,6 +187,7 @@ function listSolveKeys( return skeys end + const listSupersolves = listSolveKeys #TODO mergeBlobentries! does not fit with merge definition, should probably be updated to copyto or sync. @@ -354,19 +335,31 @@ function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, key::Regex) return getfirstBlobentry(dfg, label; labelFilter = contains(key)) end +macro defVariable(args...) + return esc(:(DFG.@defStateType $(args...))) +end + +@deprecate getFactorFunction(args...) getObservation(args...) +@deprecate getFactorType(args...) getObservation(args...) + +#TODO maybe deprecate setMetadata! +function setMetadata!(v::VariableDFG, metadata::Dict{Symbol, MetadataTypes}) + return error("FIXME: Metadata is not currently mutable in a Variable") + # v.metadata = base64encode(JSON3.write(metadata)) +end + +function setMetadata!(v::VariableCompute, metadata::Dict{Symbol, MetadataTypes}) + v.smallData !== metadata && empty!(v.smallData) + return merge!(v.smallData, metadata) +end + ## ================================================================================ ## Deprecated in v0.27 ##================================================================================= -export AbstractFactor -const AbstractFactor = AbstractObservation -export AbstractPackedFactor +const AbstractFactor = AbstractObservation const AbstractPackedFactor = AbstractPackedObservation - -export FactorOperationalMemory const FactorOperationalMemory = FactorCache - -export VariableNodeData const VariableNodeData = State @deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...) @@ -442,13 +435,11 @@ const VariableNodeData = State @deprecate getSolverData(v::VariableCompute, solveKey::Symbol = :default) getState( v, solveKey, -) +) false @deprecate packVariableNodeData(args...; kwargs...) packState(args...; kwargs...) @deprecate unpackVariableNodeData(args...; kwargs...) unpackState(args...; kwargs...) -export updateVariableSolverData! - #TODO possibly completely deprecated or not exported until update verb is standardized function updateVariableSolverData!( dfg::AbstractDFG, @@ -606,7 +597,7 @@ function FactorCompute( state::FactorState = FactorState(), solvercache::Base.RefValue{<:FactorCache} = Ref{FactorCache}(), id::Union{UUID, Nothing} = nothing, - smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), + smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(), ) error( "This constructor is deprecated, use FactorCompute(label, variableOrder, solverData; ...) instead", @@ -627,8 +618,6 @@ function FactorCompute( ) end -export getSolverData, setSolverData! - function getSolverData(f::FactorCompute) return error( "getSolverData(f::FactorCompute) is obsolete, use getFactorState, getObservation, or getCache instead", @@ -644,14 +633,13 @@ end @deprecate unpackFactor(dfg::AbstractDFG, factor::FactorDFG; skipVersionCheck::Bool = false) unpackFactor( factor; skipVersionCheck, -) +) false @deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorCache!( args...; kwargs..., ) -export reconstFactorData function reconstFactorData end function decodePackedType( @@ -672,7 +660,6 @@ function decodePackedType( return factordata end -export _packSolverData function _packSolverData(f::FactorCompute, fnctype::AbstractObservation) # error("_packSolverData is deprecated, use seperate packing of observation #TODO") @@ -690,8 +677,6 @@ function _packSolverData(f::FactorCompute, fnctype::AbstractObservation) end end -export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData - const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where {T <: AbstractPackedObservation} function PackedFunctionNodeData(args...; kw...) @@ -716,7 +701,7 @@ function FactorCompute( solvable::Int = 1, nstime::Nanosecond = Nanosecond(0), id::Union{UUID, Nothing} = nothing, - smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(), + smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(), ) Base.depwarn( "`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and solvercache should be provided explicitly.", @@ -819,7 +804,6 @@ typeModuleName(varT::Type{<:StateType}) = typeModuleName(varT()) @deprecate getRobotLabel(dfg) getAgentLabel(dfg) @deprecate getSessionLabel(dfg) getGraphLabel(dfg) -export DFGSummary DFGSummary(args) = error("DFGSummary is deprecated") @deprecate getSummary(dfg::AbstractDFG) getSummaryGraph(dfg) diff --git a/src/DistributedFactorGraphs.jl b/src/DistributedFactorGraphs.jl index f51e9c46..e70abbc1 100644 --- a/src/DistributedFactorGraphs.jl +++ b/src/DistributedFactorGraphs.jl @@ -40,7 +40,7 @@ using OrderedCollections: OrderedDict using CSV using Tables -# used for @defVariable +# used for @defStateType import ManifoldsBase using ManifoldsBase: AbstractManifold, manifold_dimension export AbstractManifold, manifold_dimension @@ -54,7 +54,9 @@ using InteractiveUtils: subtypes ##============================================================================== # Exports ##============================================================================== +##------------------------------------------------------------------------------ ## Abstract types and their aliases +##------------------------------------------------------------------------------ export AbstractDFG export AbstractDFGParams, DFGParams export AbstractBlobstore, Blobstore @@ -69,12 +71,22 @@ export AbstractFactorCache, FactorCache export AbstractStateType, StateType export AbstractPackedBelief, PackedBelief -## types +##------------------------------------------------------------------------------ +## Types +##------------------------------------------------------------------------------ +#TODO types are not yet stable - also, we might not export types such as VariableCompute # Variables export VariableCompute, VariableDFG, VariableSummary, VariableSkeleton # Factors export FactorCompute, FactorDFG, FactorSummary, FactorSkeleton +export Blobentry + +export State, PackedState + +##------------------------------------------------------------------------------ +## Functions +##------------------------------------------------------------------------------ # v1 name, signiture, return, and error checked export addVariable!, mergeVariable!, deleteVariable! export addVariables!, getVariables @@ -94,33 +106,88 @@ export listVariables, listFactors, listStates export getGraphBlobentry export getObservation -# v1 name, signiture, and return -# v1 name only -export getVariable, getBlob, addBlob! +## v1 name, signiture, and return -export hasVariable, hasFactor +## v1 name only -# getBlob TODO do we want all of them easy portable vs convenience? -# getBlob(::AbstractBlobstore, ::UUID) -# getBlob(::AbstractBlobstore, ::Blobentry) -# getBlob(::AbstractDFG, ::Blobentry) +##------------------------------------------------------------------------------ +# Variable +##------------------------------------------------------------------------------ +export getVariable +export hasVariable -# TODO get,add,delete|Blob still needs immutability discussion. but errors checked, tests needs updating though. +##------------------------------------------------------------------------------ +## State +##------------------------------------------------------------------------------ +export getStates + +##------------------------------------------------------------------------------ +# Factor +##------------------------------------------------------------------------------ +export mergeFactor! +export hasFactor + +##------------------------------------------------------------------------------ +## Blobentries +##------------------------------------------------------------------------------ +export addBlobentries! +export addGraphBlobentry! +export addGraphBlobentries! +export addAgentBlobentry! +export addAgentBlobentries! + +export getBlobentries +export getGraphBlobentries +export getAgentBlobentry +export getAgentBlobentries + +export mergeBlobentries! +export mergeGraphBlobentry! +export mergeAgentBlobentry! + +export deleteGraphBlobentry! +export deleteAgentBlobentry! + +export listBlobentries +export listGraphBlobentries +export listAgentBlobentries + +export hasBlobentry # TODO not yet implemented in DFG # addAgentBlobentry! # addGraphBlobentry! +##------------------------------------------------------------------------------ +## Blobstores and Blobs +##------------------------------------------------------------------------------ +export getBlobstore +export addBlobstore! +export deleteBlobstore! +export listBlobstores + +# TODO get,add,delete|Blob still needs immutability discussion. but errors checked, tests needs updating though. +export getBlob +# getBlob TODO do we want all of them easy portable vs convenience? +# getBlob(::AbstractBlobstore, ::UUID) +# getBlob(::AbstractBlobstore, ::Blobentry) +# getBlob(::AbstractDFG, ::Blobentry) +export addBlob! +export deleteBlob! +export listBlobs +export hasBlob + +##------------------------------------------------------------------------------ + ## const DFG = DistributedFactorGraphs export DFG -export GraphsDFGs, GraphsDFG - -## -export getFactorState # FIXME getFactorState were questioned and being reviewed again for name, other than that they are checked. +export GraphsDFGs +export GraphsDFG +##============================================================================== ## CRUD Matrix # export addVariable!, getVariable, mergeVariable!, deleteVariable! # export addVariables!, getVariables, mergeVariables!, deleteVariables! @@ -157,220 +224,70 @@ export getFactorState # FIXME getFactorState were questioned and being reviewed # export listVariableBlobentryMetadata, listFactorBlobentryMetadata, listAgentBlobentryMetadata, listGraphBlobentryMetadata ##============================================================================== -## Internal or not yet ready +## Common Accessors ##============================================================================== +export getLabel + +# might only be public +export getId +##============================================================================== +## Internal or not yet ready +##============================================================================== ##------------------------------------------------------------------------------ -## DFG +## Types ##------------------------------------------------------------------------------ - -# accessors & crud -export getDescription, - setDescription!, - getSolverParams, - setSolverParams!, - getAgentMetadata, - setAgentMetadata!, - getGraphMetadata, - setGraphMetadata!, - getAddHistory - -export getGraphBlobentries, - addGraphBlobentry!, - addGraphBlobentries!, - mergeGraphBlobentry!, - deleteGraphBlobentry!, - getAgentBlobentry, - getAgentBlobentries, - addAgentBlobentry!, - addAgentBlobentries!, - mergeAgentBlobentry!, - deleteAgentBlobentry!, - listGraphBlobentries, - listAgentBlobentries - -export getBlobstore, - addBlobstore!, updateBlobstore!, deleteBlobstore!, emptyBlobstore!, listBlobstores - -# TODO Not sure these are needed or should work everywhere, implement in cloud? -# NOTE not exporiting these for now. For consistency `get` and `set` might work better. -# export updateAgentMetadata!, -# updateGraphMetadata!, deleteAgentMetadata!, deleteGraphMetadata! -# export emptyAgentMetadata!, emptyGraphMetadata! - -# Graph Types: exported from modules -export InMemoryDFGTypes, LocalDFG - -# AbstractDFG Interface -export exists, mergeFactor!, isVariable, isFactor - -export isConnected - -export getBiadjacencyMatrix - -export getSummaryGraph - -# Common -export getSolvable, setSolvable!, isSolvable -export getVariableLabelNumber - -# accessors -export getLabel, getTimestamp, setTimestamp, getTags, setTags! - -export getAgentLabel, getGraphLabel - -#TODO these are currently unused, do we deprecate? -export isSolveInProgress, getSolveInProgress - -# CRUD & SET -export listTags, mergeTags!, emptyTags! -export removeTags! #TODO do we want this one +export InMemoryDFGTypes +export LocalDFG +export FolderStore ##------------------------------------------------------------------------------ -# Variable +## Tags ##------------------------------------------------------------------------------ -# accessors -export getSolverDataDict -export getVariableType, getVariableTypeName - -export getVariableType - -# VariableType functions -export getDimension, getManifold, getPointType -export getPointIdentity, getPoint, getCoordinates - -# Small Data CRUD -export SmallDataTypes -export getMetadata, - setMetadata!, - addMetadata!, - updateMetadata!, - deleteMetadata!, - listMetadata, - emptyMetadata! - -# CRUD & SET -export getStates +# tags is a set: get/list, merge, empty, and remove (we don't have add but merge) +export getTags +export listTags +export mergeTags! +export emptyTags! +export removeTags! #TODO do we want this one +export hasTags -# PPE ##------------------------------------------------------------------------------ -# PPE TYPES -export AbstractPointParametricEst -export MeanMaxPPE -export getPPEMax, getPPEMean, getPPESuggested, getLastUpdatedTimestamp - -# accessors - -export getPPEDict, getVariablePPEDict, getVariablePPE - -# CRUD & SET -export getPPE, - getPPEs, getVariablePPE, addPPE!, updatePPE!, deletePPE!, listPPEs, mergePPEs! #TODO look at rename to just mergePPE to match with cloud? - -# Variable Node Data +## Metadata ##------------------------------------------------------------------------------ -export State, PackedState - -export packState, unpackState +# currently these refer to variable metadata +export getMetadata +export addMetadata! +export deleteMetadata! +export listMetadata -export getSolvedCount, - isSolved, setSolvedCount!, isInitialized, isMarginalized, setMarginalized! +export getAgentMetadata +export getGraphMetadata -export listNeighborhood, listNeighbors -export findFactorsBetweenNaive -export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph! - -# Entry Blob Data ##------------------------------------------------------------------------------ - -export hasBlobentry, - getfirstBlobentry, addBlobentries!, listBlobentrySequence, mergeBlobentries! -export incrDataLabelSuffix - -export getBlobentries -export getBlobentriesVariables -# convenience wrappers -# aliases -export packBlob, unpackBlob -export @format_str # exported from FileIO +## FileDFG +##------------------------------------------------------------------------------ +# File import and export +export saveDFG +export loadDFG! +export loadDFG ##------------------------------------------------------------------------------ -# Factors +## Aliases ##------------------------------------------------------------------------------ -# Factor Data - -# accessors -export getVariableOrder -export getFactorType, getFactorFunction - -# Serialization type conversion -export convertPackedType, convertStructType - -export pack, unpack, packDistribution, unpackDistribution +#TODO is ls alias or more of a shorthand with extra functionality? +# if shorthand kind of function it is likeley only DFG +export ls # alias for listVariables +export lsf # alias for listFactors ##------------------------------------------------------------------------------ ## Other utility functions ##------------------------------------------------------------------------------ -# Sort -export natural_lt, sortDFG - -# Validation -# export isValidLabel - -## List -export ls, lsf, ls2 -export isPrior, lsfPriors -export hasTags, hasTagsNeighbors - -## Finding -export findClosestTimestamp, findVariableNearTimestamp - -# Serialization -export packVariable, unpackVariable, packFactor, unpackFactor -export rebuildFactorCache! -export @defVariable - -# File import and export -export saveDFG, loadDFG!, loadDFG - -# export toDot, toDotFile +export listNeighborhood +export listNeighbors -# shortest path -export findShortestPathDijkstra -export isPathFactorsHomogeneous - -# Comparisons -export compare, - compareField, - compareFields, - compareAll, - compareVariable, - compareFactor, - compareAllVariables, - compareSimilarVariables, - compareSimilarFactors, - compareFactorGraphs - -## Deprecated exports should be listed in Deprecated.jl if possible, otherwise here - -## CustomPrinting.jl -export printFactor, printVariable, printNode - -# Data Blobs -export InMemoryBlobstore -export FolderStore -export Blobentry -export updateBlob!, deleteBlob!, hasBlob, listBlobentries -export listBlobs -export Blobentry -# export copyStore -export getId, getHash, getTimestamp -# convenience wrappers - -export plotDFG - -## TODO maybe move to DFG +## TODO maybe move to DFG from SDK # addAgent! # deleteAgent! # listAgents @@ -383,6 +300,203 @@ export plotDFG # addModel! # getGraphs +##============================================================================== + +export getFactorState # FIXME getFactorState were questioned and being reviewed again for name, other than that they are checked. + +##============================================================================== +export @format_str # exported from FileIO + +export @defStateType #TODO Should this be exported? + +# list of unstable functions not exported any more +# will move to public or deprecate over time +const unstable_functions::Vector{Symbol} = [ + :InMemoryBlobstore, + :MetadataTypes, #maybe make public after metadata stable + :exists, + :emptyMetadata!, #TODO maybe deprecate for just deleteMetadata! + :emptyBlobstore!, #TODO maybe deprecate for just deleteBlobstore! + :compare, + :compareField, + :compareFields, + :compareAll, + :compareVariable, + :compareFactor, + :compareAllVariables, + :compareSimilarVariables, + :compareSimilarFactors, + :compareFactorGraphs, + :convertPackedType, + :convertStructType, + :copyGraph!, + :deepcopyGraph, + :deepcopyGraph!, + :findClosestTimestamp, + :findVariableNearTimestamp, + :findShortestPathDijkstra, + :findFactorsBetweenNaive, + :getAgentLabel, + :getGraphLabel, + :getVariableTypeName, + :getVariableType, + :getDescription, + :getAddHistory, + :getSolverParams, + :getHash, + :getTimestamp, + :getSolvable, + :getVariableOrder, + :getSolvedCount, + :getDimension, + :getManifold, + :getPointType, + :getSummaryGraph, + :getBiadjacencyMatrix, + :getPointIdentity, + :getPoint, + :getCoordinates, + :getVariableLabelNumber,# TODO somewhat used, do we deprecate? + :getfirstBlobentry,# TODO somewhat used, do we deprecate? + :getSolveInProgress,#TODO unused, do we deprecate? + :getSolverDataDict,## TODO deprecated or obsolete + :hasTagsNeighbors, + :isVariable, + :isFactor, + :isConnected, + :isPathFactorsHomogeneous, + :isSolvable, + :isSolved, + :isInitialized, + :isMarginalized, + :isPrior, + :isSolveInProgress,#TODO these are currently unused, do we deprecate? + :printFactor, + :printVariable, + :printNode, + :plotDFG, + :pack, + :packDistribution, + :packVariable, + :packFactor, + :packBlob, + :packState, + :unpack, + :unpackDistribution, + :unpackVariable, + :unpackFactor, + :unpackBlob, + :unpackState, + :ls2, + :lsfPriors, + :listBlobentrySequence,# TODO somewhat used, do we deprecate? + :natural_lt, #TODO do we stable functions such as natural_lt or just mark as public + :sortDFG, #TODO do we stable functions such as natural_lt or just mark as public + :mergeGraph!, + :buildSubgraph, + :incrDataLabelSuffix,# TODO somewhat used, do we deprecate? + :updateBlobstore!,## TODO deprecated or obsolete + :updateMetadata!,## TODO deprecated or obsolete + :updateBlob!,## TODO deprecated or obsolete + + # set # TODO what to do here, maybe `ref` verb + setproperty. + :setSolverParams!, + :setDescription!, + :setSolvable!, + :setTimestamp, + :setTags!, + :setSolvedCount!, + :setMarginalized!, + # no set on these + :setMetadata!, # no set, use add merge + :setAgentMetadata!, + :setGraphMetadata!, + + #Deprecated in v0.28 + :AbstractRelativeMinimize, + :AbstractManifoldMinimize, + :AbstractPrior, + :AbstractRelative, + :InferenceVariable, + :InferenceType, + :PackedSamplableBelief, + :getVariableState, + :addVariableState!, + :mergeVariableState!, + :deleteVariableState!, + :listVariableStates, + :VariableState, + :VariableStateType, + :copytoVariableState!, + :setSolverData!, + :getBlobentriesVariables, + :mergeVariableData!, + :mergeGraphVariableData!, + :getData, + :addData!, + :updateData!, + :deleteData!, + :SkeletonDFGVariable, + :DFGVariableSummary, + :PackedVariable, + :Variable, + :DFGVariable, + :SkeletonDFGFactor, + :DFGFactorSummary, + :DFGFactor, + :PackedFactor, + :Factor, + :AbstractPointParametricEst, + :MeanMaxPPE, + :getPPEMax, + :getPPEMean, + :getPPESuggested, + :getLastUpdatedTimestamp, + :getPPEDict, + :getVariablePPEDict, + :getVariablePPE, + :listSolveKeys, + :listSupersolves, + :getPPE, + :getPPEs, + :getVariablePPE, + :addPPE!, + :updatePPE!, + :deletePPE!, + :listPPEs, + :mergePPEs!, + Symbol("@defVariable"), + :SmallDataTypes, + :NoSolverParams, + :AbstractParams, + # Deprecated in v0.27 + :AbstractFactor, + :AbstractPackedFactor, + :FactorOperationalMemory, + :VariableNodeData, + :updateVariableSolverData!, + :getSolverData, + :setSolverData!, + :reconstFactorData, + :_packSolverData, + :GenericFunctionNodeData, + :PackedFunctionNodeData, + :FunctionNodeData, + # Deprecated in v0.25 + :DFGSummary, +] + +macro usingDFG(unstable = false) + pub_names = names(DistributedFactorGraphs) + if unstable + pub_names = union(pub_names, DFG.unstable_functions) + end + syms = [Expr(:., Symbol(n)) for n in pub_names] + return Expr(:using, Expr(:(:), Expr(:(.), :DistributedFactorGraphs), syms...)) +end + +##============================================================================== + ##============================================================================== ## Files Includes ##============================================================================== @@ -413,6 +527,8 @@ include("DataBlobs/services/HelpersDataWrapEntryBlob.jl") # To be moved as necessary. include("Common.jl") +function getSolvable end +function getVariableType end # In Memory Types include("GraphsDFG/GraphsDFG.jl") using .GraphsDFGs @@ -429,40 +545,39 @@ include("services/DFGFactor.jl") include("Deprecated.jl") include("services/CompareUtils.jl") -# Include the FilesDFG API. -include("FileDFG/FileDFG.jl") - -# Custom show and printing for variable factor etc. -include("services/CustomPrinting.jl") - -include("weakdeps_prototypes.jl") +#FIXME move +function mergeGraphBlobentry!(dfg::GraphsDFG, entry::Blobentry) + refBlobentries(dfg.graph)[getLabel(entry)] = entry + return 1 +end -#TODO start off as just an alias before deprecating -# Starting Variable-level nouns-adjective standardisation -export SkeletonDFGVariable -const SkeletonDFGVariable = VariableSkeleton +function mergeAgentBlobentry!(dfg::GraphsDFG, entry::Blobentry) + refBlobentries(dfg.agent)[getLabel(entry)] = entry + return 1 +end -export DFGVariableSummary -const DFGVariableSummary = VariableSummary +function mergeGraphBlobentries!(dfg::GraphsDFG, entries::Vector{Blobentry}) + cnts = map(entries) do entry + return mergeGraphBlobentry!(dfg, entry) + end + return sum(cnts) +end -export PackedVariable -const PackedVariable = VariableDFG -export Variable -const Variable = VariableDFG +function mergeAgentBlobentries!(dfg::GraphsDFG, entries::Vector{Blobentry}) + cnts = map(entries) do entry + return mergeAgentBlobentry!(dfg, entry) + end + return sum(cnts) +end -# Starting Factor-level noun-adjective standardisation -export SkeletonDFGFactor -const SkeletonDFGFactor = FactorSkeleton +# include("services/Sync.jl") -export DFGFactorSummary -const DFGFactorSummary = FactorSummary +# Include the FilesDFG API. +include("FileDFG/FileDFG.jl") -export DFGFactor -const DFGFactor = FactorCompute +# Custom show and printing for variable factor etc. +include("services/CustomPrinting.jl") -export PackedFactor -const PackedFactor = FactorDFG -export Factor -const Factor = FactorDFG +include("weakdeps_prototypes.jl") end diff --git a/src/services/DFGFactor.jl b/src/services/DFGFactor.jl index acb5c87d..8577e9b6 100644 --- a/src/services/DFGFactor.jl +++ b/src/services/DFGFactor.jl @@ -3,34 +3,14 @@ ##============================================================================== function getMetadata(f::FactorDFG) - return JSON3.read(base64decode(f.metadata), Dict{Symbol, SmallDataTypes}) + return JSON3.read(base64decode(f.metadata), Dict{Symbol, MetadataTypes}) end ## COMMON # getSolveInProgress # isSolveInProgress -#TODO getFactorFunction = getFactorType -""" - $SIGNATURES - -Return reference to the user factor in `<:AbstractDFG` identified by `::Symbol`. -""" -getFactorFunction(fc::FactorCompute) = getObservation(fc) -getFactorFunction(dfg::AbstractDFG, fsym::Symbol) = getFactorFunction(getFactor(dfg, fsym)) - -""" - $SIGNATURES - -Return user factor type from factor graph identified by label `::Symbol`. - -Notes -- Replaces older `getfnctype`. -""" -getFactorType(fct::FactorCompute) = getObservation(fct) -getFactorType(f::FactorDFG) = getTypeFromSerializationModule(f.fnctype)() # TODO find a better way to do this that does not rely on empty constructor -getFactorType(dfg::AbstractDFG, lbl::Symbol) = getFactorType(getFactor(dfg, lbl)) - +#TODO `FactorState` is no longer the correct noun, update getFactorState. """ $SIGNATURES From 4e84b0db7b21539beb282057e6ec4ff9895b57ac Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 10 Sep 2025 19:39:31 +0200 Subject: [PATCH 3/4] fix missing using --- src/GraphsDFG/GraphsDFG.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GraphsDFG/GraphsDFG.jl b/src/GraphsDFG/GraphsDFG.jl index 68246524..cb0d1717 100644 --- a/src/GraphsDFG/GraphsDFG.jl +++ b/src/GraphsDFG/GraphsDFG.jl @@ -19,6 +19,8 @@ using ...DistributedFactorGraphs: filterDFG!, getSolvable, getVariableType, + getAgentLabel, + getGraphLabel, MetadataTypes # import DFG functions to extend From 6ed501f8d66d45f538b6d36d27f8da76e72d8a93 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 10 Sep 2025 22:03:37 +0200 Subject: [PATCH 4/4] few missing imports --- src/DistributedFactorGraphs.jl | 1 + src/GraphsDFG/GraphsDFG.jl | 1 + src/GraphsDFG/services/GraphsDFG.jl | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DistributedFactorGraphs.jl b/src/DistributedFactorGraphs.jl index e70abbc1..27d83503 100644 --- a/src/DistributedFactorGraphs.jl +++ b/src/DistributedFactorGraphs.jl @@ -529,6 +529,7 @@ include("Common.jl") function getSolvable end function getVariableType end +function isInitialized end # In Memory Types include("GraphsDFG/GraphsDFG.jl") using .GraphsDFGs diff --git a/src/GraphsDFG/GraphsDFG.jl b/src/GraphsDFG/GraphsDFG.jl index cb0d1717..8e11b40a 100644 --- a/src/GraphsDFG/GraphsDFG.jl +++ b/src/GraphsDFG/GraphsDFG.jl @@ -21,6 +21,7 @@ using ...DistributedFactorGraphs: getVariableType, getAgentLabel, getGraphLabel, + isInitialized, MetadataTypes # import DFG functions to extend diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index 7cce7003..b34d53e4 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -503,7 +503,7 @@ function findShortestPathDijkstra( else varList end - deepcopyGraph(typeof(dfg), dfg, varList, fctList) + DFG.deepcopyGraph(typeof(dfg), dfg, varList, fctList) else # no filter can be used directly dfg