Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SpiceQL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
SpiceQL
Commits
26c1789b
Unverified
Commit
26c1789b
authored
5 months ago
by
Christine Kim
Committed by
GitHub
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Bugfixes (#55)
* Add rest url env var option * Fix strToList bug
parent
d952cb94
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
SpiceQL/include/utils.h
+8
-0
8 additions, 0 deletions
SpiceQL/include/utils.h
SpiceQL/src/api.cpp
+12
-10
12 additions, 10 deletions
SpiceQL/src/api.cpp
SpiceQL/src/utils.cpp
+13
-0
13 additions, 0 deletions
SpiceQL/src/utils.cpp
fastapi/app/main.py
+2
-4
2 additions, 4 deletions
fastapi/app/main.py
with
35 additions
and
14 deletions
SpiceQL/include/utils.h
+
8
−
0
View file @
26c1789b
...
@@ -301,6 +301,14 @@ namespace SpiceQL {
...
@@ -301,6 +301,14 @@ namespace SpiceQL {
std
::
string
getMissionKeys
(
nlohmann
::
json
config
);
std
::
string
getMissionKeys
(
nlohmann
::
json
config
);
/**
* @brief Returns the REST URL
*
* @returns SpiceQL's REST URL as string
**/
std
::
string
getRestUrl
();
/**
/**
* @brief resolve the dependencies in a config in place
* @brief resolve the dependencies in a config in place
*
*
...
...
This diff is collapsed.
Click to expand it.
SpiceQL/src/api.cpp
+
12
−
10
View file @
26c1789b
...
@@ -152,30 +152,32 @@ namespace SpiceQL {
...
@@ -152,30 +152,32 @@ namespace SpiceQL {
json
spiceAPIQuery
(
std
::
string
functionName
,
json
args
,
std
::
string
method
){
json
spiceAPIQuery
(
std
::
string
functionName
,
json
args
,
std
::
string
method
){
restincurl
::
Client
client
;
restincurl
::
Client
client
;
// Need to be able to set URL externally
// Need to be able to set URL externally
std
::
string
queryString
=
"http://127.0.0.1:8080/"
+
functionName
;
std
::
string
queryString
=
"http://127.0.0.1:8080/"
+
functionName
+
"?"
;
json
j
;
json
j
;
if
(
method
==
"GET"
){
if
(
method
==
"GET"
){
std
::
cout
<<
"[RestfulSpice] spiceAPIQuery GET"
<<
std
::
endl
;
SPDLOG_TRACE
(
"spiceAPIQuery GET"
);
queryString
+=
"?"
;
for
(
auto
x
:
args
.
items
())
{
for
(
auto
x
:
args
.
items
())
{
if
(
x
.
value
().
is_null
())
{
continue
;
}
queryString
+=
x
.
key
();
queryString
+=
x
.
key
();
queryString
+=
"="
;
queryString
+=
"="
;
queryString
+=
x
.
value
().
dump
();
queryString
+=
x
.
value
().
dump
();
queryString
+=
"&"
;
queryString
+=
"&"
;
}
}
SPDLOG_TRACE
(
"queryString = {}"
,
queryString
);
std
::
string
encodedString
=
url_encode
(
queryString
);
std
::
string
encodedString
=
url_encode
(
queryString
);
SPDLOG_TRACE
(
"
spiceAPIQuery
encodedString = {}"
,
encodedString
);
SPDLOG_TRACE
(
"encodedString = {}"
,
encodedString
);
client
.
Build
()
->
Get
(
encodedString
).
Option
(
CURLOPT_FOLLOWLOCATION
,
1L
).
AcceptJson
().
WithCompletion
([
&
](
const
restincurl
::
Result
&
result
)
{
client
.
Build
()
->
Get
(
encodedString
).
Option
(
CURLOPT_FOLLOWLOCATION
,
1L
).
AcceptJson
().
WithCompletion
([
&
](
const
restincurl
::
Result
&
result
)
{
SPDLOG_TRACE
(
"
spiceAPIQuery
GET result body = {}"
,
result
.
body
);
SPDLOG_TRACE
(
"GET result body = {}"
,
result
.
body
);
j
=
json
::
parse
(
result
.
body
);
j
=
json
::
parse
(
result
.
body
);
}).
ExecuteSynchronous
();
}).
ExecuteSynchronous
();
}
else
{
}
else
{
SPDLOG_TRACE
(
"
spiceAPIQuery
POST"
);
SPDLOG_TRACE
(
"POST"
);
client
.
Build
()
->
Post
(
queryString
).
Option
(
CURLOPT_FOLLOWLOCATION
,
1L
).
AcceptJson
().
WithJson
(
args
.
dump
()).
WithCompletion
([
&
](
const
restincurl
::
Result
&
result
)
{
client
.
Build
()
->
Post
(
queryString
).
Option
(
CURLOPT_FOLLOWLOCATION
,
1L
).
AcceptJson
().
WithJson
(
args
.
dump
()).
WithCompletion
([
&
](
const
restincurl
::
Result
&
result
)
{
SPDLOG_TRACE
(
"
spiceAPIQuery
POST result = {}"
,
result
.
body
);
SPDLOG_TRACE
(
"POST result = {}"
,
result
.
body
);
j
=
json
::
parse
(
result
.
body
);
j
=
json
::
parse
(
result
.
body
);
}).
ExecuteSynchronous
();
}).
ExecuteSynchronous
();
}
}
...
...
This diff is collapsed.
Click to expand it.
SpiceQL/src/utils.cpp
+
13
−
0
View file @
26c1789b
...
@@ -1215,6 +1215,19 @@ namespace SpiceQL {
...
@@ -1215,6 +1215,19 @@ namespace SpiceQL {
}
}
string
getRestUrl
()
{
char
*
spiceqlRestUrlEnvVar
=
std
::
getenv
(
"SPICEQL_REST_URL"
);
string
spiceqlRestUrl
;
if
(
spiceqlRestUrlEnvVar
==
NULL
)
{
spiceqlRestUrl
=
"https://astrogeology.usgs.gov/apis/spiceq/latest/"
;
}
else
{
spiceqlRestUrl
=
string
(
spiceqlRestUrlEnvVar
);
}
SPDLOG_TRACE
(
"SpiceQL REST URL: {}"
,
spiceqlRestUrl
);
return
spiceqlRestUrl
;
}
void
resolveConfigDependencies
(
json
&
config
,
const
json
&
dependencies
)
{
void
resolveConfigDependencies
(
json
&
config
,
const
json
&
dependencies
)
{
SPDLOG_TRACE
(
"IN resolveConfigDependencies"
);
SPDLOG_TRACE
(
"IN resolveConfigDependencies"
);
vector
<
json
::
json_pointer
>
depLists
=
findKeyInJson
(
config
,
"deps"
);
vector
<
json
::
json_pointer
>
depLists
=
findKeyInJson
(
config
,
"deps"
);
...
...
This diff is collapsed.
Click to expand it.
fastapi/app/main.py
+
2
−
4
View file @
26c1789b
...
@@ -138,7 +138,7 @@ async def getTargetOrientations(
...
@@ -138,7 +138,7 @@ async def getTargetOrientations(
toFrame
:
int
,
toFrame
:
int
,
refFrame
:
int
,
refFrame
:
int
,
mission
:
str
,
mission
:
str
,
ets
:
str
|
None
=
None
,
ets
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
[]
,
startEts
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
startEts
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
stopEts
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
stopEts
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
exposureDuration
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
exposureDuration
:
Annotated
[
list
[
float
],
Query
()]
|
float
|
str
|
None
=
None
,
...
@@ -172,7 +172,6 @@ async def strSclkToEt(
...
@@ -172,7 +172,6 @@ async def strSclkToEt(
frameCode
:
int
,
frameCode
:
int
,
sclk
:
str
,
sclk
:
str
,
mission
:
str
,
mission
:
str
,
useWeb
:
bool
=
False
,
searchKernels
:
bool
=
True
,
searchKernels
:
bool
=
True
,
kernelList
:
Annotated
[
list
[
str
],
Query
()]
|
str
|
None
=
[]):
kernelList
:
Annotated
[
list
[
str
],
Query
()]
|
str
|
None
=
[]):
try
:
try
:
...
@@ -351,7 +350,6 @@ async def frameTrace(
...
@@ -351,7 +350,6 @@ async def frameTrace(
ckQualities
=
strToList
(
ckQualities
)
ckQualities
=
strToList
(
ckQualities
)
kernelList
=
strToList
(
kernelList
)
kernelList
=
strToList
(
kernelList
)
result
,
kernels
=
pyspiceql
.
frameTrace
(
et
,
initialFrame
,
mission
,
ckQualities
,
False
,
searchKernels
,
kernelList
)
result
,
kernels
=
pyspiceql
.
frameTrace
(
et
,
initialFrame
,
mission
,
ckQualities
,
False
,
searchKernels
,
kernelList
)
print
(
"
frameTrace result =
"
+
str
(
result
))
body
=
ResultModel
(
result
=
result
,
kernels
=
kernels
)
body
=
ResultModel
(
result
=
result
,
kernels
=
kernels
)
return
ResponseModel
(
statusCode
=
200
,
body
=
body
)
return
ResponseModel
(
statusCode
=
200
,
body
=
body
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -418,7 +416,7 @@ def strToList(value: str) -> list:
...
@@ -418,7 +416,7 @@ def strToList(value: str) -> list:
# Converts a string into a list or its literal value
# Converts a string into a list or its literal value
if
value
is
not
None
:
if
value
is
not
None
:
if
isinstance
(
value
,
str
):
if
isinstance
(
value
,
str
):
value
=
literal_eval
(
value
)
value
=
value
.
replace
(
"
[
"
,
""
).
replace
(
"
]
"
,
""
).
split
(
"
,
"
)
else
:
else
:
try
:
try
:
iter
(
value
)
iter
(
value
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment