Skip to content

Commit d13883d

Browse files
committed
Merge branch 'master' into feat/4Q19/showvar
2 parents 8ab0173 + 6f9006e commit d13883d

File tree

25 files changed

+544
-267
lines changed

25 files changed

+544
-267
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CompatHelper
2+
3+
on:
4+
schedule:
5+
- cron: '00 00 * * *'
6+
7+
jobs:
8+
CompatHelper:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
julia-version: [1.2.0]
13+
julia-arch: [x86]
14+
os: [ubuntu-latest]
15+
steps:
16+
- uses: julia-actions/setup-julia@latest
17+
with:
18+
version: ${{ matrix.julia-version }}
19+
- name: Pkg.add("CompatHelper")
20+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
21+
- name: CompatHelper.main()
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ dist: trusty
55
os:
66
- linux
77

8+
arch:
9+
- amd64
10+
- arm64
11+
812
services:
913
- neo4j
1014

1115
julia:
1216
- 1.0
13-
- 1.1
1417
- 1.2
1518
- 1.3
1619
- nightly
@@ -24,7 +27,7 @@ jobs:
2427
env: IIF_TEST=true
2528
if: NOT branch =~ ^release.*$
2629
- stage: "Documentation"
27-
julia: 1.0
30+
julia: 1.2
2831
os: linux
2932
script:
3033
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
@@ -38,6 +41,7 @@ notifications:
3841
matrix:
3942
allow_failures:
4043
- julia: nightly
44+
- arch: arm64
4145
# - env: IIF_TEST=true
4246

4347
# Set the password for Neo4j to neo4j:test

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.5.2"
3+
version = "0.5.4"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/BigData/entities/AbstractBigDataEntries.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Internal function to generate a unique key for the entry - userId_robotId_sessio
1717
Simple symbol.
1818
"""
1919
function _uniqueKey(dfg::G, v::V, key::Symbol)::Symbol where {G <: AbstractDFG, V <: AbstractDFGVariable}
20-
key = join(String.([dfg.userId, dfg.robotId, dfg.sessionId, label(v), String(key)]), "_")
20+
key = join(String.([dfg.userId, dfg.robotId, dfg.sessionId, getLabel(v), String(key)]), "_")
2121
return Symbol(key)
2222
end
2323

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ function mergeUpdateVariableSolverData!(dfg::CloudGraphsDFG, sourceVariable::DFG
256256
error("Source variable '$(sourceVariable.label)' doesn't exist in the graph.")
257257
end
258258
var = getVariable(dfg, sourceVariable.label)
259-
newEsts = merge!(var.estimateDict, deepcopy(sourceVariable.estimateDict))
259+
newEsts = merge!(var.ppeDict, deepcopy(sourceVariable.ppeDict))
260260
newSolveData = merge!(var.solverDataDict, sourceVariable.solverDataDict)
261-
Neo4j.setnodeproperty(dfg.neo4jInstance.graph, var._internalId, "estimateDict",
261+
Neo4j.setnodeproperty(dfg.neo4jInstance.graph, var._internalId, "ppeDict",
262262
JSON2.write(newEsts))
263263
Neo4j.setnodeproperty(dfg.neo4jInstance.graph, var._internalId, "solverDataDict",
264264
JSON2.write(Dict(keys(newSolveData) .=> map(vnd -> pack(dfg, vnd), values(newSolveData)))))

src/CommonAccessors.jl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@ Return the label for a variable or factor.
2020
"""
2121
getLabel(v::DataLevel0) = v.label
2222

23-
"""
24-
$SIGNATURES
25-
26-
Return the label for a variable or factor.
27-
28-
DEPRECATED label -> getLabel
29-
"""
30-
function label(v::DataLevel0)
31-
@warn "Deprecated label, use getLabel instead."
32-
getLabel(v)
33-
end
34-
3523

