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
c37f3e36
Commit
c37f3e36
authored
3 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-860
: specialized method to get latest strategy template
parent
c4cee8ed
No related branches found
No related tags found
1 merge request
!828
TMSS-860
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/client/lib/populate.py
+2
-2
2 additions, 2 deletions
SAS/TMSS/client/lib/populate.py
SAS/TMSS/client/lib/tmss_http_rest_client.py
+32
-8
32 additions, 8 deletions
SAS/TMSS/client/lib/tmss_http_rest_client.py
with
34 additions
and
10 deletions
SAS/TMSS/client/lib/populate.py
+
2
−
2
View file @
c37f3e36
...
...
@@ -152,7 +152,7 @@ def populate_schemas(schema_dir: str=None, dbcreds_name: str=None, parallel: boo
try
:
template_type_name
=
template
.
pop
(
'
template_type_name
'
)
try
:
known_template
=
client
.
_get_template
(
template_type_name
=
template_type_name
,
name
=
template
[
'
name
'
],
version
=
template
[
'
version
'
])
known_template
=
client
.
_get_
schema_
template
(
template_type_name
=
template_type_name
,
name
=
template
[
'
name
'
],
version
=
template
[
'
version
'
])
if
known_template
[
'
schema
'
]
==
template
[
'
schema
'
]:
logger
.
info
(
"
Skipping template with name=
'
%s
'
version=
'
%s
'
because it is already known and the contents did not change: url=
'
%s
'"
,
template
[
'
name
'
],
template
[
'
version
'
],
known_template
[
'
url
'
])
...
...
@@ -198,7 +198,7 @@ def populate_schemas(schema_dir: str=None, dbcreds_name: str=None, parallel: boo
strategy_template_type
=
template
.
pop
(
'
template_type_name
'
)
try
:
known_template
=
client
.
_get_template
(
template_type_name
=
strategy_template_type
,
name
=
template
[
'
name
'
],
version
=
template
[
'
version
'
])
known_template
=
client
.
_get_
schema_
template
(
template_type_name
=
strategy_template_type
,
name
=
template
[
'
name
'
],
version
=
template
[
'
version
'
])
if
known_template
[
'
template
'
]
==
template
[
'
template
'
]:
logger
.
info
(
"
Skipping strategy template with name=
'
%s
'
version=
'
%s
'
because it is already known and the contents did not change: url=
'
%s
'"
,
template
[
'
name
'
],
template
[
'
version
'
],
known_template
[
'
url
'
])
else
:
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/client/lib/tmss_http_rest_client.py
+
32
−
8
View file @
c37f3e36
...
...
@@ -343,8 +343,8 @@ class TMSSsession(object):
response
.
elapsed
.
total_seconds
()
*
1000
,
'
SLOW!
'
if
response
.
elapsed
>
timedelta
(
seconds
=
1
)
else
''
,
response
.
request
.
url
))
def
_get_template
(
self
,
template_type_name
:
str
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the template of the given type as dict for the given name (and version)
'''
def
_get_
schema_
template
(
self
,
template_type_name
:
str
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the
schema
template of the given type as dict for the given name (and version)
'''
clauses
=
{}
if
name
is
not
None
:
clauses
[
"
name
"
]
=
name
...
...
@@ -372,19 +372,19 @@ class TMSSsession(object):
def
get_schedulingunit_template
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the schedulingunit_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
scheduling_unit_template
'
,
name
,
version
)
return
self
.
_get_
schema_
template
(
'
scheduling_unit_template
'
,
name
,
version
)
def
get_task_template
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the task_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
task_template
'
,
name
,
version
)
return
self
.
_get_
schema_
template
(
'
task_template
'
,
name
,
version
)
def
get_subtask_template
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the subtask_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
subtask_template
'
,
name
,
version
)
return
self
.
_get_
schema_
template
(
'
subtask_template
'
,
name
,
version
)
def
get_scheduling_constraints_template
(
self
,
name
:
str
=
'
constraints
'
,
version
:
int
=
None
)
->
dict
:
'''
get the scheduling_constraints_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
scheduling_constraints_template
'
,
name
,
version
)
return
self
.
_get_
schema_
template
(
'
scheduling_constraints_template
'
,
name
,
version
)
def
get_schedulingunit_template_default_specification
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
template
=
self
.
get_schedulingunit_template
(
name
=
name
,
version
=
version
)
...
...
@@ -400,7 +400,7 @@ class TMSSsession(object):
def
get_dataproduct_specifications_template
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the subtask_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
dataproduct_specifications_template
'
,
name
,
version
)
return
self
.
_get_
schema_
template
(
'
dataproduct_specifications_template
'
,
name
,
version
)
def
get_dataproduct_specifications_template_default_specification
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the subtask_template as dict for the given name (and version)
'''
...
...
@@ -702,7 +702,31 @@ class TMSSsession(object):
def
get_scheduling_unit_observing_strategy_template
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the scheduling_unit_observing_strategy_template as dict for the given name (and version)
'''
return
self
.
_get_template
(
'
scheduling_unit_observing_strategy_template
'
,
name
,
version
)
clauses
=
{}
if
name
is
not
None
:
clauses
[
"
name
"
]
=
name
if
version
is
not
None
:
clauses
[
"
version
"
]
=
version
else
:
# try to determine the latest version
if
name
is
not
None
:
try
:
templates
=
self
.
get_path_as_json_object
(
'
/scheduling_unit_observing_strategy_template
'
,
params
=
{
'
name
'
:
name
})
if
templates
:
templates
=
sorted
(
templates
,
key
=
lambda
t
:
t
[
'
version
'
])
clauses
[
"
version
"
]
=
templates
[
-
1
][
'
version
'
]
except
Exception
as
e
:
# could not determine latest version
pass
result
=
self
.
get_path_as_json_object
(
'
/scheduling_unit_observing_strategy_template
'
,
clauses
)
if
isinstance
(
result
,
list
):
if
len
(
result
)
>
1
:
raise
ValueError
(
"
Found more then one scheduling_unit_observing_strategy_template for clauses: %s
"
%
(
clauses
,))
elif
len
(
result
)
==
1
:
return
result
[
0
]
raise
ValueError
(
"
Could not find any template of type=
'
scheduling_unit_observing_strategy_template
'
and clauses=
'
%s
'"
%
(
clauses
,))
return
result
def
get_scheduling_unit_observing_strategy_template_default_specification
(
self
,
name
:
str
,
version
:
int
=
None
)
->
dict
:
'''
get the scheduling_unit_observing_strategy_template as dict for the given name (and version) with completely filled in with all defaults
'''
...
...
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