Skip to content

Commit

Permalink
Variable level Abstraction in DFG Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Affie committed Jul 10, 2024
1 parent df7c8d6 commit 5ac20bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/NavAbilityClient.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
struct DFGClient <: DFG.AbstractDFG{DFG.AbstractParams}
struct DFGClient{VT<:AbstractDFGVariable, FT<:AbstractDFGFactor} <: AbstractDFG{AbstractParams}
client::GQL.Client
user::NamedTuple{(:id, :label), Tuple{UUID, String}}
robot::NamedTuple{(:id, :label), Tuple{UUID, String}}
session::NamedTuple{(:id, :label), Tuple{UUID, String}}
blobStores::Dict{Symbol, DFG.AbstractBlobStore}
end

DFG.getTypeDFGVariables(::DFGClient{T, <:AbstractDFGFactor}) where {T} = T
DFG.getTypeDFGFactors(::DFGClient{<:AbstractDFGVariable, T}) where {T} = T

function DFGClient(client::GQL.Client, context::Context)
return DFGClient(
return DFGClient{DFG.Variable, DFG.PackedFactor}(
client,
(id = context.user.id, label = context.user.label),
(id = context.robot.id, label = context.robot.label),
Expand Down Expand Up @@ -55,7 +58,7 @@ function DFGClient(
addSessionIfNotExists,
)

return DFGClient(
return DFGClient{DFG.Variable, DFG.PackedFactor}(
client,
(id = context.user.id, label = context.user.label),
(id = context.robot.id, label = context.robot.label),
Expand Down
2 changes: 1 addition & 1 deletion src/NavAbilitySDK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import GraphQLClient as GQL
import DistributedFactorGraphs as DFG
using DistributedFactorGraphs:
Variable, PackedVariableNodeData, MeanMaxPPE, BlobEntry, PackedFactor, hasBlob,
getBlobStore
getBlobStore, AbstractDFGVariable, AbstractDFGFactor, AbstractParams, AbstractDFG

import DistributedFactorGraphs:
getFactor,
Expand Down
4 changes: 2 additions & 2 deletions src/services/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function listVariables(fgclient::DFGClient)
)
end

function getVariable(fgclient::DFGClient, label::Symbol)
function getVariable(fgclient::DFGClient{VT, <:AbstractDFGFactor}, label::Symbol) where VT
variables = Dict(
"userId" => fgclient.user.id,
"robotId" => fgclient.robot.id,
Expand All @@ -226,7 +226,7 @@ function getVariable(fgclient::DFGClient, label::Symbol)
variables,
throw_on_execution_error = true,
)
return response.data["users"][1]["robots"][1]["sessions"][1]["variables"][1]
return VT(response.data["users"][1]["robots"][1]["sessions"][1]["variables"][1])
end

function getVariableSummary(fgclient::DFGClient, label::Symbol)
Expand Down

0 comments on commit 5ac20bc

Please sign in to comment.