Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gateway
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
gateway
Commits
a98b6581
Commit
a98b6581
authored
3 years ago
by
Steve Reis
Browse files
Options
Downloads
Patches
Plain Diff
fix(exareme): Headers empty, catch parsing errors
Adding result message on experiment parsing error
parent
c1314ee5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/src/engine/connectors/exareme/converters.ts
+8
-0
8 additions, 0 deletions
api/src/engine/connectors/exareme/converters.ts
api/src/engine/connectors/exareme/main.connector.ts
+21
-21
21 additions, 21 deletions
api/src/engine/connectors/exareme/main.connector.ts
with
29 additions
and
21 deletions
api/src/engine/connectors/exareme/converters.ts
+
8
−
0
View file @
a98b6581
...
...
@@ -227,6 +227,14 @@ export const dataToExperiment = (
status
:
'
error
'
,
variables
:
[],
domain
:
data
[
'
domain
'
]
??
''
,
results
:
[
{
rawdata
:
{
type
:
'
text/plain+error
'
,
data
:
'
Error when parsing experiment data from the Engine
'
,
},
},
],
datasets
:
[],
algorithm
:
{
id
:
'
unknown
'
,
...
...
This diff is collapsed.
Click to expand it.
api/src/engine/connectors/exareme/main.connector.ts
+
21
−
21
View file @
a98b6581
...
...
@@ -5,6 +5,7 @@ import {
HttpStatus
,
Inject
,
Injectable
,
InternalServerErrorException
,
}
from
'
@nestjs/common
'
;
import
{
AxiosRequestConfig
}
from
'
axios
'
;
import
{
Request
}
from
'
express
'
;
...
...
@@ -45,7 +46,6 @@ type Headers = Record<string, string>;
@
Injectable
()
export
default
class
ExaremeService
implements
IEngineService
{
headers
=
{};
constructor
(
@
Inject
(
ENGINE_MODULE_OPTIONS
)
private
readonly
options
:
IEngineOptions
,
private
readonly
httpService
:
HttpService
,
...
...
@@ -75,9 +75,7 @@ export default class ExaremeService implements IEngineService {
this
.
options
.
baseurl
+
`experiments
${
isTransient
?
'
/transient
'
:
''
}
`
;
const
resultAPI
=
await
firstValueFrom
(
this
.
post
<
ExperimentData
>
(
request
,
path
,
form
,
{
headers
:
this
.
headers
,
}),
this
.
post
<
ExperimentData
>
(
request
,
path
,
form
),
);
return
dataToExperiment
(
resultAPI
.
data
);
...
...
@@ -141,11 +139,7 @@ export default class ExaremeService implements IEngineService {
const
path
=
this
.
options
.
baseurl
+
`experiments/
${
id
}
`
;
try
{
await
firstValueFrom
(
this
.
delete
(
request
,
path
,
{
headers
:
this
.
headers
,
}),
);
await
firstValueFrom
(
this
.
delete
(
request
,
path
));
return
{
id
:
id
,
};
...
...
@@ -158,11 +152,7 @@ export default class ExaremeService implements IEngineService {
const
path
=
this
.
options
.
baseurl
+
'
pathologies
'
;
try
{
const
data
=
await
firstValueFrom
(
this
.
get
<
Pathology
[]
>
(
request
,
path
,
{
headers
:
this
.
headers
,
}),
);
const
data
=
await
firstValueFrom
(
this
.
get
<
Pathology
[]
>
(
request
,
path
));
return
(
data
?.
data
...
...
@@ -192,20 +182,30 @@ export default class ExaremeService implements IEngineService {
async
getActiveUser
(
request
:
Request
):
Promise
<
User
>
{
const
path
=
this
.
options
.
baseurl
+
'
activeUser
'
;
const
response
=
await
firstValueFrom
(
this
.
get
<
string
>
(
request
,
path
));
return
transformToUser
.
evaluate
(
response
.
data
);
try
{
return
transformToUser
.
evaluate
(
response
.
data
);
}
catch
(
e
)
{
new
InternalServerErrorException
(
'
Cannot parse user data from Engine
'
,
e
);
}
}
async
updateUser
(
request
:
Request
):
Promise
<
User
>
{
const
path
=
this
.
options
.
baseurl
+
'
activeUser/agreeNDA
'
;
this
.
post
<
string
>
(
request
,
path
,
request
.
body
).
pipe
(
map
((
response
)
=>
response
.
data
),
const
response
=
await
firstValueFrom
(
this
.
post
<
string
>
(
request
,
path
,
{
agreeNDA
:
true
,
}),
);
return
this
.
getActiveUser
(
request
);
try
{
return
transformToUser
.
evaluate
(
response
.
data
);
}
catch
(
e
)
{
throw
new
InternalServerErrorException
(
'
Error when trying to parse user data from the engine
'
,
);
}
}
getAlgorithmsREST
(
request
:
Request
):
Observable
<
string
>
{
...
...
@@ -256,7 +256,7 @@ export default class ExaremeService implements IEngineService {
};
private
getHeadersFromRequest
(
request
:
Request
):
Headers
{
if
(
!
request
||
request
.
headers
)
return
{};
if
(
!
request
||
!
request
.
headers
)
return
{};
return
request
.
headers
as
Headers
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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