Skip to content

Commit

Permalink
Update Model and Patch docs for v0.8 (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Affie authored Oct 30, 2024
1 parent c053afd commit 239fdd4
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 159 deletions.
10 changes: 5 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ makedocs(;
),
pages = [
"Home" => "index.md",
"Getting Started" => "start.md",
"Variables" => "variables.md",
"Factors" => "factors.md",
"Build a Graph" => "buildgraph.md",
"Graph Solvers" => "solvers.md",
# "Getting Started" => "start.md",
# "Variables" => "variables.md",
# "Factors" => "factors.md",
# "Build a Graph" => "buildgraph.md",
# "Graph Solvers" => "solvers.md",
"Index" => "summary.md",
],
)
Expand Down
6 changes: 1 addition & 5 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

Welcome to the NavAbilitySDK documentation. Various NavAbilitySDKs exist for different programming languages. This particular documentation set is for the Julia language package, however, there is strong consistency between the SDKs for various languages. All the SDKs make standard, authenticated requests to the NavAbility servers, thereby enforcing consistency of operations.

Convenient links to other language NavAbilitySDKs:
- [NavAbilitySDK.py](https://github.com/NavAbility/NavAbilitySDK.py)
- [NavAbilitySDK.js](https://github.com/NavAbility/NavAbilitySDK.js)

Next, see the [Getting Started](@ref getting_started) page.
NavAbilitySDK.jl extends functions of [DistributedFactorGraphs.jl](https://github.com/JuliaRobotics/DistributedFactorGraphs.jl) and more documentaion is avialable [here](https://juliarobotics.org/DistributedFactorGraphs.jl/latest/).
4 changes: 2 additions & 2 deletions docs/src/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Documentation for [NavAbilitySDK](https://github.com/NavAbility/NavAbilitySDK.jl
```@index
```

<!-- ```@autodocs
```@autodocs
Modules = [NavAbilitySDK]
``` -->
```
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions docs/todo/index_extra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Convenient links to other language NavAbilitySDKs:
- [NavAbilitySDK.py](https://github.com/NavAbility/NavAbilitySDK.py)
- [NavAbilitySDK.js](https://github.com/NavAbility/NavAbilitySDK.js)

Next, see the [Getting Started](@ref getting_started) page.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/NavAbilityClient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ function NavAbilityClient(
auth_token::String,
apiUrl::String = "https://api.navability.io";
orgLabel::Union{Symbol, Nothing} = nothing,
introspect::Bool = false,
kwargs...,
)
headers = Dict("Authorization" => "Bearer $auth_token")
client = GQL.Client(apiUrl; headers, kwargs...)
client = GQL.Client(apiUrl; headers, introspect, kwargs...)
if isnothing(orgLabel)
id = getOrgs(client)[1].id
else
Expand Down
4 changes: 4 additions & 0 deletions src/NavAbilityDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ struct NavAbilityDFG{VT<:AbstractDFGVariable, FT<:AbstractDFGFactor} <: Abstract
blobStores::Dict{Symbol, DFG.AbstractBlobStore}
end

DFG.getLabel(dfg::NavAbilityDFG) = dfg.fg.label

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

Expand Down Expand Up @@ -77,6 +79,8 @@ function NavAbilityDFG(
fg = getGraph(client, fgLabel)
end

connect!(client, agent, fg)

return NavAbilityDFG{DFG.Variable, DFG.PackedFactor}(
client,
fg,
Expand Down
2 changes: 2 additions & 0 deletions src/entities/NvaNodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct NvaNode{T}
label::Symbol
end

DFG.getLabel(node::NvaNode) = node.label

@kwdef struct AgentCreateInput
# Interface
id::UUID#!
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Base.@kwdef struct BlobEntryCreateInput
metadata::String
_version::String
timestamp::ZonedDateTime
size::Int
size::Union{String, Nothing} #FIXME
parent::Any
end

Expand Down
33 changes: 22 additions & 11 deletions src/graphql/Model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
#TODO replace sesssion
# $GQL_FRAGMENT_SESSION
# sessions { ...session_fields }
# $GQL_FRAGMENT_BLOBENTRY
FRAGMENT_MODEL = """
$GQL_FRAGMENT_BLOBENTRY
fragment FRAGMENT_MODEL on Model {
label
createdTimestamp
namespace
}
"""
Expand All @@ -23,27 +22,39 @@ QUERY_GET_MODEL = """
query QUERY_GET_MODEL(\$modelId: ID!) {
models (where: {id: \$modelId}) {
label
createdTimestamp
namespace
}
}
"""

# $FRAGMENT_MODEL
# ...FRAGMENT_MODEL
QUERY_GET_MODELS_ALL = """
$FRAGMENT_MODEL
{
models {
label
namespace
}
}
"""

GQL_ADD_MODELS = GQL.gql"""
mutation addModels($input: [ModelCreateInput!]!) {
addModels(input: $input) {
models {
...FRAGMENT_MODEL
label
namespace
}
}
}
"""

GQL_ADD_MODEL = """
$FRAGMENT_MODEL
mutation addModel(\$label: String!, \$status: String = "", \$description: String = "") {
addModels(input: {label: \$label, status: \$status, description: \$description}) {
models {
...FRAGMENT_MODEL
QUERY_GET_MODEL_GRAPHS = GQL.gql"""
query getGraphs_Model($id: ID!) {
models(where: {id: $id}) {
fgs {
label
namespace
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/services/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ function addBlobEntries!(
getCommonProperties(BlobEntryCreateInput, entry)...,
id = getId(fgclient, parent, entry.label),
parent = createConnect(fgclient, parent),
size = isnothing(entry.size) ? "" : entry.size, #FIXME remove once size is "required"
)
end

Expand Down
8 changes: 6 additions & 2 deletions src/services/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ function executeGql(cfg::NavAbilityDFG, query::AbstractString, variables, T::Ty
executeGql(cfg.client, query, variables, T; kwargs...)
end

function executeGql(client::NavAbilityClient, query::AbstractString, variables, T::Type = Any; throw_on_execution_error = true, kwargs...)
function executeGql(cfg::NavAbilityClient, query::AbstractString, variables, T::Type = Any; kwargs...)
executeGql(cfg.client, query, variables, T; kwargs...)
end

function executeGql(client::GQL.Client, query::AbstractString, variables, T::Type = Any; throw_on_execution_error = true, kwargs...)
return GQL.execute(
client.client,
client,
query,
T;
variables,
Expand Down
71 changes: 71 additions & 0 deletions src/services/FactorGraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,75 @@ function DFG.setGraphMetadata!(fgclient::NavAbilityDFG, smallData::Dict{Symbol,
base64decode(response.data["updateFactorgraphs"]["factorgraphs"][1]["metadata"]),
Dict{Symbol, DFG.SmallDataTypes},
)
end


## =======================================================================================
## Connect Factorgraph to other nodes
## =======================================================================================


GQL_CONNECT_GRAPH_TO_MODEL = GQL.gql"""
mutation connectGraphModel($modelId: ID!, $fgId: ID!) {
updateModels(
where: { id: $modelId }
update: { fgs: { connect: { where: { node: { id: $fgId } } } } }
) {
info {
relationshipsCreated
}
}
}
"""

function connect!(client, model::NvaNode{Model}, fg::NvaNode{Factorgraph})
variables = Dict("modelId" => getId(model), "fgId" => getId(fg))

response = executeGql(client, GQL_CONNECT_GRAPH_TO_MODEL, variables)

return response.data["updateModels"]["info"]["relationshipsCreated"]
end


GQL_CONNECT_GRAPH_TO_AGENT = GQL.gql"""
mutation connectGraphModel($agentId: ID!, $fgId: ID!) {
updateAgents(
where: { id: $agentId }
update: { fgs: { connect: { where: { node: { id: $fgId } } } } }
) {
info {
relationshipsCreated
}
}
}
"""

function connect!(client, agent::NvaNode{Agent}, fg::NvaNode{Factorgraph})
variables = Dict("agentId" => getId(agent), "fgId" => getId(fg))

response = executeGql(client, GQL_CONNECT_GRAPH_TO_AGENT, variables)

return response.data["updateAgents"]["info"]["relationshipsCreated"]
end


QUERY_GET_GRAPHS_AGENTS = GQL.gql"""
query getAgents_Graph($id: ID!) {
factorgraphs(where: {id: $id}) {
agents {
label
namespace
}
}
}
"""

function getAgents(client::NavAbilityClient, fg::NvaNode{Factorgraph})
response = executeGql(
client,
QUERY_GET_GRAPHS_AGENTS,
Dict("id" => getId(fg)),
Vector{Dict{Symbol, Vector{NvaNode{Agent}}}},
)
return handleQuery(response, "factorgraphs")[1][:agents]
end
Loading

0 comments on commit 239fdd4

Please sign in to comment.