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
12 changes: 6 additions & 6 deletions src/GraphsDFG/entities/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function GraphsDFG{T, V, F}(
graphTags::Union{Set{Symbol}, Vector{Symbol}} = Set{Symbol}(),
graphBloblets::Bloblets = Bloblets(),
graphBlobentries = Blobentries(),
graph::Graphroot = Graphroot(
graphLabel,
graphDescription,
graphTags,
graphBloblets,
graphBlobentries,
graph::Graphroot = Graphroot(;
label = graphLabel,
description = graphDescription,
tags = graphTags,
bloblets = graphBloblets,
blobentries = graphBlobentries,
),
agents::OrderedDict{Symbol, Agent} = OrderedDict{Symbol, Agent}(),
#TODO deprecated v0.29
Expand Down
16 changes: 13 additions & 3 deletions src/Serialization/PackedSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ See also: [`pack`](@ref), [`Packed`](@ref)
"""
function unpack end

version(::Type{T}) where {T} = pkgversion(parentmodule(T))
# version(node) = node.version
"""
DFG_TYPES_VERSION

DFG types serialization format version, tracked separately from `pkgversion(DistributedFactorGraphs)`.
All independently serialized DFG CRUD nodes (`VariableDFG`, `FactorDFG`, `State`, `Blobentry`,
`Agent`, `Graphroot`) embed this version so that serialized data remains compatible
across minor/patch releases of the DFG package.

Bump this when any serialized DFG type changes its field layout.
"""
const DFG_TYPES_VERSION::VersionNumber = v"0.1"

"""
TypeMetadata(pkg, name, version)
Expand All @@ -91,7 +100,8 @@ struct TypeMetadata
end

function TypeMetadata(::Type{T}) where {T}
return TypeMetadata(fullname(parentmodule(T))[1], nameof(T), version(T))
mod = parentmodule(T)
return TypeMetadata(fullname(mod)[1], nameof(T), pkgversion(mod))
end

"""
Expand Down
4 changes: 4 additions & 0 deletions src/entities/Agent_and_Graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
tags::Set{Symbol} = Set{Symbol}()
bloblets::Bloblets = Bloblets()
blobentries::Blobentries = Blobentries()
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end

@kwdef mutable struct Graphroot
Expand All @@ -13,6 +15,8 @@ end
tags::Set{Symbol} = Set{Symbol}()
bloblets::Bloblets = Bloblets()
blobentries::Blobentries = Blobentries()
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end

#TODO
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Blobentry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ StructUtils.@kwarg struct Blobentry
metadata::JSONText = JSONText("{}")
""" When the Blob itself was first created. Serialized as an ISO 8601 string."""
timestamp::TimeDateZone = now_tdz()
""" Type version of this Blobentry."""
version::VersionNumber = DFG.version(Blobentry)
""" DFG serialization format version."""
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end
version(::Type{Blobentry}) = v"0.1.0"

# construction helper from existing Blobentry for user overriding via kwargs
function Blobentry(entry::Blobentry; kwargs...)
Expand Down
12 changes: 5 additions & 7 deletions src/entities/Factor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,12 @@ StructUtils.@kwarg struct FactorDFG{T <: AbstractObservation, N} <: AbstractGrap
solvercache::Base.RefValue{<:FactorCache} = Ref{FactorCache}() & (ignore = true,)#TODO easy of use vs. performance as container is abstract in any case.
"""Blobentries associated with this factor."""
blobentries::Blobentries = Blobentries() #NOTE v0.29 added
"""Internal: used for automatic type metadata generation."""
_autotype::Nothing = nothing & (name = :type, lower = _ -> TypeMetadata(FactorDFG))
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end

version(::Type{<:FactorDFG}) = v"0.29.0"

##------------------------------------------------------------------------------
## Constructors - IIF like
#------------------------------------------------------------------------------
# Constructors - IIF like
function FactorDFG(
variableorder::Union{<:Tuple, Vector{Symbol}},
observation::AbstractObservation;
Expand Down Expand Up @@ -201,7 +199,7 @@ function FactorDFG(
state,
solvercache,
blobentries,
nothing,
DFG_TYPES_VERSION,
)
end

Expand Down
3 changes: 3 additions & 0 deletions src/entities/State.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $(TYPEDFIELDS)
marginalized::Bool = false #TODO renamed from ismargin v0.29
"""How many times has a solver updated this state estimate."""
solves::Int = 0 # TODO renamed from solvedCount v0.29
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end
# OLD deprecated fields, removed in v0.29, kept here for reference during transition
# val::Vector{P} = Vector{P}()
Expand Down Expand Up @@ -89,6 +91,7 @@ function StructUtils.fielddefaults(
marginalized = false,
solves = 0,
statekind = T(),
version = DFG_TYPES_VERSION,
)
end

Expand Down
18 changes: 8 additions & 10 deletions src/entities/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ $(TYPEDFIELDS)
Accessors: [`getSolvable`](@ref), [`setSolvable!`](@ref)"""
solvable::Base.RefValue{Int} = Ref{Int}(1) #& (lower = getindex,)
statekind::T = T()
# TODO autotype or version and statekind
_autotype::Nothing = nothing #& (name = :type, lower = _ -> TypeMetadata(VariableDFG))
""" DFG types serialization format version."""
version::VersionNumber = DFG.DFG_TYPES_VERSION
end
version(::Type{<:VariableDFG}) = v"0.29"
refStates(v::VariableDFG) = v.states

#NOTE fielddefaults and fieldtags not through @kwarg macro due to error with State{T, P, N}
Expand All @@ -70,16 +69,15 @@ function StructUtils.fielddefaults(
bloblets = Bloblets(),
blobentries = Blobentries(),
solvable = Ref(1),
_autotype = nothing,
version = DFG.DFG_TYPES_VERSION,
)
end

function StructUtils.fieldtags(::StructUtils.StructStyle, ::Type{<:VariableDFG})
return (
_autotype = (name = :type, lower = _ -> TypeMetadata(VariableDFG)),
# solvable = (lower = getindex,),
)
end
# function StructUtils.fieldtags(::StructUtils.StructStyle, ::Type{<:VariableDFG})
# return (
# solvable = (lower = getindex,),
# )
# end

function resolveVariableDFGType(lazyobj)
statekind = liftStateKind(lazyobj.statekind[])
Expand Down
Loading