Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F74992739
runselector.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 30, 19:03
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Aug 1, 19:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19467491
Attached To
R3127 blackdynamite
runselector.py
View Options
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- py-which-shell: "python"; -*-
__all__
=
[
"RunSelector"
]
import
copy
import
run
import
job
import
selector
import
constraints
as
BDcons
################################################################
class
RunSelector
(
selector
.
Selector
):
"""
"""
def
selectRuns
(
self
,
constraints
,
sort_by
=
None
,
quiet
=
False
):
run_list
=
self
.
select
([
run
.
Run
,
job
.
Job
],
constraints
=
[
'job_id = jobs.id'
,
constraints
],
sort_by
=
sort_by
)
if
quiet
is
False
:
if
not
run_list
:
print
(
"no runs found"
)
print
(
"Selected runs are: "
+
str
([
r
[
0
]
.
id
for
r
in
run_list
]))
print
(
"Selected jobs are: "
+
str
([
r
[
0
][
"job_id"
]
for
r
in
run_list
]))
# run_list = self.buildJoinedList(myjob, myrun, curs)
return
run_list
def
buildJoinedList
(
self
,
job_object
,
run_object
,
curs
):
coljob_info
=
self
.
base
.
getColumnProperties
(
job_object
)
colrun_info
=
self
.
base
.
getColumnProperties
(
run_object
)
run_list
=
[]
for
entries
in
curs
:
jobj
=
copy
.
deepcopy
(
job_object
)
robj
=
copy
.
deepcopy
(
run_object
)
ncoljob
=
len
(
coljob_info
)
ncolrun
=
len
(
colrun_info
)
for
i
in
range
(
0
,
ncoljob
):
col_name
=
coljob_info
[
i
][
0
]
jobj
[
col_name
]
=
entries
[
i
]
jobj
.
id
=
jobj
[
"id"
]
for
i
in
range
(
0
,
ncolrun
):
col_name
=
colrun_info
[
i
][
0
]
robj
[
col_name
]
=
entries
[
i
+
ncoljob
]
robj
.
id
=
robj
[
"id"
]
run_list
.
append
([
robj
,
jobj
])
return
run_list
def
getObjectList
(
self
,
order
=
"id"
):
self
.
prepare
()
request
=
"SELECT * FROM {0}.{1} ORDER BY "
.
format
(
self
.
base
.
schema
,
self
.
table_name
)
+
order
curs
=
self
.
base
.
performRequest
(
request
)
return
self
.
buildList
(
curs
)
def
getMatchedObjectList
(
self
,
order_condition
=
""
):
condition
,
params
=
self
.
makeMatchingCondition
()
request
=
self
.
makeSelectRequest
()
# print (condition)
# print (order_condition)
if
(
condition
):
request
+=
"WHERE "
+
condition
if
(
order_condition
):
request
+=
order_condition
# print (request)
# print (params)
curs
=
self
.
base
.
performRequest
(
request
,
params
)
return
self
.
buildList
(
curs
)
def
__init__
(
self
,
base
):
selector
.
Selector
.
__init__
(
self
,
base
)
Event Timeline
Log In to Comment