@@ -28,18 +28,23 @@ function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG})
2828 end
2929end
3030
31- # # Utility functions for ZonedDateTime
32-
33- # variableType module.type string functions
34- function typeModuleName (variableType:: InferenceVariable )
35- io = IOBuffer ()
36- ioc = IOContext (io, :module => DistributedFactorGraphs)
37- show (ioc, typeof (variableType))
38- return String (take! (io))
31+ function stringVariableType (varT:: InferenceVariable )
32+ T = typeof (varT)
33+ # FIXME maybe don't use .parameters
34+ Tparams = T. parameters
35+ if length (Tparams) == 0
36+ return string (parentmodule (T), " ." , nameof (T))
37+ elseif length (Tparams) == 1 && Tparams[1 ] isa Integer
38+ return string (parentmodule (T), " ." , nameof (T), " {" , join (Tparams, " ," ), " }" )
39+ else
40+ throw (
41+ SerializationError (
42+ " Serializing Variable State type only supports 1 integer parameter, got '$(T) '." ,
43+ ),
44+ )
45+ end
3946end
4047
41- typeModuleName (varT:: Type{<:InferenceVariable} ) = typeModuleName (varT ())
42-
4348function parseVariableType (_typeString:: AbstractString )
4449 m = match (r" {(\d +)}" , _typeString)
4550 if ! isnothing (m) # parameters in type
@@ -55,7 +60,7 @@ function parseVariableType(_typeString::AbstractString)
5560 subtype = get (all_subtypes, Symbol (split (typeString, " ." )[end ]), nothing )
5661
5762 if isnothing (subtype)
58- error ( " Unable to deserialize type $(_typeString) , not found" )
63+ throw ( SerializationError ( " Unable to deserialize type $(_typeString) , not found" ) )
5964 return nothing
6065 end
6166
@@ -133,7 +138,7 @@ function packVariableState(d::VariableState{T}) where {T <: InferenceVariable}
133138 d. eliminated,
134139 d. BayesNetVertID,
135140 d. separator,
136- typeModuleName (getVariableType (d)),
141+ stringVariableType (getVariableType (d)),
137142 d. initialized,
138143 d. infoPerCoord,
139144 d. ismargin,
@@ -215,7 +220,7 @@ function packVariable(
215220 solverData = packVariableState .(collect (values (v. solverDataDict))),
216221 metadata = base64encode (JSON3. write (v. smallData)),
217222 solvable = v. solvable,
218- variableType = DFG . typeModuleName (DFG. getVariableType (v)),
223+ variableType = stringVariableType (DFG. getVariableType (v)),
219224 blobEntries = collect (values (v. dataDict)),
220225 _version = string (DFG. _getDFGVersion ()),
221226 )
0 commit comments