Skip to content

Commit b899df6

Browse files
committed
Merge branch 'master' into feat/20Q3/in_mem_store
2 parents f2bebb3 + 60ba70f commit b899df6

File tree

12 files changed

+135
-220
lines changed

12 files changed

+135
-220
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ function getVariable(dfg::CloudGraphsDFG, label::Union{Symbol, String})
236236
for ppe in listPPEs(dfg, label)
237237
variable.ppeDict[ppe] = getPPE(dfg, label, ppe)
238238
end
239-
for solverKey in listVariableSolverData(dfg, label)
240-
variable.solverDataDict[solverKey] = getVariableSolverData(dfg, label, solverKey)
239+
for solveKey in listVariableSolverData(dfg, label)
240+
variable.solverDataDict[solveKey] = getVariableSolverData(dfg, label, solveKey)
241241
end
242242
dataDict = getDataEntries(dfg, label)
243243
for (k,v) in dataDict
@@ -543,7 +543,7 @@ function _unpackPPE(dfg::G, packedPPE::Dict{String, Any})::AbstractPointParametr
543543
end
544544

545545
function listPPEs(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
546-
return _listVarSubnodesForType(dfg, variablekey, MeanMaxPPE, "solverKey"; currentTransaction=currentTransaction)
546+
return _listVarSubnodesForType(dfg, variablekey, MeanMaxPPE, "solveKey"; currentTransaction=currentTransaction)
547547
end
548548

549549
function getPPE(dfg::CloudGraphsDFG, variablekey::Symbol, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::AbstractPointParametricEst
@@ -578,8 +578,8 @@ function addPPE!(dfg::CloudGraphsDFG,
578578
ppe::P;
579579
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::AbstractPointParametricEst where
580580
{P <: AbstractPointParametricEst}
581-
if ppe.solverKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
582-
error("PPE '$(ppe.solverKey)' already exists")
581+
if ppe.solveKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
582+
error("PPE '$(ppe.solveKey)' already exists")
583583
end
584584
softType = getSofttype(dfg, variablekey)
585585
# Add additional properties for the PPE
@@ -600,8 +600,8 @@ function updatePPE!(
600600
ppe::P;
601601
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::P where
602602
{P <: AbstractPointParametricEst}
603-
if !(ppe.solverKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction))
604-
@warn "PPE '$(ppe.solverKey)' does not exist, adding"
603+
if !(ppe.solveKey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction))
604+
@warn "PPE '$(ppe.solveKey)' does not exist, adding"
605605
end
606606
softType = getSofttype(dfg, variablekey, currentTransaction=currentTransaction)
607607
# Add additional properties for the PPE
@@ -727,20 +727,20 @@ function _unpackVariableNodeData(dfg::G, packedDict::Dict{String, Any})::Variabl
727727
end
728728

729729
function listVariableSolverData(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
730-
return _listVarSubnodesForType(dfg, variablekey, VariableNodeData, "solverKey"; currentTransaction=currentTransaction)
730+
return _listVarSubnodesForType(dfg, variablekey, VariableNodeData, "solveKey"; currentTransaction=currentTransaction)
731731
end
732732

733-
function getVariableSolverData(dfg::CloudGraphsDFG, variablekey::Symbol, solverKey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
734-
properties = _getVarSubnodeProperties(dfg, variablekey, VariableNodeData, solverKey; currentTransaction=currentTransaction)
733+
function getVariableSolverData(dfg::CloudGraphsDFG, variablekey::Symbol, solveKey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
734+
properties = _getVarSubnodeProperties(dfg, variablekey, VariableNodeData, solveKey; currentTransaction=currentTransaction)
735735
return _unpackVariableNodeData(dfg, properties)
736736
end
737737

738738
function addVariableSolverData!(dfg::CloudGraphsDFG,
739739
variablekey::Symbol,
740740
vnd::VariableNodeData;
741741
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
742-
if vnd.solverKey in listVariableSolverData(dfg, variablekey, currentTransaction=currentTransaction)
743-
error("Solver data '$(vnd.solverKey)' already exists")
742+
if vnd.solveKey in listVariableSolverData(dfg, variablekey, currentTransaction=currentTransaction)
743+
error("Solver data '$(vnd.solveKey)' already exists")
744744
end
745745
retPacked = _matchmergeVariableSubnode!(
746746
dfg,
@@ -758,8 +758,8 @@ function updateVariableSolverData!(dfg::CloudGraphsDFG,
758758
useCopy::Bool=true,
759759
fields::Vector{Symbol}=Symbol[];
760760
currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
761-
if !(vnd.solverKey in listVariableSolverData(dfg, variablekey, currentTransaction=currentTransaction))
762-
@warn "Solver data '$(vnd.solverKey)' does not exist, adding rather than updating."
761+
if !(vnd.solveKey in listVariableSolverData(dfg, variablekey, currentTransaction=currentTransaction))
762+
@warn "Solver data '$(vnd.solveKey)' does not exist, adding rather than updating."
763763
end
764764
# TODO: Update this to use the selective parameters from fields.
765765
retPacked = _matchmergeVariableSubnode!(
@@ -772,13 +772,13 @@ function updateVariableSolverData!(dfg::CloudGraphsDFG,
772772
return _unpackVariableNodeData(dfg, retPacked)
773773
end
774774

775-
function deleteVariableSolverData!(dfg::CloudGraphsDFG, variablekey::Symbol, solverKey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
775+
function deleteVariableSolverData!(dfg::CloudGraphsDFG, variablekey::Symbol, solveKey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::VariableNodeData
776776
retPacked = _deleteVarSubnode!(
777777
dfg,
778778
variablekey,
779779
:SOLVERDATA,
780780
_getLabelsForType(dfg, VariableNodeData, parentKey=variablekey),
781-
solverKey,
781+
solveKey,
782782
currentTransaction=currentTransaction)
783783
return _unpackVariableNodeData(dfg, retPacked)
784784
end
@@ -839,12 +839,12 @@ function updateVariableSolverData!(dfg::CloudGraphsDFG,
839839
end
840840

841841
function mergeVariableSolverData!(dfg::CloudGraphsDFG, sourceVariable::DFGVariable)
842-
for solverKey in listVariableSolverData(dfg, sourceVariable.label)
842+
for solveKey in listVariableSolverData(dfg, sourceVariable.label)
843843
updateVariableSolverData!(
844844
dfg,
845845
sourceVariable.label,
846-
getVariableSolverData(dfg, sourceVariable, solverKey),
847-
solverKey)
846+
getVariableSolverData(dfg, sourceVariable, solveKey),
847+
solveKey)
848848
end
849849
end
850850

src/CloudGraphsDFG/services/CommonFunctions.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ function _getLabelsForInst(dfg::CloudGraphsDFG,
249249
labels = _getLabelsForType(dfg, typeof(inst), parentKey=parentKey)
250250
typeof(inst) <: DFGVariable && push!(labels, String(getLabel(inst)))
251251
typeof(inst) <: DFGFactor && push!(labels, String(getLabel(inst)))
252-
typeof(inst) <: AbstractPointParametricEst && push!(labels, String(inst.solverKey))
253-
typeof(inst) <: VariableNodeData && push!(labels, String(inst.solverKey))
252+
typeof(inst) <: AbstractPointParametricEst && push!(labels, String(inst.solveKey))
253+
typeof(inst) <: VariableNodeData && push!(labels, String(inst.solveKey))
254254
typeof(inst) <: AbstractDataEntry && push!(labels, String(inst.label))
255255
return labels
256256
end
@@ -316,8 +316,8 @@ function _matchmergeVariableSubnode!(
316316
result = commit(tx)
317317
end
318318
length(result.errors) > 0 && error(string(result.errors))
319-
length(result.results[1]["data"]) != 1 && error("Cannot find subnode '$(ppe.solverKey)' for variable '$variablekey'")
320-
length(result.results[1]["data"][1]["row"]) != 1 && error("Cannot find subnode '$(ppe.solverKey)' for variable '$variablekey'")
319+
length(result.results[1]["data"]) != 1 && error("Cannot find subnode '$(ppe.solveKey)' for variable '$variablekey'")
320+
length(result.results[1]["data"][1]["row"]) != 1 && error("Cannot find subnode '$(ppe.solveKey)' for variable '$variablekey'")
321321
return result.results[1]["data"][1]["row"][1]
322322
end
323323

src/Deprecated.jl

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,10 @@
22
# deprecation staging area
33
##==============================================================================
44

5-
6-
##==============================================================================
7-
## Remove in 0.10
8-
##==============================================================================
9-
10-
# temporary promote with warning
11-
Base.promote_rule(::Type{DateTime}, ::Type{ZonedDateTime}) = DateTime
12-
function Base.convert(::Type{DateTime}, ts::ZonedDateTime)
13-
@warn "DFG now uses ZonedDateTime, temporary promoting and converting to DateTime local time"
14-
return DateTime(ts, Local)
15-
end
16-
17-
export listSolvekeys
18-
19-
@deprecate listSolvekeys(x...) listSolveKeys(x...)
20-
21-
export InferenceType
22-
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
23-
24-
abstract type InferenceType end
25-
26-
# These will become AbstractPrior, AbstractRelativeFactor, and AbstractRelativeFactorMinimize in 0.9.
27-
abstract type FunctorSingleton <: FunctorInferenceType end
28-
abstract type FunctorPairwise <: FunctorInferenceType end
29-
abstract type FunctorPairwiseMinimize <: FunctorInferenceType end
30-
31-
# I don't know how to deprecate this, any suggestions?
32-
const AbstractBigDataEntry = AbstractDataEntry
33-
34-
@deprecate GeneralBigDataEntry(args...; kwargs...) GeneralDataEntry(args...; kwargs...)
35-
@deprecate MongodbBigDataEntry(args...) MongodbDataEntry(args...)
36-
@deprecate FileBigDataEntry(args...) FileDataEntry(args...)
37-
38-
# TODO entities/DFGVariable.jl DFGVariableSummary.bigData getproperty and setproperty!
39-
# TODO entities/DFGVariable.jl DFGVariable.bigData getproperty and setproperty!
40-
@deprecate getBigData(args...) getDataBlob(args...)
41-
@deprecate addBigData!(args...) addDataBlob!(args...)
42-
@deprecate updateBigData!(args...) updateDataBlob!(args...)
43-
@deprecate deleteBigData!(args...) deleteDataBlob!(args...)
44-
@deprecate listStoreEntries(args...) listDataBlobs(args...)
45-
@deprecate hasBigDataEntry(args...) hasDataEntry(args...)
46-
47-
48-
@deprecate getBigDataEntry(args...) getDataEntry(args...)
49-
@deprecate addBigDataEntry!(args...) addDataEntry!(args...)
50-
@deprecate updateBigDataEntry!(args...) updateDataEntry!(args...)
51-
@deprecate deleteBigDataEntry!(args...) deleteDataEntry!(args...)
52-
@deprecate getBigDataKeys(args...) listDataEntries(args...)
53-
@deprecate getBigDataEntries(args...) getDataEntries(args...)
54-
@deprecate getDataEntryElement(args...) getDataEntryBlob(args...)
55-
56-
575
##==============================================================================
586
## Remove in 0.11
597
##==============================================================================
60-
@deprecate addVariableSolverData!(dfg::AbstractDFG, variablekey::Symbol, vnd::VariableNodeData, solverKey::Symbol) addVariableSolverData!(dfg, variablekey, vnd)
8+
@deprecate addVariableSolverData!(dfg::AbstractDFG, variablekey::Symbol, vnd::VariableNodeData, solveKey::Symbol) addVariableSolverData!(dfg, variablekey, vnd)
619

6210
@deprecate updatePPE!(dfg::AbstractDFG, variablekey::Symbol, ppe::AbstractPointParametricEst, ppekey::Symbol) updatePPE!(dfg, variablekey, ppe)
6311

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ export findClosestTimestamp, findVariableNearTimestamp
223223
# Serialization
224224
export packVariable, unpackVariable, packFactor, unpackFactor
225225
export rebuildFactorMetadata!
226+
export @defVariable
226227

227228
# File import and export
228-
export saveDFG, loadDFG!
229+
export saveDFG, loadDFG!, loadDFG
229230
export toDot, toDotFile
230231

231232
# Comparisons

src/FileDFG/services/FileDFG.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE], solvable=0)
1717
saveDFG(dfg, "/tmp/saveDFG.tar.gz")
1818
```
1919
"""
20-
function saveDFG( dfg::AbstractDFG, folder::AbstractString )
20+
function saveDFG(folder::AbstractString, dfg::AbstractDFG)
2121

22-
# TODO: Deprecate the folder functionality in v0.6.1
22+
# TODO: Deprecate the folder functionality
2323

2424
# Clean up save path if a file is specified
2525
savepath = folder[end] == '/' ? folder[1:end-1] : folder
@@ -65,6 +65,8 @@ function saveDFG( dfg::AbstractDFG, folder::AbstractString )
6565
end
6666
Base.rm(joinpath(savedir,savename), recursive=true)
6767
end
68+
# support both argument orders, #581
69+
saveDFG(dfg::AbstractDFG, folder::AbstractString) = saveDFG(folder, dfg)
6870

6971
"""
7072
$(SIGNATURES)
@@ -77,17 +79,16 @@ using DistributedFactorGraphs, IncrementalInference
7779
# Create a DFG - can make one directly, e.g. LightDFG{NoSolverParams}() or use IIF:
7880
dfg = initfg()
7981
# Load the graph
80-
loadDFG("/tmp/savedgraph.tar.gz", IncrementalInference, dfg)
82+
loadDFG!(dfg, "/tmp/savedgraph.tar.gz")
8183
# Use the DFG as you do normally.
8284
ls(dfg)
8385
```
8486
"""
8587
function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
8688

87-
8889
#
8990
# loaddir gets deleted so needs to be unique
90-
loaddir=joinpath("/","tmp","caesar","random", string(uuid1()))
91+
loaddir=split(joinpath("/","tmp","caesar","random", string(uuid1())), '-')[1]
9192
# Check if zipped destination (dst) by first doing fuzzy search from user supplied dst
9293
folder = dst # working directory for fileDFG variable and factor operations
9394
dstname = dst # path name could either be legacy FileDFG dir or .tar.gz file of FileDFG files.
@@ -111,7 +112,7 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
111112
@show sfolder = split(dstname, '.')
112113
Base.mkpath(loaddir)
113114
folder = joinpath(loaddir, filename) #splitpath(string(sfolder[end-2]))[end]
114-
@info "loadDFG detected a gzip $dstname -- unpacking via $loaddir now..."
115+
@info "loadDFG! detected a gzip $dstname -- unpacking via $loaddir now..."
115116
Base.rm(folder, recursive=true, force=true)
116117
# unzip the tar file
117118
run(`tar -zxf $dstname -C $loaddir`)
@@ -158,10 +159,13 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
158159

159160
# remove the temporary unzipped file
160161
if unzip
161-
@info "DFG.loadDFG is deleting a temp folder created during unzip, $loaddir"
162+
@info "DFG.loadDFG! is deleting a temp folder created during unzip, $loaddir"
162163
# need this because the number of files created in /tmp/caesar/random is becoming redonkulous.
163164
Base.rm(loaddir, recursive=true, force=true)
164165
end
165166

166167
return dfgLoadInto
167168
end
169+
170+
# to be extended by users with particular choices in dispatch.
171+
function loadDFG end

src/entities/DFGFactor.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ end
185185
Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
186186
if f == :solvable || f == :solverData
187187
getfield(x,f)[] = val
188-
elseif f == :timestamp && val isa DateTime
189-
# #TODO Deprecation - Remove in v0.10
190-
Base.depwarn("DFGFactor timestamp field is now a ZonedTimestamp", :setproperty!)
191-
setfield!(x,:timestamp, ZonedDateTime(val, localzone()))
192188
else
193189
setfield!(x,f,val)
194190
end

0 commit comments

Comments
 (0)