@@ -166,53 +166,34 @@ function loadDFG!(
166
166
varFiles = sort (readdir (varFolder; sort = false ); lt = natural_lt)
167
167
factorFiles = sort (readdir (factorFolder; sort = false ); lt = natural_lt)
168
168
169
+ packedvars = @showprogress 1 " loading variables" map (varFiles) do varFile
170
+ jstr = read (" $varFolder /$varFile " , String)
171
+ return JSON3. read (jstr, PackedVariable)
172
+ end
173
+ # FIXME , why is this treated different from VariableSkeleton, VariableSummary?
174
+ # FIXME , still creates type instability on `variables` as either `::Variable` or `::DFGVariable`
169
175
if isa (dfgLoadInto, GraphsDFG) && GraphsDFGs. _variablestype (dfgLoadInto) == Variable
170
- variables = @showprogress 1 " loading variables" map (varFiles) do varFile
171
- jstr = read (" $varFolder /$varFile " , String)
172
- return JSON3. read (jstr, PackedVariable)
173
- end
176
+ variables = packedvars
174
177
else
175
- variables = DFGVariable[]
176
- @showprogress 1 " loading variables" for varFile in varFiles
177
- jstr = read (" $varFolder /$varFile " , String)
178
- try
179
- packedData = JSON3. read (jstr, PackedVariable)
180
- push! (variables, unpackVariable (packedData))
181
- catch ex
182
- @error (
183
- " JSON3 is having trouble reading $varFolder /$varFile into a PackedVariable"
184
- )
185
- @show jstr
186
- throw (ex)
187
- end
188
- end
178
+ variables = unpackVariable .(packedvars)
189
179
end
190
180
191
181
@info " Loaded $(length (variables)) variables" # - $(map(v->v.label, variables))"
192
182
@info " Inserting variables into graph..."
193
183
# Adding variables
194
184
map (v -> addVariable! (dfgLoadInto, v), variables)
195
185
186
+ packedfacts = @showprogress 1 " loading factors" map (factorFiles) do factorFile
187
+ jstr = read (" $factorFolder /$factorFile " , String)
188
+ return JSON3. read (jstr, PackedFactor)
189
+ end
190
+ # FIXME , still creates type instability on `variables` as either `::Factor` or `::DFGFactor{<:}`
196
191
if isa (dfgLoadInto, GraphsDFG) && GraphsDFGs. _factorstype (dfgLoadInto) == PackedFactor
197
- factors = @showprogress 1 " loading factors" map (factorFiles) do factorFile
198
- jstr = read (" $factorFolder /$factorFile " , String)
199
- return JSON3. read (jstr, PackedFactor)
200
- end
192
+ factors = packedfacts
201
193
else
202
- @showprogress 1 " loading factors" for factorFile in factorFiles
203
- jstr = read (" $factorFolder /$factorFile " , String)
204
- try
205
- packedData = JSON3. read (jstr, PackedFactor)
206
- push! (factors, unpackFactor (dfgLoadInto, packedData))
207
- catch ex
208
- @error (
209
- " JSON3 is having trouble reading $factorFolder /$factorFile into a PackedFactor"
210
- )
211
- @show jstr
212
- throw (ex)
213
- end
214
- end
194
+ factors = unpackFactor .(dfgLoadInto, packedfacts)
215
195
end
196
+
216
197
@info " Loaded $(length (factors)) factors" # - $(map(f->f.label, factors))"
217
198
@info " Inserting factors into graph..."
218
199
# # Adding factors
0 commit comments