Skip to content

Commit 9b33394

Browse files
committed
updatePPE! standard and bugfix
1 parent a37d004 commit 9b33394

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,11 @@ function addPPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbo
520520
if ppekey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
521521
error("PPE '$(ppekey)' already exists")
522522
end
523-
return updatePPE!(dfg, variablekey, ppe, ppekey, currentTransaction=currentTransaction)
523+
return _matchmergePPE!(dfg, variablekey, ppe, ppekey, currentTransaction=currentTransaction)
524524
end
525525

526-
function updatePPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::P where P <: AbstractPointParametricEst
526+
#TODO clean this, just to match api for update
527+
function _matchmergePPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::P where P <: AbstractPointParametricEst
527528
packed = packPPE(dfg, ppe)
528529
query = """
529530
MATCH (var:$variablekey:$(join(_getLabelsForType(dfg, DFGVariable, parentKey=variablekey),':')))
@@ -546,10 +547,17 @@ function updatePPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Sy
546547
return unpackPPE(dfg, result.results[1]["data"][1]["row"][1])
547548
end
548549

550+
function updatePPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::P where P <: AbstractPointParametricEst
551+
if !(ppekey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction))
552+
@warn "PPE '$(ppekey)' does not exist, adding"
553+
end
554+
return _matchmergePPE!(dfg, variablekey, ppe, ppekey, currentTransaction=currentTransaction)
555+
end
556+
549557
function updatePPE!(dfg::CloudGraphsDFG, sourceVariables::Vector{<:DFGVariable}, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
550558
tx = currentTransaction == nothing ? transaction(dfg.neo4jInstance.connection) : currentTransaction
551559
for var in sourceVariables
552-
updatePPE!(dfg, var.label, getPPE(dfg, var, ppekey), ppekey, currentTransaction=tx)
560+
updatePPE!(dfg, var.label, getPPE(var, ppekey), ppekey, currentTransaction=tx)
553561
end
554562
if currentTransaction == nothing
555563
result = commit(tx)

test/consolInterfaceDev.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ end
100100
tagsTestBlock!(fg1, var1, v1_tags)
101101
end
102102

103-
# @testset "Parametric Point Estimates" begin
104-
# PPETestBlock!(fg1, var1)
105-
# end
103+
@testset "Parametric Point Estimates" begin
104+
PPETestBlock!(fg1, var1)
105+
end
106106

107107
@testset "Variable Solver Data" begin
108108
VSDTestBlock!(fg1, var1)

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ end
4343
if get(ENV, "IIF_TEST", "") != "true"
4444
@testset "Consolidation WIP Testing Driver: CloudGraphsDFG" begin
4545
global decodePackedType
46-
function decodePackedType(dfg::G, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where {PT, G <: AbstractDFG}
46+
function decodePackedType(dfg::AbstractDFG, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where PT
4747
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
4848
# Also look at parentmodule
4949
usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
5050
fulltype = DFG.FunctionNodeData{TestCCW{usrtyp}}
51-
factor = convert(fulltype, packeddata)
52-
return factor
51+
factordata = convert(fulltype, packeddata)
52+
return factordata
5353
end
5454
@info "Testing Driver: CloudGraphsDFG"
5555
global testDFGAPI = CloudGraphsDFG

test/testBlocks.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ function PPETestBlock!(fg, v1)
527527
@test @test_logs (:warn, r"does not exist") updatePPE!(fg, :a, ppe, :default) == ppe
528528
# Update update it
529529
@test updatePPE!(fg, :a, ppe, :default) == ppe
530-
# Bulk copy PPE's for x0 and x1
530+
@test deletePPE!(fg, :a, :default) == ppe
531+
532+
# manually add ppe to v1 for tests
533+
v1.ppeDict[:default] = deepcopy(ppe)
534+
# Bulk copy PPE's for :x1
531535
@test updatePPE!(fg, [v1], :default) == nothing
532536
# Delete it
533537
@test deletePPE!(fg, :a, :default) == ppe
@@ -551,6 +555,8 @@ function PPETestBlock!(fg, v1)
551555
updatePPE!(fg, :a, ppe, :default)
552556
# Update update it
553557
updatePPE!(fg, :a, ppe, :default)
558+
559+
v1.ppeDict[:default] = deepcopy(ppe)
554560
# Bulk copy PPE's for x0 and x1
555561
updatePPE!(fg, [v1], :default)
556562
# Delete it

0 commit comments

Comments
 (0)