3624
"""
3725
$SIGNATURES
@@ -41,18 +29,6 @@ Return the tags for a variable.
4129
getTags(v::DataLevel0) = v.tags
4230

4331

44-
"""
45-
$SIGNATURES
46-
47-
Return the tags for a variable.
48-
49-
DEPRECATED, tags -> getTags
50-
"""
51-
function tags(v::DataLevel0)
52-
@warn "tags deprecated, use getTags instead"
53-
getTags(v)
54-
end
55-
5632
"""
5733
$SIGNATURES
5834

src/DFGPlots/DFGPlots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ More information at [GraphPlot.jl](https://github.com/JuliaGraphs/GraphPlot.jl)
8888
function dfgplot(dfg::AbstractDFG, p::DFGPlotProps = DFGPlotProps())
8989
# TODO implement convert functions
9090
@warn "TODO Implement convert"
91-
ldfg = LightDFG{AbstractParams}()
91+
ldfg = LightDFG{NoSolverParams}()
9292
DistributedFactorGraphs._copyIntoGraph!(dfg, ldfg, union(getVariableIds(dfg), getFactorIds(dfg)), true, copyGraphMetadata=false)
9393

9494
dfgplot(ldfg, p)

src/Deprecated.jl

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# deprecation staging area
2+
3+
## quick deprecation handle
4+
import Base: propertynames, getproperty
5+
6+
Base.propertynames(x::VariableDataLevel1, private::Bool=false) = private ? (:estimateDict, :ppeDict) : (:ppeDict,)
7+
8+
Base.getproperty(x::VariableDataLevel1,f::Symbol) = begin
9+
if f == :estimateDict
10+
@warn "estimateDict is deprecated, use ppeDict instead"
11+
getfield(x, :ppeDict)
12+
else
13+
getfield(x,f)
14+
end
15+
end
16+
17+
18+
19+
"""
20+
$SIGNATURES
21+
22+
Return the estimates for a variable.
23+
"""
24+
function getEstimates(v::VariableDataLevel1)
25+
@warn "Deprecated getEstimates, use getVariablePPE/getPPE instead."
26+
getVariablePPEs(vari)
27+
end
28+
29+
"""
30+
$SIGNATURES
31+
32+
Return the estimates for a variable.
33+
34+
DEPRECATED, estimates -> getVariablePPEs/getPPEs
35+
"""
36+
function estimates(v::VariableDataLevel1)
37+
@warn "Deprecated estimates, use getVariablePPEs/getPPE instead."
38+
getVariablePPEs(v)
39+
end
40+
41+
"""
42+
$SIGNATURES
43+
44+
Return a keyed estimate (default is :default) for a variable.
45+
46+
DEPRECATED use getVariablePPE/getPPE instead.
47+
"""
48+
function getEstimate(v::VariableDataLevel1, key::Symbol=:default)
49+
@warn "Deprecated getEstimate, use getVariablePPE/getPPE instead."
50+
getVariablePPE(v, key)
51+
end
52+
53+
"""
54+
$SIGNATURES
55+
56+
Return a keyed estimate (default is :default) for a variable.
57+
"""
58+
function estimate(v::VariableDataLevel1, key::Symbol=:default)
59+
@warn "DEPRECATED estimate, use getVariablePPE/getPPE instead."
60+
getVariablePPE(v, key)
61+
end
62+
63+
64+
"""
65+
$SIGNATURES
66+
67+
Return the softtype for a variable.
68+
69+
DEPRECATED, softtype -> getSofttype
70+
"""
71+
function softtype(v::VariableDataLevel1)
72+
@warn "Deprecated softtype, use getSofttype instead."
73+
getSofttype(v)
74+
end
75+
76+
77+
"""
78+
$SIGNATURES
79+
80+
Return the label for a variable or factor.
81+
82+
DEPRECATED label -> getLabel
83+
"""
84+
function label(v::DataLevel0)
85+
@warn "Deprecated label, use getLabel instead."
86+
getLabel(v)
87+
end
88+
89+
90+
"""
91+
$SIGNATURES
92+
93+
Return the tags for a variable.
94+
95+
DEPRECATED, tags -> getTags
96+
"""
97+
function tags(v::DataLevel0)
98+
@warn "tags deprecated, use getTags instead"
99+
getTags(v)
100+
end
101+
102+
103+
"""
104+
$SIGNATURES
105+
106+
Retrieve data structure stored in a variable.
107+
"""
108+
function getData(v::DFGVariable; solveKey::Symbol=:default)::VariableNodeData
109+
@warn "getData is deprecated, please use solverData()"
110+
return v.solverDataDict[solveKey]
111+
end
112+
113+
114+
"""
115+
$SIGNATURES
116+
117+
Set solver data structure stored in a variable.
118+
"""
119+
function setSolverData(v::DFGVariable, data::VariableNodeData, key::Symbol=:default)
120+
@warn "Deprecated setSolverData, use setSolverData! instead."
121+
setSolverData!(v, data, key)
122+
end
123+
124+
125+
"""
126+
$SIGNATURES
127+
128+
Retrieve solver data structure stored in a factor.
129+
"""
130+
function data(f::DFGFactor)::GenericFunctionNodeData
131+
@warn "data() is deprecated, please use solverData()"
132+
return f.data
133+
end

src/DistributedFactorGraphs.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export AbstractParams, NoSolverParams
2121
export DFGNode, DFGVariable, DFGFactor, AbstractDFGVariable, AbstractDFGFactor
2222
export InferenceType, PackedInferenceType, FunctorInferenceType, InferenceVariable, ConvolutionObject
2323
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
24-
export getMaxPPE, getMeanPPE, getSuggestedPPE
24+
export getMaxPPE, getMeanPPE, getSuggestedPPE, getVariablePPE, getPPE, getVariablePPEs, getPPEs #, getEstimates
2525
export timestamp # DEPRECATED
26+
export getSolvedCount, isSolved, setSolvedCount!
2627
export label, getTimestamp, setTimestamp!, tags, setTags!, estimates, estimate, data, softtype, solverData, getData, solverDataDict, setSolverData, setSolverData!, internalId, smallData, setSmallData!, bigData
2728
export DFGVariableSummary, DFGFactorSummary, AbstractDFGSummary
2829
export addBigDataEntry!, getBigDataEntry, updateBigDataEntry!, deleteBigDataEntry!, getBigDataEntries, getBigDataKeys
30+
export getNeighborhood, getSubgraph, getSubgraphAroundNode
2931
export printFactor, printVariable
3032

3133
#Skeleton types
@@ -81,6 +83,7 @@ include("services/AbstractDFG.jl")
8183
include("services/DFGVariable.jl")
8284
include("services/DFGFactor.jl")
8385
include("CommonAccessors.jl")
86+
include("Deprecated.jl")
8487
include("services/CompareUtils.jl")
8588

8689
# Include the Graphs.jl API.

src/FileDFG/services/FileDFG.jl

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE], solvable=0)
1414
saveDFG(dfg, "/tmp/saveDFG")
1515
```
1616
"""
17-
function saveDFG(dfg::G, folder::String) where G <: AbstractDFG
17+
function saveDFG(dfg::AbstractDFG, folder::String; compress::Symbol=:gzip)
1818
variables = getVariables(dfg)
1919
factors = getFactors(dfg)
2020
varFolder = "$folder/variables"
@@ -43,6 +43,16 @@ function saveDFG(dfg::G, folder::String) where G <: AbstractDFG
4343
JSON2.write(io, fPacked)
4444
close(io)
4545
end
46+
47+
# compress newly saved folder, skip if not supported format
48+
!(compress in [:gzip]) && return
49+
savepath = folder[end] == '/' ? folder[1:end-1] : folder
50+
savedir = dirname(savepath)
51+
savename = splitpath(string(savepath))[end]
52+
@assert savename != ""
53+
# temporarily change working directory to get correct zipped path
54+
run( pipeline(`tar -zcf - -C $savedir $savename`, stdout="$savepath.tar.gz") )
55+
Base.rm(joinpath(savedir,savename), recursive=true)
4656
end
4757

4858
"""
@@ -56,20 +66,48 @@ using DistributedFactorGraphs, IncrementalInference
5666
# Create a DFG - can make one directly, e.g. GraphsDFG{NoSolverParams}() or use IIF:
5767
dfg = initfg()
5868
# Load the graph
59-
loadDFG("/tmp/savedgraph", IncrementalInference, dfg)
69+
loadDFG("/tmp/savedgraph.tar.gz", IncrementalInference, dfg)
70+
loadDFG("/tmp/savedgraph", IncrementalInference, dfg) # alternative
6071
# Use the DFG as you do normally.
6172
ls(dfg)
6273
```
6374
"""
64-
function loadDFG(folder::String, iifModule, dfgLoadInto::G) where G <: AbstractDFG
75+
function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","tmp","caesar","random")) where G <: AbstractDFG
76+
# Check if zipped destination (dst) by first doing fuzzy search from user supplied dst
77+
folder = dst # working directory for fileDFG variable and factor operations
78+
dstname = dst # path name could either be legacy FileDFG dir or .tar.gz file of FileDFG files.
79+
unzip = false
80+
# add if doesn't have .tar.gz extension
81+
lastdirname = splitpath(dstname)[end]
82+
if !isdir(dst)
83+
unzip = true
84+
sdst = split(lastdirname, '.')
85+
if sdst[end] != "gz" # length(sdst) == 1 &&
86+
dstname *= ".tar.gz"
87+
lastdirname *= ".tar.gz"
88+
end
89+
end
90+
# TODO -- what if it is not a tar.gz but classic folder instead?
91+
# do actual unzipping
92+
filename = lastdirname[1:(end-length(".tar.gz"))] |> string
93+
if unzip
94+
@show sfolder = split(dstname, '.')
95+
Base.mkpath(loaddir)
96+
folder = joinpath(loaddir, filename) #splitpath(string(sfolder[end-2]))[end]
97+
@info "loadDFG detected a gzip $dstname -- unpacking via $loaddir now..."
98+
Base.rm(folder, recursive=true, force=true)
99+
# unzip the tar file
100+
run(`tar -zxf $dstname -C $loaddir`)
101+
end
102+
# extract the factor graph from fileDFG folder
65103
variables = DFGVariable[]
66104
factors = DFGFactor[]
67105
varFolder = "$folder/variables"
68106
factorFolder = "$folder/factors"
69107
# Folder preparations
70108
!isdir(folder) && error("Can't load DFG graph - folder '$folder' doesn't exist")
71-
!isdir(varFolder) && error("Can't load DFG graph - folder '$folder' doesn't exist")
72-
!isdir(factorFolder) && error("Can't load DFG graph - folder '$folder' doesn't exist")
109+
!isdir(varFolder) && error("Can't load DFG graph - folder '$varFolder' doesn't exist")
110+
!isdir(factorFolder) && error("Can't load DFG graph - folder '$factorFolder' doesn't exist")
73111

74112
varFiles = readdir(varFolder)
75113
factorFiles = readdir(factorFolder)
@@ -104,5 +142,12 @@ function loadDFG(folder::String, iifModule, dfgLoadInto::G) where G <: AbstractD
104142
# TODO: Remove in future
105143
map(f->solverData(f).fncargvID = f._variableOrderSymbols, getFactors(dfgLoadInto))
106144

145+
# remove the temporary unzipped file
146+
if unzip
147+
@info "DFG.loadDFG is deleting a temp folder created during unzip, $folder"
148+
# need this because the number of files created in /tmp/caesar/random is becoming redonkulous.
149+
Base.rm(folder, recursive=true)
150+
end
151+
107152
return dfgLoadInto
108153
end

0 commit comments

Comments
 (0)