Skip to content

Commit 73d9ece

Browse files
committed
Changes needed for NvaSDK v0.6
1 parent a78b6d9 commit 73d9ece

File tree

5 files changed

+67
-21
lines changed

5 files changed

+67
-21
lines changed

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ General Data Store Entry.
2626
_version::String = string(_getDFGVersion()) # TBD consider upgrading to ::VersionNumber
2727
end
2828

29+
30+
function Base.propertynames(x::BlobEntry, private::Bool=false)
31+
if private
32+
return fieldnames(BlobEntry)
33+
else
34+
return (:blobId, :originId, :label, :blobstore, :hash, :origin, :description,
35+
:mimeType, :metadata, :timestamp, :_type, :_version)
36+
end
37+
end
38+
2939
StructTypes.StructType(::Type{BlobEntry}) = StructTypes.UnorderedStruct()
3040
StructTypes.idproperty(::Type{BlobEntry}) = :id
3141
StructTypes.omitempties(::Type{BlobEntry}) = (:id,)

src/DataBlobs/services/BlobEntry.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function assertHash(de::BlobEntry, db; hashfunction::Function = sha256)
4646
end
4747

4848

49-
function Base.show(io::IO, entry::BlobEntry)
49+
function Base.show(io::IO, ::MIME"text/plain", entry::BlobEntry)
5050
println(io, "_type=BlobEntry {")
5151
println(io, " id: ", entry.id)
5252
println(io, " blobId: ", entry.blobId)
@@ -62,10 +62,6 @@ function Base.show(io::IO, entry::BlobEntry)
6262
println(io, "}")
6363
end
6464

65-
Base.show(io::IO, ::MIME"text/plain", entry::BlobEntry) = show(io, entry)
66-
67-
68-
6965
##==============================================================================
7066
## BlobEntry - CRUD
7167
##==============================================================================

