Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60526637
updateRuns.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Apr 30, 21:04
Size
1 KB
Mime Type
text/x-python
Expires
Thu, May 2, 21:04 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17367756
Attached To
R3127 blackdynamite
updateRuns.py
View Options
#!/usr/bin/env python3
import
BlackDynamite
as
BD
import
os
import
sys
import
socket
parser
=
BD
.
BDParser
()
parser
.
register_params
(
group
=
"updateRuns"
,
params
=
{
"run_id"
:
int
,
"updates"
:
[
str
]},
defaults
=
{
"machine_name"
:
socket
.
gethostname
()},
help
=
{
"run_id"
:
"The id of the run to update"
,
"updates"
:
"The updates to perform. Syntax should be 'key = newval'"
}
)
params
=
parser
.
parseBDParameters
()
if
"user"
not
in
params
.
keys
():
params
[
"user"
]
=
os
.
getlogin
()
base
=
BD
.
Base
(
**
params
)
if
"run_id"
in
params
:
if
"constraints"
not
in
params
:
params
[
"constraints"
]
=
[]
params
[
"constraints"
]
.
append
(
"runs.id = "
+
str
(
params
[
"run_id"
]))
runSelector
=
BD
.
RunSelector
(
base
)
run_list
=
runSelector
.
selectRuns
(
params
)
if
len
(
run_list
)
==
0
:
print
(
"No runs to be updated"
)
if
"updates"
not
in
params
:
print
(
"No update to be performed: use --updates option"
)
sys
.
exit
(
-
1
)
for
r
,
j
in
run_list
:
r
.
setFields
(
params
[
"updates"
])
if
params
[
"truerun"
]
is
True
:
r
.
update
()
base
.
commit
()
Event Timeline
Log In to Comment