Skip to content

Commit 030cc49

Browse files
authored
fix parseVariableType performance and skip module fallback for IIF/RoMETypes (#1151)
1 parent 7708ecd commit 030cc49

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/services/Serialization.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,21 @@ function parseVariableType(_typeString::AbstractString)
5555
typeString = _typeString
5656
end
5757

58-
all_subtypes = Dict(map(s -> nameof(s) => s, subtypes(InferenceVariable)))
58+
split_typeSyms = Symbol.(split(typeString, "."))
5959

60-
subtype = get(all_subtypes, Symbol(split(typeString, ".")[end]), nothing)
60+
subtype = nothing
61+
62+
if length(split_typeSyms) == 1
63+
@warn "Module not found in variable '$typeString'." maxlog = 1
64+
subtype = getfield(Main, split_typeSyms[1]) # no module specified, use Main
65+
#FIXME interm fallback for backwards compatibility in IIFTypes and RoMETypes
66+
elseif split_typeSyms[1] in Symbol.(values(Base.loaded_modules))
67+
m = getfield(Main, split_typeSyms[1])
68+
subtype = getfield(m, split_typeSyms[end])
69+
else
70+
@warn "Module not found in Main, using Main for type '$typeString'." maxlog = 1
71+
subtype = getfield(Main, split_typeSyms[end])
72+
end
6173

6274
if isnothing(subtype)
6375
throw(SerializationError("Unable to deserialize type $(_typeString), not found"))

test/runtests.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,22 @@ end
6363
if get(ENV, "IIF_TEST", "true") == "true"
6464

6565
# Switch to our upstream test branch.
66+
#FIXME This is a temporary fix to use the develop branch of IIF.
67+
# Pkg.add(PackageSpec(; name = "IncrementalInference", rev = "upstream/dfg_integration_test"))
68+
# Pkg.add(PackageSpec(; name = "IncrementalInference", rev = "develop"))
6669
Pkg.add(
67-
#FIXME This is a temporary fix to use the refactored factor branch.
68-
# PackageSpec(; name = "IncrementalInference", rev = "upstream/dfg_integration_test"),
69-
PackageSpec(; name = "IncrementalInference", rev = "develop"),
70+
PackageSpec(;
71+
url = "https://github.com/JuliaRobotics/IncrementalInference.jl.git",
72+
subdir = "IncrementalInferenceTypes",
73+
rev = "develop",
74+
),
75+
)
76+
Pkg.add(
77+
PackageSpec(;
78+
url = "https://github.com/JuliaRobotics/IncrementalInference.jl.git",
79+
subdir = "IncrementalInference",
80+
rev = "develop",
81+
),
7082
)
7183
@info "------------------------------------------------------------------------"
7284
@info "These tests are using IncrementalInference to do additional driver tests"

0 commit comments

Comments
 (0)