Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F73600782
pushQuantity.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, Jul 23, 01:28
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Jul 25, 01:28 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19233058
Attached To
R3127 blackdynamite
pushQuantity.py
View Options
#!/usr/bin/env python
import
BlackDynamite
as
BD
def
main
(
argv
=
None
):
parser
=
BD
.
BDParser
()
parser
.
register_params
(
group
=
"pushQuantity"
,
params
=
{
"runid"
:
int
,
"quantity_id"
:
str
,
"value"
:
str
,
"values"
:
[
str
],
"step"
:
int
,
"is_float"
:
bool
},
defaults
=
{
"step"
:
0
},
help
=
{
"runid"
:
"The id of the run to update"
,
"quantity_id"
:
"ID of the Quantity to push"
,
"value"
:
"Value tu push for the quantity"
,
"values"
:
"Vectorial value tu push for the quantity"
,
"step"
:
"Step at which the data is generated"
,
"is_float"
:
"0 if the quantity is a float 1 other why"
}
)
params
=
parser
.
parseBDParameters
()
if
(
"runid"
not
in
params
):
raise
Exception
(
"The run id should be set"
)
if
(
"quantity_id"
not
in
params
):
raise
Exception
(
"The quantity id should be set"
)
if
(
"value"
not
in
params
and
"values"
not
in
params
):
raise
Exception
(
"The value should be set"
)
is_vector
=
False
if
(
"values"
in
params
):
is_vector
=
True
if
(
"value"
in
params
):
raise
Exception
(
"You cannot define values and value at the same time"
)
base
=
BD
.
Base
(
**
params
)
if
(
"runid"
in
params
):
if
"run_constraints"
not
in
params
:
params
[
"run_constraints"
]
=
[]
params
[
"run_constraints"
]
.
append
(
"id = "
+
str
(
params
[
"runid"
]))
runSelector
=
BD
.
RunSelector
(
base
)
run_list
=
runSelector
.
selectRuns
(
params
,
params
)
if
(
not
len
(
run_list
)
==
1
):
raise
Exception
(
"No or too many runs selected"
)
r
,
j
=
run_list
[
0
]
if
(
params
[
"truerun"
]
==
True
):
if
(
is_vector
==
False
):
r
.
pushScalarQuantity
(
params
[
"value"
]
,
params
[
"step"
],
params
[
"quantity_id"
],
params
[
"is_float"
]
==
False
)
else
:
r
.
pushVectorQuantity
(
params
[
"values"
],
params
[
"step"
],
params
[
"quantity_id"
],
params
[
"is_float"
]
==
False
)
base
.
commit
()
if
__name__
==
'__main__'
:
main
()
Event Timeline
Log In to Comment