-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from germanfgv/skippedStream
Adds skipped_streamers table to T0 Data Service
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from WMCore.REST.Server import RESTEntity, restcall, rows | ||
from WMCore.REST.Tools import tools | ||
from WMCore.REST.Validation import * | ||
from WMCore.REST.Format import JSONFormat, PrettyJSONFormat | ||
from T0WmaDataSvc.Regexps import * | ||
from operator import itemgetter | ||
|
||
class RunStreamSkippedLumis(RESTEntity): | ||
"""REST entity for retrieving run/stream/lumis that have been skipped during processing.""" | ||
def validate(self, apiobj, method, api, param, safe): | ||
"""Validate request input data.""" | ||
validate_str('run', param, safe, RX_RUN, optional = True) | ||
validate_str('stream', param, safe, RX_STREAM, optional = True) | ||
|
||
@restcall(formats=[('text/plain', PrettyJSONFormat()), ('application/json', JSONFormat())]) | ||
@tools.expires(secs=300) | ||
def get(self,run, stream): | ||
"""Retrieve run/stream/lumis that have been skipped during processing. If no run or stream is | ||
specified, returns the latest 100 skipped runs | ||
:arg int run: the run number | ||
:arg str primary_dataset: the primary dataset name (optional, otherwise queries for all) | ||
:returns: list of skipped lumis in each run/stream combination, and number of events in the lumi""" | ||
|
||
sql = """SELECT run, stream, lumi, events | ||
FROM skipped_streamers | ||
WHERE run is not null""" | ||
sqlWithRun = " AND skipped_streamers.run = :run" | ||
sqlWithStream = " AND skipped_streamers.stream = :stream" | ||
sqlOrder = " ORDER BY run desc, stream asc, lumi asc" | ||
sqlLimit = " FETCH FIRST 100 ROWS ONLY" | ||
|
||
binds = {} | ||
if run is not None: | ||
sql += sqlWithRun | ||
binds.update({"run":run}) | ||
if stream is not None: | ||
sql += sqlWithStream | ||
binds.update({"stream":stream}) | ||
sql += sqlOrder | ||
if run is None: | ||
sql += sqlLimit | ||
|
||
c, _ = self.api.execute(sql, binds) | ||
results=c.fetchall() | ||
|
||
runs={} | ||
for run, stream, lumi, events in results: | ||
runDict=runs.setdefault(run,{}) | ||
streamDict=runDict.setdefault(stream,{}) | ||
streamDict[lumi]=events | ||
|
||
return [runs] |