Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
123e21b5
Commit
123e21b5
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-190
: fixes for url construction and specifiey correct content type in accept header for parset
parent
7df82437
No related branches found
No related tags found
1 merge request
!252
Resolve TMSS-190
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/client/lib/tmss_http_rest_client.py
+8
-7
8 additions, 7 deletions
SAS/TMSS/client/lib/tmss_http_rest_client.py
with
8 additions
and
7 deletions
SAS/TMSS/client/lib/tmss_http_rest_client.py
+
8
−
7
View file @
123e21b5
...
@@ -106,7 +106,8 @@ class TMSSsession(object):
...
@@ -106,7 +106,8 @@ class TMSSsession(object):
def
get_subtask_parset
(
self
,
subtask_id
)
->
str
:
def
get_subtask_parset
(
self
,
subtask_id
)
->
str
:
'''
get the lofar parameterset (as text) for the given subtask
'''
'''
get the lofar parameterset (as text) for the given subtask
'''
result
=
self
.
session
.
get
(
url
=
'
%s/subtask/%s/parset
'
%
(
self
.
base_url
,
subtask_id
))
result
=
self
.
session
.
get
(
url
=
self
.
get_full_url_for_path
(
'
/subtask/%s/parset
'
%
(
subtask_id
,)),
headers
=
{
'
Accept
'
:
'
text/plain
'
})
if
result
.
status_code
>=
200
and
result
.
status_code
<
300
:
if
result
.
status_code
>=
200
and
result
.
status_code
<
300
:
return
result
.
content
.
decode
(
'
utf-8
'
)
return
result
.
content
.
decode
(
'
utf-8
'
)
raise
Exception
(
"
Could not get parameterset for subtask %s.
\n
Response: %s
"
%
(
subtask_id
,
result
))
raise
Exception
(
"
Could not get parameterset for subtask %s.
\n
Response: %s
"
%
(
subtask_id
,
result
))
...
@@ -241,7 +242,7 @@ class TMSSsession(object):
...
@@ -241,7 +242,7 @@ class TMSSsession(object):
def
specify_observation_task
(
self
,
task_id
:
int
)
->
requests
.
Response
:
def
specify_observation_task
(
self
,
task_id
:
int
)
->
requests
.
Response
:
"""
specify observation for the given draft task by just doing a REST API call
"""
"""
specify observation for the given draft task by just doing a REST API call
"""
result
=
self
.
session
.
get
(
url
=
'
%s/api
/task/%s/specify_observation
'
%
(
self
.
base_url
,
task_id
))
result
=
self
.
session
.
get
(
url
=
self
.
get_full_url_for_path
(
'
/task/%s/specify_observation
'
%
(
task_id
,)
))
if
result
.
status_code
>=
200
and
result
.
status_code
<
300
:
if
result
.
status_code
>=
200
and
result
.
status_code
<
300
:
return
result
.
content
.
decode
(
'
utf-8
'
)
return
result
.
content
.
decode
(
'
utf-8
'
)
raise
Exception
(
"
Could not specify observation for task %s.
\n
Response: %s
"
%
(
task_id
,
result
))
raise
Exception
(
"
Could not specify observation for task %s.
\n
Response: %s
"
%
(
task_id
,
result
))
...
@@ -259,7 +260,7 @@ class TMSSsession(object):
...
@@ -259,7 +260,7 @@ class TMSSsession(object):
def
get_setting
(
self
,
setting_name
:
str
)
->
{}:
def
get_setting
(
self
,
setting_name
:
str
)
->
{}:
"""
get the value of a TMSS setting.
"""
get the value of a TMSS setting.
returns the setting value upon success, or raises.
"""
returns the setting value upon success, or raises.
"""
response
=
self
.
session
.
get
(
url
=
'
%s
/setting/%s/
'
%
(
self
.
base_url
,
setting_name
),
response
=
self
.
session
.
get
(
url
=
self
.
get_full_url_for_path
(
'
/setting/%s/
'
%
(
setting_name
,)
),
params
=
{
'
format
'
:
'
json
'
})
params
=
{
'
format
'
:
'
json
'
})
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
...
@@ -271,7 +272,7 @@ class TMSSsession(object):
...
@@ -271,7 +272,7 @@ class TMSSsession(object):
def
set_setting
(
self
,
setting_name
:
str
,
setting_value
:
bool
)
->
{}:
def
set_setting
(
self
,
setting_name
:
str
,
setting_value
:
bool
)
->
{}:
"""
set a value for a TMSS setting.
"""
set a value for a TMSS setting.
returns the setting value upon success, or raises.
"""
returns the setting value upon success, or raises.
"""
response
=
self
.
session
.
patch
(
url
=
'
%s
/setting/%s/
'
%
(
self
.
base_url
,
setting_name
),
response
=
self
.
session
.
patch
(
url
=
self
.
get_full_url_for_path
(
'
/setting/%s/
'
%
(
setting_name
,)
),
json
=
{
'
value
'
:
setting_value
})
json
=
{
'
value
'
:
setting_value
})
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
...
@@ -291,7 +292,7 @@ class TMSSsession(object):
...
@@ -291,7 +292,7 @@ class TMSSsession(object):
json_data
[
'
template
'
]
=
json
.
loads
(
template
)
if
isinstance
(
template
,
str
)
else
template
json_data
[
'
template
'
]
=
json
.
loads
(
template
)
if
isinstance
(
template
,
str
)
else
template
json_data
.
update
(
**
kwargs
)
json_data
.
update
(
**
kwargs
)
response
=
self
.
session
.
post
(
url
=
'
%s/%s/
'
%
(
self
.
base_url
,
template_path
),
json
=
json_data
)
response
=
self
.
session
.
post
(
url
=
self
.
get_full_url_for_path
(
template_path
),
json
=
json_data
)
if
response
.
status_code
==
201
:
if
response
.
status_code
==
201
:
logger
.
info
(
"
created new template: %s
"
,
json
.
loads
(
response
.
text
)[
'
url
'
])
logger
.
info
(
"
created new template: %s
"
,
json
.
loads
(
response
.
text
)[
'
url
'
])
else
:
else
:
...
@@ -304,7 +305,7 @@ class TMSSsession(object):
...
@@ -304,7 +305,7 @@ class TMSSsession(object):
new_feedback
=
feedback
new_feedback
=
feedback
else
:
else
:
new_feedback
=
"
%s
\n
%s
"
%
(
existing_feedback
,
feedback
)
new_feedback
=
"
%s
\n
%s
"
%
(
existing_feedback
,
feedback
)
response
=
self
.
session
.
patch
(
url
=
'
%s
/subtask/%s/
'
%
(
self
.
base_url
,
subtask_id
),
response
=
self
.
session
.
patch
(
url
=
self
.
get_full_url_for_path
(
'
/subtask/%s/
'
%
(
subtask_id
,)
),
json
=
{
'
raw_feedback
'
:
new_feedback
},
json
=
{
'
raw_feedback
'
:
new_feedback
},
params
=
{
'
format
'
:
'
json
'
})
params
=
{
'
format
'
:
'
json
'
})
...
@@ -318,7 +319,7 @@ class TMSSsession(object):
...
@@ -318,7 +319,7 @@ class TMSSsession(object):
def
process_subtask_feedback_and_set_finished
(
self
,
subtask_id
:
int
)
->
{}:
def
process_subtask_feedback_and_set_finished
(
self
,
subtask_id
:
int
)
->
{}:
'''
process the raw_feedback of a given subtask and set the subtask to finished on succes. Return the subtask
'''
process the raw_feedback of a given subtask and set the subtask to finished on succes. Return the subtask
with its new state, or raise an error
'''
with its new state, or raise an error
'''
response
=
self
.
session
.
post
(
url
=
'
%s
/subtask/%s/process_feedback_and_set_finished
'
%
(
self
.
base_url
,
subtask_id
),
response
=
self
.
session
.
post
(
url
=
self
.
get_full_url_for_path
(
'
/subtask/%s/process_feedback_and_set_finished
'
%
(
subtask_id
,)
),
params
=
{
'
format
'
:
'
json
'
})
params
=
{
'
format
'
:
'
json
'
})
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
if
response
.
status_code
>=
200
and
response
.
status_code
<
300
:
...
...
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