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
0a7a4931
Commit
0a7a4931
authored
5 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-516
: datetimes are now automagically converted
parent
cdd7cace
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssignmentService/rpc.py
+8
-47
8 additions, 47 deletions
SAS/ResourceAssignment/ResourceAssignmentService/rpc.py
with
8 additions
and
47 deletions
SAS/ResourceAssignment/ResourceAssignmentService/rpc.py
+
8
−
47
View file @
0a7a4931
...
@@ -60,7 +60,7 @@ class RARPC(RPCWrapper):
...
@@ -60,7 +60,7 @@ class RARPC(RPCWrapper):
def
getResourceClaims
(
self
,
claim_ids
=
None
,
lower_bound
=
None
,
upper_bound
=
None
,
resource_ids
=
None
,
task_ids
=
None
,
def
getResourceClaims
(
self
,
claim_ids
=
None
,
lower_bound
=
None
,
upper_bound
=
None
,
resource_ids
=
None
,
task_ids
=
None
,
status
=
None
,
resource_type
=
None
,
extended
=
False
,
include_properties
=
False
):
status
=
None
,
resource_type
=
None
,
extended
=
False
,
include_properties
=
False
):
claims
=
self
.
rpc
(
'
GetResourceClaims
'
,
claim_ids
=
claim_ids
,
return
self
.
rpc
(
'
GetResourceClaims
'
,
claim_ids
=
claim_ids
,
lower_bound
=
lower_bound
,
lower_bound
=
lower_bound
,
upper_bound
=
upper_bound
,
upper_bound
=
upper_bound
,
resource_ids
=
resource_ids
,
resource_ids
=
resource_ids
,
...
@@ -70,21 +70,8 @@ class RARPC(RPCWrapper):
...
@@ -70,21 +70,8 @@ class RARPC(RPCWrapper):
extended
=
extended
,
extended
=
extended
,
include_properties
=
include_properties
)
include_properties
=
include_properties
)
logger
.
debug
(
"
found %s claims for claim_ids=%s, lower_bound=%s, upper_bound=%s, task_ids=%s, status=%s, resource_type=%s
"
,
len
(
claims
),
claim_ids
,
lower_bound
,
upper_bound
,
task_ids
,
status
,
resource_type
)
for
claim
in
claims
:
claim
[
'
starttime
'
]
=
claim
[
'
starttime
'
].
datetime
()
claim
[
'
endtime
'
]
=
claim
[
'
endtime
'
].
datetime
()
return
claims
def
getResourceClaim
(
self
,
id
):
def
getResourceClaim
(
self
,
id
):
resource_claim
=
self
.
rpc
(
'
GetResourceClaim
'
,
id
=
id
)
return
self
.
rpc
(
'
GetResourceClaim
'
,
id
=
id
)
if
resource_claim
:
resource_claim
[
'
starttime
'
]
=
resource_claim
[
'
starttime
'
].
datetime
()
resource_claim
[
'
endtime
'
]
=
resource_claim
[
'
endtime
'
].
datetime
()
return
resource_claim
def
insertResourceClaim
(
self
,
resource_id
,
task_id
,
starttime
,
endtime
,
status
,
claim_size
,
username
,
def
insertResourceClaim
(
self
,
resource_id
,
task_id
,
starttime
,
endtime
,
status
,
claim_size
,
username
,
user_id
,
used_rcus
=
None
,
properties
=
None
):
user_id
,
used_rcus
=
None
,
properties
=
None
):
...
@@ -158,11 +145,6 @@ class RARPC(RPCWrapper):
...
@@ -158,11 +145,6 @@ class RARPC(RPCWrapper):
all_usages
=
convertStringDigitKeysToInt
(
all_usages
)
all_usages
=
convertStringDigitKeysToInt
(
all_usages
)
for
resource_id
,
resource_usages_per_status
in
list
(
all_usages
.
items
()):
for
status
,
usages
in
list
(
resource_usages_per_status
.
items
()):
for
usage
in
usages
:
usage
[
'
as_of_timestamp
'
]
=
usage
[
'
as_of_timestamp
'
].
datetime
()
return
all_usages
return
all_usages
def
getResourceGroupTypes
(
self
):
def
getResourceGroupTypes
(
self
):
...
@@ -196,11 +178,7 @@ class RARPC(RPCWrapper):
...
@@ -196,11 +178,7 @@ class RARPC(RPCWrapper):
def
getTask
(
self
,
id
=
None
,
mom_id
=
None
,
otdb_id
=
None
,
specification_id
=
None
):
def
getTask
(
self
,
id
=
None
,
mom_id
=
None
,
otdb_id
=
None
,
specification_id
=
None
):
'''
get a task for either the given (task)id, or for the given mom_id, or for the given otdb_id, or for the given specification_id
'''
'''
get a task for either the given (task)id, or for the given mom_id, or for the given otdb_id, or for the given specification_id
'''
task
=
self
.
rpc
(
'
GetTask
'
,
id
=
id
,
mom_id
=
mom_id
,
otdb_id
=
otdb_id
,
specification_id
=
specification_id
)
return
self
.
rpc
(
'
GetTask
'
,
id
=
id
,
mom_id
=
mom_id
,
otdb_id
=
otdb_id
,
specification_id
=
specification_id
)
if
task
:
task
[
'
starttime
'
]
=
task
[
'
starttime
'
].
datetime
()
task
[
'
endtime
'
]
=
task
[
'
endtime
'
].
datetime
()
return
task
def
insertTask
(
self
,
mom_id
,
otdb_id
,
task_status
,
task_type
,
specification_id
):
def
insertTask
(
self
,
mom_id
,
otdb_id
,
task_status
,
task_type
,
specification_id
):
return
self
.
rpc
(
'
InsertTask
'
,
mom_id
=
mom_id
,
return
self
.
rpc
(
'
InsertTask
'
,
mom_id
=
mom_id
,
...
@@ -227,10 +205,7 @@ class RARPC(RPCWrapper):
...
@@ -227,10 +205,7 @@ class RARPC(RPCWrapper):
task_status
=
task_status
)
task_status
=
task_status
)
def
getTasksTimeWindow
(
self
,
task_ids
=
None
,
mom_ids
=
None
,
otdb_ids
=
None
):
def
getTasksTimeWindow
(
self
,
task_ids
=
None
,
mom_ids
=
None
,
otdb_ids
=
None
):
result
=
self
.
rpc
(
'
GetTasksTimeWindow
'
,
task_ids
=
task_ids
,
mom_ids
=
mom_ids
,
otdb_ids
=
otdb_ids
)
return
self
.
rpc
(
'
GetTasksTimeWindow
'
,
task_ids
=
task_ids
,
mom_ids
=
mom_ids
,
otdb_ids
=
otdb_ids
)
result
[
'
min_starttime
'
]
=
result
[
'
min_starttime
'
].
datetime
()
result
[
'
max_endtime
'
]
=
result
[
'
max_endtime
'
].
datetime
()
return
result
def
getTasks
(
self
,
lower_bound
=
None
,
upper_bound
=
None
,
task_ids
=
None
,
task_status
=
None
,
task_type
=
None
,
mom_ids
=
None
,
otdb_ids
=
None
,
cluster
=
None
):
def
getTasks
(
self
,
lower_bound
=
None
,
upper_bound
=
None
,
task_ids
=
None
,
task_status
=
None
,
task_type
=
None
,
mom_ids
=
None
,
otdb_ids
=
None
,
cluster
=
None
):
'''
getTasks let
'
s you query tasks from the radb with many optional filters.
'''
getTasks let
'
s you query tasks from the radb with many optional filters.
...
@@ -243,11 +218,7 @@ class RARPC(RPCWrapper):
...
@@ -243,11 +218,7 @@ class RARPC(RPCWrapper):
:param otdb_ids: int/list/tuple specifies one or more otdb_ids to select
:param otdb_ids: int/list/tuple specifies one or more otdb_ids to select
:param cluster: string specifies the cluster to select
:param cluster: string specifies the cluster to select
'''
'''
tasks
=
self
.
rpc
(
'
GetTasks
'
,
lower_bound
=
lower_bound
,
upper_bound
=
upper_bound
,
task_ids
=
task_ids
,
task_status
=
task_status
,
task_type
=
task_type
,
mom_ids
=
mom_ids
,
otdb_ids
=
otdb_ids
,
cluster
=
cluster
)
return
self
.
rpc
(
'
GetTasks
'
,
lower_bound
=
lower_bound
,
upper_bound
=
upper_bound
,
task_ids
=
task_ids
,
task_status
=
task_status
,
task_type
=
task_type
,
mom_ids
=
mom_ids
,
otdb_ids
=
otdb_ids
,
cluster
=
cluster
)
for
task
in
tasks
:
task
[
'
starttime
'
]
=
task
[
'
starttime
'
].
datetime
()
task
[
'
endtime
'
]
=
task
[
'
endtime
'
].
datetime
()
return
tasks
def
getTaskPredecessorIds
(
self
,
id
=
None
):
def
getTaskPredecessorIds
(
self
,
id
=
None
):
return
self
.
rpc
(
'
GetTaskPredecessorIds
'
,
id
=
id
)
return
self
.
rpc
(
'
GetTaskPredecessorIds
'
,
id
=
id
)
...
@@ -268,11 +239,7 @@ class RARPC(RPCWrapper):
...
@@ -268,11 +239,7 @@ class RARPC(RPCWrapper):
return
self
.
rpc
(
'
GetTaskStatuses
'
)
return
self
.
rpc
(
'
GetTaskStatuses
'
)
def
getSpecification
(
self
,
id
):
def
getSpecification
(
self
,
id
):
specification
=
self
.
rpc
(
'
GetSpecification
'
,
id
=
id
)
return
self
.
rpc
(
'
GetSpecification
'
,
id
=
id
)
if
specification
:
specification
[
'
starttime
'
]
=
specification
[
'
starttime
'
].
datetime
()
specification
[
'
endtime
'
]
=
specification
[
'
endtime
'
].
datetime
()
return
specification
def
insertSpecificationAndTask
(
self
,
mom_id
,
otdb_id
,
task_status
,
task_type
,
starttime
,
endtime
,
content
,
cluster
):
def
insertSpecificationAndTask
(
self
,
mom_id
,
otdb_id
,
task_status
,
task_type
,
starttime
,
endtime
,
content
,
cluster
):
return
self
.
rpc
(
'
InsertSpecificationAndTask
'
,
return
self
.
rpc
(
'
InsertSpecificationAndTask
'
,
...
@@ -304,11 +271,7 @@ class RARPC(RPCWrapper):
...
@@ -304,11 +271,7 @@ class RARPC(RPCWrapper):
cluster
=
cluster
)
cluster
=
cluster
)
def
getSpecifications
(
self
):
def
getSpecifications
(
self
):
specifications
=
self
.
rpc
(
'
GetSpecifications
'
)
return
self
.
rpc
(
'
GetSpecifications
'
)
for
specification
in
specifications
:
specification
[
'
starttime
'
]
=
specification
[
'
starttime
'
].
datetime
()
specification
[
'
endtime
'
]
=
specification
[
'
endtime
'
].
datetime
()
return
specifications
def
getUnits
(
self
):
def
getUnits
(
self
):
return
self
.
rpc
(
'
GetUnits
'
)
return
self
.
rpc
(
'
GetUnits
'
)
...
@@ -328,13 +291,11 @@ class RARPC(RPCWrapper):
...
@@ -328,13 +291,11 @@ class RARPC(RPCWrapper):
claim_id
=
claim_id
)
claim_id
=
claim_id
)
def
get_max_resource_usage_between
(
self
,
resource_id
,
lower_bound
,
upper_bound
,
claim_status
=
'
claimed
'
):
def
get_max_resource_usage_between
(
self
,
resource_id
,
lower_bound
,
upper_bound
,
claim_status
=
'
claimed
'
):
re
sult
=
self
.
rpc
(
'
get_max_resource_usage_between
'
,
re
turn
self
.
rpc
(
'
get_max_resource_usage_between
'
,
resource_id
=
resource_id
,
resource_id
=
resource_id
,
lower_bound
=
lower_bound
,
lower_bound
=
lower_bound
,
upper_bound
=
upper_bound
,
upper_bound
=
upper_bound
,
claim_status
=
claim_status
)
claim_status
=
claim_status
)
result
[
'
as_of_timestamp
'
]
=
result
[
'
as_of_timestamp
'
].
datetime
()
return
result
def
get_resource_claimable_capacity
(
self
,
resource_id
,
lower_bound
,
upper_bound
):
def
get_resource_claimable_capacity
(
self
,
resource_id
,
lower_bound
,
upper_bound
):
'''
get the claimable capacity for the given resource within the timewindow given by lower_bound and upper_bound.
'''
get the claimable capacity for the given resource within the timewindow given by lower_bound and upper_bound.
...
...
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