Skip to content

Commit

Permalink
Merge pull request #180 from NavAbility/main
Browse files Browse the repository at this point in the history
Syncing before we advance to v0.5
  • Loading branch information
GearsAD authored Nov 17, 2022
2 parents a604a31 + d130860 commit c834e9d
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "f3e6a059-199c-4ada-8143-fcefb97e6165"
keywords = ["navability", "navigation", "slam", "sdk", "robotics", "robots"]
desc = "NavAbility SDK: Access NavAbility Cloud factor graph features. Note that this SDK and the related API are still in development. Please let us know if you have any issues at [email protected]."
authors = ["NavAbility <[email protected]>"]
version = "0.4.8"
version = "0.4.9"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
2 changes: 1 addition & 1 deletion src/navability/graphql/DataBlobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mutation sdk_url_createdownload (\$userId: String!, \$fileId: ID!) {
"""


GQL_CREATEUPLOAD = """
GQL_CREATE_UPLOAD = """
mutation sdk_url_createupload(\$filename: String!, \$filesize: Int!, \$parts: Int!) {
createUpload(
file: {
Expand Down
16 changes: 16 additions & 0 deletions src/navability/graphql/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ GQL_FRAGMENT_VARIABLES = """
}
"""

GQL_LISTVARIABLES = """
query sdk_list_variables (
\$userId: ID!,
\$robotId: ID!,
\$sessionId: ID!) {
users(where:{id: \$userId}) {
robots(where:{id: \$robotId}) {
sessions(where:{id: \$sessionId}) {
variables {
label
}
}
}
}
}"""

GQL_GETVARIABLE = """
query sdk_get_variable(
\$userId: ID!,
Expand Down
77 changes: 39 additions & 38 deletions src/navability/services/DataBlobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Args:
fileId (String): The unique file identifier of the data blob.
"""
function createDownloadEvent(
navAbilityClient::NavAbilityClient,
userId::AbstractString,
fileId::UUID
)
navAbilityClient::NavAbilityClient,
userId::AbstractString,
fileId::UUID
)
#
response = navAbilityClient.mutate(MutationOptions(
"sdk_url_createdownload",
Expand All @@ -40,10 +40,10 @@ createDownload(w...) = @async createDownloadEvent(w...)


function getDataEvent(
client::NavAbilityClient,
userId::AbstractString,
fileId::UUID
)
client::NavAbilityClient,
userId::AbstractString,
fileId::UUID
)
#
url = createDownload(client, userId, fileId) |> fetch
io = PipeBuffer()
Expand All @@ -53,6 +53,7 @@ end

getDataEvent(client::NavAbilityClient, context::Client, fileId::UUID) = getDataEvent(client, context.userId, fileId)
getData(client::NavAbilityClient, context::Client, fileId::UUID) = @async getDataEvent(client, context, fileId)
getData(client::NavAbilityClient, userId::AbstractString, fileId::UUID) = @async getDataEvent(client, userId, fileId)


function getDataEntry(
Expand Down Expand Up @@ -128,15 +129,15 @@ Args:
parts (Int): Split upload into multiple blob parts, FIXME currently only supports parts=1.
"""
function createUploadEvent(
navAbilityClient::NavAbilityClient,
filename::AbstractString,
filesize::Int,
parts::Int=1
)
navAbilityClient::NavAbilityClient,
filename::AbstractString,
filesize::Int,
parts::Int=1
)
#
response = navAbilityClient.mutate(MutationOptions(
"sdk_url_createupload",
GQL_CREATEUPLOAD,
GQL_CREATE_UPLOAD,
Dict(
"filename" => filename,
"filesize" => filesize,
Expand All @@ -161,11 +162,11 @@ createUpload(w...) = @async createUploadEvent(w...)


function completeUploadSingleEvent(
navAbilityClient::NavAbilityClient,
fileId::AbstractString,
uploadId::AbstractString,
eTag::AbstractString,
)
navAbilityClient::NavAbilityClient,
fileId::AbstractString,
uploadId::AbstractString,
eTag::AbstractString,
)
response = navAbilityClient.mutate(MutationOptions(
"completeUpload",
GQL_COMPLETEUPLOAD_SINGLE,
Expand All @@ -192,10 +193,10 @@ completeUploadSingle(w...) = @async completeUploadSingleEvent(w...)


function addDataEvent(
client::NavAbilityClient,
blobname::AbstractString,
blob::AbstractVector{UInt8}
)
client::NavAbilityClient,
blobname::AbstractString,
blob::AbstractVector{UInt8}
)
#
io = IOBuffer(blob)

Expand Down Expand Up @@ -244,15 +245,15 @@ addData(w...) = @async addDataEvent(w...)


function addDataEntryEvent(
navAbilityClient::NavAbilityClient,
userId::AbstractString,
robotId::AbstractString,
sessionId::AbstractString,
variableLabel::AbstractString,
dataId::AbstractString, # TODO must also support ::UUID
dataLabel::AbstractString,
mimeType::AbstractString="",
)
navAbilityClient::NavAbilityClient,
userId::AbstractString,
robotId::AbstractString,
sessionId::AbstractString,
variableLabel::AbstractString,
dataId::AbstractString, # TODO must also support ::UUID
dataLabel::AbstractString,
mimeType::AbstractString="",
)
response = navAbilityClient.mutate(MutationOptions(
"sdk_adddataentry",
GQL_ADDDATAENTRY,
Expand Down Expand Up @@ -292,12 +293,12 @@ addDataEntry(w...) = @async addDataEntryEvent(w...)


function listDataEntriesEvent(
navAbilityClient::NavAbilityClient,
userId::AbstractString,
robotId::AbstractString,
sessionId::AbstractString,
variableLabel::AbstractString
)
navAbilityClient::NavAbilityClient,
userId::AbstractString,
robotId::AbstractString,
sessionId::AbstractString,
variableLabel::AbstractString
)
#
response = navAbilityClient.mutate(MutationOptions(
"sdk_listdataentries",
Expand Down
41 changes: 35 additions & 6 deletions src/navability/services/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,44 @@ end

getVariables(navAbilityClient::NavAbilityClient, client::Client; detail::QueryDetail = SKELETON) = @async getVariablesEvent(navAbilityClient, client; detail)

function listVariables(navAbilityClient::NavAbilityClient, client::Client)
@async begin
variables = getVariables(navAbilityClient,client) |> fetch
map(v -> v["label"], variables)

function listVariablesEvent(
client::NavAbilityClient,
context::Client
)
response = client.query(QueryOptions(
"sdk_list_variables",
GQL_LISTVARIABLES,
Dict(
"userId" => context.userId,
"robotId" => context.robotId,
"sessionId" => context.sessionId,
)
)) |> fetch
payload = JSON.parse(response.Data)
try
# FIXME, this list can be empty, using try catch as lazy check
(s->s["label"]).(payload["data"]["users"][1]["robots"][1]["sessions"][1]["variables"])
catch err
if err isa BoundsError
String[]
else
throw(err)
end
end
end

function ls(navAbilityClient::NavAbilityClient, client::Client)
return listVariables(navAbilityClient,client)
function listVariables(client::NavAbilityClient, context::Client)
@async listVariablesEvent(client, context)
# @async begin
# # FIXME, upgrade to use a direct listVariables API call instead
# variables = getVariables(client,context) |> fetch
# map(v -> v["label"], variables)
# end
end

function ls(client::NavAbilityClient, context::Client)
return listVariables(client, context)
end

function listFactorsEvent(
Expand Down

0 comments on commit c834e9d

Please sign in to comment.