src/entities/DFGFactor.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Base.@kwdef mutable struct GenericFunctionNodeData{T<:Union{<:AbstractPackedFact
4848
inflation::Float64 = 0.0
4949
end
5050

51+
# TODO should we move non FactorOperationalMemory to DFGFactor:
52+
# fnc, multihypo, nullhypo, inflation ?
53+
# that way we split solverData <: FactorOperationalMemory and constants
54+
# TODO see if above ever changes?
55+
56+
5157
## Constructors
5258

5359

@@ -78,8 +84,7 @@ FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw
7884

7985
# Packed Factor
8086
Base.@kwdef struct PackedFactor
81-
# NOTE: This has to match the order of the JSON deserializer as we're using OrderedStructs.
82-
id::Union{UUID, Nothing}
87+
id::Union{UUID, Nothing} = nothing
8388
label::Symbol
8489
tags::Vector{Symbol}
8590
_variableOrderSymbols::Vector{Symbol}
@@ -89,7 +94,7 @@ Base.@kwdef struct PackedFactor
8994
solvable::Int
9095
data::String
9196
metadata::String
92-
_version::String
97+
_version::String = string(_getDFGVersion())
9398
end
9499

95100
StructTypes.StructType(::Type{PackedFactor}) = StructTypes.UnorderedStruct()

src/entities/DFGVariable.jl

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ VariableNodeData(variableType::InferenceVariable; kwargs...) = VariableNodeData{
9191

9292
"""
9393
$(TYPEDEF)
94-
Packed VariabeNodeData structure for serializing DFGVariables.
94+
Packed VariableNodeData structure for serializing DFGVariables.
9595
9696
---
9797
Fields:
@@ -120,6 +120,17 @@ Base.@kwdef mutable struct PackedVariableNodeData
120120
_version::String = string(_getDFGVersion())
121121
end
122122

123+
function Base.propertynames(x::PackedVariableNodeData, private::Bool=false)
124+
if private
125+
return fieldnames(PackedVariableNodeData)
126+
else
127+
return (:vecval, :dimval, :vecbw, :dimbw, :BayesNetOutVertIDs,
128+
:dimIDs, :dims, :eliminated, :BayesNetVertID, :separator,
129+
:variableType, :initialized, :infoPerCoord, :ismargin, :dontmargin,
130+
:solveInProgress, :solvedCount, :solveKey, :_version)
131+
end
132+
end
133+
123134
StructTypes.StructType(::Type{PackedVariableNodeData}) = StructTypes.UnorderedStruct()
124135
StructTypes.idproperty(::Type{PackedVariableNodeData}) = :id
125136
StructTypes.omitempties(::Type{PackedVariableNodeData}) = (:id,)
@@ -155,6 +166,10 @@ Base.@kwdef struct MeanMaxPPE <: AbstractPointParametricEst
155166
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
156167
end
157168

169+
function Base.propertynames(x::MeanMaxPPE, private::Bool = false)
170+
return (:solveKey, :suggested, :max, :mean, :_type, :_version)
171+
end
172+
158173
StructTypes.StructType(::Type{MeanMaxPPE}) = StructTypes.UnorderedStruct()
159174
StructTypes.idproperty(::Type{MeanMaxPPE}) = :id
160175
StructTypes.omitempties(::Type{MeanMaxPPE}) = (:id,:createdTimestamp,:lastUpdatedTimestamp)
@@ -179,19 +194,18 @@ getEstimateFields(::MeanMaxPPE) = [:suggested, :max, :mean]
179194

180195
# Packed Variable
181196
Base.@kwdef struct PackedVariable
182-
# NOTE: This has to match the order of the JSON deserializer as we're using OrderedStructs.
183-
id::Union{UUID, Nothing}
197+
id::Union{UUID, Nothing} = nothing
184198
label::Symbol
185-
tags::Vector{Symbol}
186-
timestamp::ZonedDateTime
187-
nstime::Int
188-
ppes::Vector{MeanMaxPPE}
189-
blobEntries::Vector{BlobEntry}
199+
tags::Vector{Symbol} = Symbol[]
200+
timestamp::ZonedDateTime = now(tz"UTC")
201+
nstime::Int = 0
202+
ppes::Vector{MeanMaxPPE} = MeanMaxPPE[]
203+
blobEntries::Vector{BlobEntry} = BlobEntry[]
190204
variableType::String
191-
_version::String
192-
metadata::String
193-
solvable::Int
194-
solverData::Vector{PackedVariableNodeData}
205+
_version::String = string(_getDFGVersion())
206+
metadata::String = "e30="
207+
solvable::Int = 1
208+
solverData::Vector{PackedVariableNodeData} = PackedVariableNodeData[]
195209
end
196210

197211
StructTypes.StructType(::Type{PackedVariable}) = StructTypes.UnorderedStruct()
@@ -344,6 +358,27 @@ Base.@kwdef struct DFGVariableSummary <: AbstractDFGVariable
344358
dataDict::Dict{Symbol, BlobEntry}
345359
end
346360

361+
function DFGVariableSummary(
362+
id,
363+
label,
364+
timestamp,
365+
tags,
366+
::Nothing,
367+
variableTypeName,
368+
::Nothing,
369+
)
370+
return DFGVariableSummary(
371+
id,
372+
label,
373+
timestamp,
374+
tags,
375+
Dict{Symbol, MeanMaxPPE}(),
376+
variableTypeName,
377+
Dict{Symbol, BlobEntry}(),
378+
)
379+
end
380+
381+
StructTypes.names(::Type{DFGVariableSummary}) = ((:variableTypeName, :variableType),)
347382

348383
##------------------------------------------------------------------------------
349384
## SkeletonDFGVariable.jl

test/testBlocks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ function VSDTestBlock!(fg, v1)
702702
# - `updateVariableSolverData!`
703703
# - `deleteVariableSolverData!`
704704
#
705-
# > - `getVariableSolverDataAll` #TODO Data is already plural so maybe Variables, All or Dict
705+
# > - `getVariableSolverDataAll` #TODO Data is already plural so maybe Variables, All or Dict, or use Datum for singular
706706
# > - `getVariablesSolverData`
707707
#
708708
# **Set like**

0 commit comments

Comments
 (0)