-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More metadata for FileDFG and restore as saved #1038
Conversation
function getBlobEntryFirst(var::Variable, key::Regex) | ||
firstIdx = findfirst(x->contains(string(x.label), key), var.blobEntries) | ||
if isnothing(firstIdx) | ||
throw(KeyError("$key")) | ||
end | ||
return var.blobEntries[firstIdx] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function getBlobEntryFirst(var::Variable, key::Regex) | |
firstIdx = findfirst(x->contains(string(x.label), key), var.blobEntries) | |
if isnothing(firstIdx) | |
throw(KeyError("$key")) | |
end | |
return var.blobEntries[firstIdx] | |
function getBlobEntryFirst(var::Variable, key::Regex) | |
firstIdx = findfirst(x -> contains(string(x.label), key), var.blobEntries) | |
if isnothing(firstIdx) | |
throw(KeyError("$key")) | |
end | |
return var.blobEntries[firstIdx] |
end | ||
return var.blobEntries[firstIdx] | ||
end | ||
|
||
getBlobEntry(var::AbstractDFGVariable, key::AbstractString) = getBlobEntry(var,Regex(key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
getBlobEntry(var::AbstractDFGVariable, key::AbstractString) = getBlobEntry(var,Regex(key)) | |
getBlobEntry(var::AbstractDFGVariable, key::AbstractString) = getBlobEntry(var, Regex(key)) |
varFiles = sort(readdir(varFolder; sort=false); lt=natural_lt) | ||
factorFiles = sort(readdir(factorFolder; sort=false); lt=natural_lt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
varFiles = sort(readdir(varFolder; sort=false); lt=natural_lt) | |
factorFiles = sort(readdir(factorFolder; sort=false); lt=natural_lt) | |
varFiles = sort(readdir(varFolder; sort = false); lt = natural_lt) | |
factorFiles = sort(readdir(factorFolder; sort = false); lt = natural_lt) |
if isa(dfgLoadInto, GraphsDFG) && GraphsDFGs._variablestype(dfgLoadInto) == Variable | ||
variables = @showprogress 1 "loading variables" map(varFiles) do varFile | ||
jstr = read("$varFolder/$varFile", String) | ||
return JSON3.read(jstr, PackedVariable) | ||
end | ||
else | ||
variables = DFGVariable[] | ||
@showprogress 1 "loading variables" for varFile in varFiles | ||
jstr = read("$varFolder/$varFile", String) | ||
try | ||
packedData = JSON3.read(jstr, PackedVariable) | ||
push!(variables, unpackVariable(packedData)) | ||
catch ex | ||
@error("JSON3 is having trouble reading $varFolder/$varFile into a PackedVariable") | ||
@show jstr | ||
throw(ex) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
if isa(dfgLoadInto, GraphsDFG) && GraphsDFGs._variablestype(dfgLoadInto) == Variable | |
variables = @showprogress 1 "loading variables" map(varFiles) do varFile | |
jstr = read("$varFolder/$varFile", String) | |
return JSON3.read(jstr, PackedVariable) | |
end | |
else | |
variables = DFGVariable[] | |
@showprogress 1 "loading variables" for varFile in varFiles | |
jstr = read("$varFolder/$varFile", String) | |
try | |
packedData = JSON3.read(jstr, PackedVariable) | |
push!(variables, unpackVariable(packedData)) | |
catch ex | |
@error("JSON3 is having trouble reading $varFolder/$varFile into a PackedVariable") | |
@show jstr | |
throw(ex) | |
end | |
end | |
if isa(dfgLoadInto, GraphsDFG) && GraphsDFGs._variablestype(dfgLoadInto) == Variable | |
variables = @showprogress 1 "loading variables" map(varFiles) do varFile | |
jstr = read("$varFolder/$varFile", String) | |
return JSON3.read(jstr, PackedVariable) | |
end | |
else | |
variables = DFGVariable[] | |
@showprogress 1 "loading variables" for varFile in varFiles | |
jstr = read("$varFolder/$varFile", String) | |
try | |
packedData = JSON3.read(jstr, PackedVariable) | |
push!(variables, unpackVariable(packedData)) | |
catch ex | |
@error("JSON3 is having trouble reading $varFolder/$varFile into a PackedVariable") | |
@show jstr | |
throw(ex) | |
end |
end | ||
end | ||
@info "Loaded $(length(variables)) variables - $(map(v->v.label, variables))" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) | ||
|
||
#FIXME Deprecate remove in DFG v0.24 | ||
setdiff!(commonfields, [:blobStores]) | ||
blobStores = Dict{Symbol, AbstractBlobStore}() | ||
!isnothing(packed.blobStores) && merge!(blobStores, packed.blobStores) | ||
|
||
props = (k => getproperty(packed, k) for k in commonfields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) | |
#FIXME Deprecate remove in DFG v0.24 | |
setdiff!(commonfields, [:blobStores]) | |
blobStores = Dict{Symbol, AbstractBlobStore}() | |
!isnothing(packed.blobStores) && merge!(blobStores, packed.blobStores) | |
props = (k => getproperty(packed, k) for k in commonfields) | |
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) | |
#FIXME Deprecate remove in DFG v0.24 | |
setdiff!(commonfields, [:blobStores]) | |
blobStores = Dict{Symbol, AbstractBlobStore}() | |
!isnothing(packed.blobStores) && merge!(blobStores, packed.blobStores) |
VT = isnothing(packed.typePackedVariable) || !packed.typePackedVariable ? DFGVariable : Variable | ||
FT = isnothing(packed.typePackedFactor) || !packed.typePackedFactor ? DFGFactor : PackedFactor | ||
# VT = isnothing(packed.typePackedVariable) || packed.typePackedVariable ? Variable : DFGVariable | ||
# FT = isnothing(packed.typePackedFactor) || packed.typePackedFactor ? PackedFactor : DFGFactor | ||
GraphsDFG{typeof(packed.solverParams), VT, FT}(;blobStores, props...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
VT = isnothing(packed.typePackedVariable) || !packed.typePackedVariable ? DFGVariable : Variable | |
FT = isnothing(packed.typePackedFactor) || !packed.typePackedFactor ? DFGFactor : PackedFactor | |
# VT = isnothing(packed.typePackedVariable) || packed.typePackedVariable ? Variable : DFGVariable | |
# FT = isnothing(packed.typePackedFactor) || packed.typePackedFactor ? PackedFactor : DFGFactor | |
GraphsDFG{typeof(packed.solverParams), VT, FT}(;blobStores, props...) | |
props = (k => getproperty(packed, k) for k in commonfields) | |
VT = if isnothing(packed.typePackedVariable) || !packed.typePackedVariable | |
DFGVariable | |
else | |
Variable | |
end | |
FT = if isnothing(packed.typePackedFactor) || !packed.typePackedFactor | |
DFGFactor | |
else | |
PackedFactor | |
end | |
# VT = isnothing(packed.typePackedVariable) || packed.typePackedVariable ? Variable : DFGVariable | |
# FT = isnothing(packed.typePackedFactor) || packed.typePackedFactor ? PackedFactor : DFGFactor | |
return GraphsDFG{typeof(packed.solverParams), VT, FT}(; blobStores, props...) |
FT = isnothing(packed.typePackedFactor) || !packed.typePackedFactor ? DFGFactor : PackedFactor | ||
# VT = isnothing(packed.typePackedVariable) || packed.typePackedVariable ? Variable : DFGVariable | ||
# FT = isnothing(packed.typePackedFactor) || packed.typePackedFactor ? PackedFactor : DFGFactor | ||
GraphsDFG{typeof(packed.solverParams), VT, FT}(;blobStores, props...) | ||
end | ||
|
||
function unpackDFGMetadata!(dfg::GraphsDFG, packed::PackedGraphsDFG) | ||
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) | |
commonfields = intersect(fieldnames(GraphsDFG), fieldnames(PackedGraphsDFG)) |
#FIXME Deprecate remove Nothing union in DFG v0.24 | ||
setdiff!(commonfields, [:blobStores]) | ||
!isnothing(packed.blobStores) && merge!(dfg.blobStores, packed.blobStores) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
#FIXME Deprecate remove Nothing union in DFG v0.24 | |
setdiff!(commonfields, [:blobStores]) | |
!isnothing(packed.blobStores) && merge!(dfg.blobStores, packed.blobStores) | |
#FIXME Deprecate remove Nothing union in DFG v0.24 | |
setdiff!(commonfields, [:blobStores]) | |
!isnothing(packed.blobStores) && merge!(dfg.blobStores, packed.blobStores) |
function packVariable(v::Variable; includePPEs::Bool=true, includeSolveData::Bool=true, includeDataEntries::Bool=true) | ||
return v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function packVariable(v::Variable; includePPEs::Bool=true, includeSolveData::Bool=true, includeDataEntries::Bool=true) | |
return v | |
function packVariable( | |
v::Variable; | |
includePPEs::Bool = true, | |
includeSolveData::Bool = true, | |
includeDataEntries::Bool = true, | |
) | |
return v |
Codecov Report
@@ Coverage Diff @@
## master #1038 +/- ##
==========================================
- Coverage 78.09% 77.94% -0.15%
==========================================
Files 26 26
Lines 2524 2181 -343
==========================================
- Hits 1971 1700 -271
+ Misses 553 481 -72
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
No description provided.