Skip to content
GitLab
Explore
Sign in
Register
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
b4a763c8
Commit
b4a763c8
authored
Nov 4, 2021
by
Jörn Künsemöller
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-763
: allow setting an error reason through REST client
parent
2142b214
No related branches found
No related tags found
1 merge request
!637
Resolve TMSS-763
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/client/lib/mains.py
+2
-1
2 additions, 1 deletion
SAS/TMSS/client/lib/mains.py
SAS/TMSS/client/lib/tmss_http_rest_client.py
+4
-1
4 additions, 1 deletion
SAS/TMSS/client/lib/tmss_http_rest_client.py
with
6 additions
and
2 deletions
SAS/TMSS/client/lib/mains.py
+
2
−
1
View file @
b4a763c8
...
...
@@ -99,12 +99,13 @@ def main_set_subtask_state():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
subtask_id
"
,
type
=
int
,
help
=
"
The ID of the TMSS subtask to set the status on
"
)
parser
.
add_argument
(
"
state
"
,
help
=
"
The state to set
"
)
parser
.
add_argument
(
'
-e
'
,
'
--error_reason
'
,
default
=
None
,
help
=
"
Optional error message string when setting a subtask to error.
"
)
parser
.
add_argument
(
'
-R
'
,
'
--rest_api_credentials
'
,
type
=
str
,
default
=
'
TMSSClient
'
,
help
=
'
TMSS django REST API credentials name, default: TMSSClient
'
)
args
=
parser
.
parse_args
()
try
:
with
TMSSsession
.
create_from_dbcreds_for_ldap
(
dbcreds_name
=
args
.
rest_api_credentials
)
as
session
:
changed_subtask
=
session
.
set_subtask_status
(
args
.
subtask_id
,
args
.
state
)
changed_subtask
=
session
.
set_subtask_status
(
args
.
subtask_id
,
args
.
state
,
args
.
error_reason
)
print
(
"
%s now has state %s, see: %s
"
%
(
changed_subtask
[
'
id
'
],
changed_subtask
[
'
state_value
'
],
changed_subtask
[
'
url
'
]))
except
Exception
as
e
:
print
(
e
)
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/client/lib/tmss_http_rest_client.py
+
4
−
1
View file @
b4a763c8
...
...
@@ -151,11 +151,14 @@ class TMSSsession(object):
except
:
pass
def
set_subtask_status
(
self
,
subtask_id
:
int
,
status
:
str
)
->
{}:
def
set_subtask_status
(
self
,
subtask_id
:
int
,
status
:
str
,
error_reason
=
None
)
->
{}:
'''
set the status for the given subtask, and return the subtask with its new state, or raise on error
'''
json_doc
=
{
'
state
'
:
"
%s/subtask_state/%s/
"
%
(
self
.
api_url
,
status
)}
if
status
==
'
finishing
'
or
status
==
'
cancelling
'
:
json_doc
[
'
scheduled_on_sky_stop_time
'
]
=
datetime
.
utcnow
().
isoformat
()
if
status
==
'
error
'
:
hostname
=
socket
.
gethostname
()
json_doc
[
'
error_reason
'
]
=
error_reason
if
error_reason
is
not
None
else
f
"
set to error via REST client on host
'
{
hostname
}
'"
logger
.
info
(
"
updating subtask id=%s status to
'
%s
'"
,
subtask_id
,
status
)
response
=
self
.
session
.
patch
(
url
=
'
%s/subtask/%s/
'
%
(
self
.
api_url
,
subtask_id
),
json
=
json_doc
)
...
...
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