Skip to content

Commit ce268d4

Browse files
authored
Cleanup unstable exports and @usingDFG macro for transition + rename SmallDataTypes -> MetadataTypes (#1170)
* Rename SmallDataTypes -> MetadataTypes and update to @defStateType * Cleanup exports and new `@usingDFG` macro to help with transition
1 parent f31d014 commit ce268d4

21 files changed

+444
-367
lines changed

NEWS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Listing news on any major breaking changes in DFG. For regular changes, see int
33
- Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session
44
- Deprecated AbstractRelativeMinimize and AbstractManifoldsMinimize
55
- Rename `VariableState` -> `State`
6+
- @defVariable -> @defStateType
7+
- 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`.
8+
- Rename SmallDataTypes -> MetadataTypes
69

710
Abstract Types Standardized, see #1153:
811
- AbstractParams -> [Abstract]DFGParams
@@ -18,8 +21,8 @@ Abstract Types Standardized, see #1153:
1821

1922
# v0.27
2023
- `delete` returns number of nodes deleted and no longer the object that was deleted.
21-
- Deprecate `updateVariable!` for `mergeVariable!`, note `merege` returns number of nodes updated/added.
22-
- Deprecate `updateFactor!` for `mergeFactor!`, note `merege` returns number of nodes updated/added.
24+
- Deprecate `updateVariable!` for `mergeVariable!`, note `merge` returns number of nodes updated/added.
25+
- Deprecate `updateFactor!` for `mergeFactor!`, note `merge` returns number of nodes updated/added.
2326
- Rename BlobEntry to Blobentry, see #1123.
2427
- Rename BlobStore to Blobstore, see #1124.
2528
- Refactor the Factor solver data structure, see #1127:

src/Deprecated.jl

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
11
## ================================================================================
22
## Deprecated in v0.28
33
##=================================================================================
4-
export AbstractRelativeMinimize,
5-
AbstractManifoldMinimize,
6-
AbstractPrior,
7-
AbstractRelative,
8-
InferenceVariable,
9-
InferenceType,
10-
PackedSamplableBelief
11-
12-
#TODO: maybe just remove these
13-
export NoSolverParams
14-
const AbstractPrior = PriorObservation
15-
const AbstractRelative = RelativeObservation
16-
export AbstractParams
17-
const AbstractParams = AbstractDFGParams
18-
194
abstract type AbstractRelativeMinimize <: RelativeObservation end
205
abstract type AbstractManifoldMinimize <: RelativeObservation end
216

7+
const SkeletonDFGVariable = VariableSkeleton
8+
const DFGVariableSummary = VariableSummary
9+
const PackedVariable = VariableDFG
10+
const Variable = VariableDFG
11+
const DFGVariable = VariableCompute
12+
const SkeletonDFGFactor = FactorSkeleton
13+
const DFGFactorSummary = FactorSummary
14+
const DFGFactor = FactorCompute
15+
const PackedFactor = FactorDFG
16+
const Factor = FactorDFG
17+
const SmallDataTypes = MetadataTypes
18+
const AbstractPrior = PriorObservation
19+
const AbstractRelative = RelativeObservation
20+
const AbstractParams = AbstractDFGParams
2221
const InferenceVariable = StateType{Any}
2322
const InferenceType = AbstractPackedObservation
24-
2523
const PackedSamplableBelief = PackedBelief
26-
27-
export getVariableState
28-
export addVariableState!
29-
export mergeVariableState!
30-
export deleteVariableState!
31-
export listVariableStates
32-
export VariableState
33-
export VariableStateType
34-
export copytoVariableState!
3524
const getVariableState = getState
3625
const addVariableState! = addState!
3726
const mergeVariableState! = mergeState!
@@ -41,7 +30,6 @@ const VariableState = State
4130
const VariableStateType = StateType
4231
const copytoVariableState! = copytoState!
4332

44-
export setSolverData!
4533
# """
4634
# $SIGNATURES
4735
# Set solver data structure stored in a variable.
@@ -57,7 +45,6 @@ end
5745

5846
@deprecate mergeVariableSolverData!(args...; kwargs...) mergeState!(args...; kwargs...)
5947

60-
export mergeVariableData!, mergeGraphVariableData!
6148
function mergeVariableData!(args...)
6249
return error(
6350
"mergeVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
@@ -129,14 +116,11 @@ function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...)
129116
return cloneSolveKey!(dfg, dest, dfg, src; kw...)
130117
end
131118

132-
export getData, addData!, updateData!, deleteData!
133-
134119
#TODO not a good function, as it's not complete.
135120
# """
136121
# $(SIGNATURES)
137122
# Convenience function to get all the metadata of a DFG
138123
# """
139-
# export getDFGInfo
140124
function getDFGInfo(dfg::AbstractDFG)
141125
return (
142126
description = getDescription(dfg),
@@ -148,10 +132,6 @@ function getDFGInfo(dfg::AbstractDFG)
148132
)
149133
end
150134

151-
export DFGVariable
152-
const DFGVariable = VariableCompute
153-
154-
export listSolveKeys, listSupersolves
155135
# """
156136
# $TYPEDSIGNATURES
157137
# List all the solvekeys used amongst all variables in the distributed factor graph object.
@@ -207,6 +187,7 @@ function listSolveKeys(
207187

208188
return skeys
209189
end
190+
210191
const listSupersolves = listSolveKeys
211192

212193
#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)
354335
return getfirstBlobentry(dfg, label; labelFilter = contains(key))
355336
end
356337

338+
macro defVariable(args...)
339+
return esc(:(DFG.@defStateType $(args...)))
340+
end
341+
342+
@deprecate getFactorFunction(args...) getObservation(args...)
343+
@deprecate getFactorType(args...) getObservation(args...)
344+
345+
#TODO maybe deprecate setMetadata!
346+
function setMetadata!(v::VariableDFG, metadata::Dict{Symbol, MetadataTypes})
347+
return error("FIXME: Metadata is not currently mutable in a Variable")
348+
# v.metadata = base64encode(JSON3.write(metadata))
349+
end
350+
351+
function setMetadata!(v::VariableCompute, metadata::Dict{Symbol, MetadataTypes})
352+
v.smallData !== metadata && empty!(v.smallData)
353+
return merge!(v.smallData, metadata)
354+
end
355+
357356
## ================================================================================
358357
## Deprecated in v0.27
359358
##=================================================================================
360-
export AbstractFactor
361-
const AbstractFactor = AbstractObservation
362359

363-
export AbstractPackedFactor
360+
const AbstractFactor = AbstractObservation
364361
const AbstractPackedFactor = AbstractPackedObservation
365-
366-
export FactorOperationalMemory
367362
const FactorOperationalMemory = FactorCache
368-
369-
export VariableNodeData
370363
const VariableNodeData = State
371364

372365
@deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...)
@@ -442,13 +435,11 @@ const VariableNodeData = State
442435
@deprecate getSolverData(v::VariableCompute, solveKey::Symbol = :default) getState(
443436
v,
444437
solveKey,
445-
)
438+
) false
446439

447440
@deprecate packVariableNodeData(args...; kwargs...) packState(args...; kwargs...)
448441
@deprecate unpackVariableNodeData(args...; kwargs...) unpackState(args...; kwargs...)
449442

450-
export updateVariableSolverData!
451-
452443
#TODO possibly completely deprecated or not exported until update verb is standardized
453444
function updateVariableSolverData!(
454445
dfg::AbstractDFG,
@@ -606,7 +597,7 @@ function FactorCompute(
606597
state::FactorState = FactorState(),
607598
solvercache::Base.RefValue{<:FactorCache} = Ref{FactorCache}(),
608599
id::Union{UUID, Nothing} = nothing,
609-
smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
600+
smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(),
610601
)
611602
error(
612603
"This constructor is deprecated, use FactorCompute(label, variableOrder, solverData; ...) instead",
@@ -627,8 +618,6 @@ function FactorCompute(
627618
)
628619
end
629620

630-
export getSolverData, setSolverData!
631-
632621
function getSolverData(f::FactorCompute)
633622
return error(
634623
"getSolverData(f::FactorCompute) is obsolete, use getFactorState, getObservation, or getCache instead",
@@ -644,14 +633,13 @@ end
644633
@deprecate unpackFactor(dfg::AbstractDFG, factor::FactorDFG; skipVersionCheck::Bool = false) unpackFactor(
645634
factor;
646635
skipVersionCheck,
647-
)
636+
) false
648637

649638
@deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorCache!(
650639
args...;
651640
kwargs...,
652641
)
653642

654-
export reconstFactorData
655643
function reconstFactorData end
656644

657645
function decodePackedType(
@@ -672,7 +660,6 @@ function decodePackedType(
672660
return factordata
673661
end
674662

675-
export _packSolverData
676663
function _packSolverData(f::FactorCompute, fnctype::AbstractObservation)
677664
#
678665
error("_packSolverData is deprecated, use seperate packing of observation #TODO")
@@ -690,8 +677,6 @@ function _packSolverData(f::FactorCompute, fnctype::AbstractObservation)
690677
end
691678
end
692679

693-
export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData
694-
695680
const PackedFunctionNodeData{T} =
696681
GenericFunctionNodeData{T} where {T <: AbstractPackedObservation}
697682
function PackedFunctionNodeData(args...; kw...)
@@ -716,7 +701,7 @@ function FactorCompute(
716701
solvable::Int = 1,
717702
nstime::Nanosecond = Nanosecond(0),
718703
id::Union{UUID, Nothing} = nothing,
719-
smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
704+
smallData::Dict{Symbol, MetadataTypes} = Dict{Symbol, MetadataTypes}(),
720705
)
721706
Base.depwarn(
722707
"`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and solvercache should be provided explicitly.",
@@ -819,7 +804,6 @@ typeModuleName(varT::Type{<:StateType}) = typeModuleName(varT())
819804
@deprecate getRobotLabel(dfg) getAgentLabel(dfg)
820805
@deprecate getSessionLabel(dfg) getGraphLabel(dfg)
821806

822-
export DFGSummary
823807
DFGSummary(args) = error("DFGSummary is deprecated")
824808
@deprecate getSummary(dfg::AbstractDFG) getSummaryGraph(dfg)
825809

0 commit comments

Comments
 (0)