Skip to content

Commit

Permalink
Merge pull request #44 from LinaresToine/3_primds_history
Browse files Browse the repository at this point in the history
API entry with primary dataset history
  • Loading branch information
LinaresToine authored Aug 1, 2023
2 parents 2b23419 + 0016c9a commit 08e4691
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/python/Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from T0WmaDataSvc.DataDatasetLocked import *
from T0WmaDataSvc.DataRepackStats import *
from T0WmaDataSvc.DataRunStreamSkippedLumis import *

from T0WmaDataSvc.DataPrimaryDatasetConfig import *

class Data(DatabaseRESTApi):
"""Server object for REST data access API."""
Expand All @@ -34,5 +34,6 @@ def __init__(self, app, config, mount):
"dataset_locked": DatasetLocked(app, self, config, mount),
"promptreco_status": PromptRecoStatus(app, self, config, mount),
"repack_stats": RepackStats(app, self, config, mount),
"skipped_streamers": RunStreamSkippedLumis(app, self, config, mount)
"skipped_streamers": RunStreamSkippedLumis(app, self, config, mount),
"primary_dataset_config": PrimaryDatasetConfig(app, self, config, mount)
})
49 changes: 49 additions & 0 deletions src/python/DataPrimaryDatasetConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 PrimaryDatasetConfig(RESTEntity):
"""REST entity for retrieving a specific primary dataset."""
def validate(self, apiobj, method, api, param, safe):
"""Validate request input data."""
validate_str('primary_dataset', param, safe, RX_PRIMARY_DATASET, optional = False)

@restcall(formats=[('text/plain', PrettyJSONFormat()), ('application/json', JSONFormat())])
@tools.expires(secs=300)
def get(self, primary_dataset):
"""Retrieve Reco configuration and its history for a specific primary dataset
:arg str primary_dataset: the primary dataset name (optional, otherwise queries for muon 0)
:returns: PrimaryDataset, Acquisition era, minimum run, maximum run, CMSSW, PhysicsSkim, DqmSeq, GlobalTag"""

sql = """
SELECT reco_config.primds primds, MIN(run_config.run) min_run, MAX(run_config.run) max_run, reco_config.cmssw cmssw, reco_config.global_tag global_tag, reco_config.physics_skim physics_skim, reco_config.dqm_seq dqm_seq, run_config.acq_era acq_era
FROM reco_config
JOIN run_config ON run_config.run = reco_config.run
WHERE primds = :primds
GROUP BY run_config.acq_era, reco_config.primds, reco_config.cmssw, reco_config.global_tag, reco_config.physics_skim, reco_config.dqm_seq
ORDER BY MIN(run_config.run) desc, MAX(run_config.run) desc
"""

c, _ = self.api.execute(sql, primds = primary_dataset)

configs = []
for result in c.fetchall():

(primds, min_run, max_run, cmssw, global_tag, physics_skim, dqm_seq, acq_era) = result

config = { "primary_dataset" : primds,
"min_run" : min_run,
"max_run" : max_run,
"cmssw" : cmssw,
"global_tag" : global_tag,
"physics_skim" : physics_skim,
"dqm_seq" : dqm_seq,
"acq_era" : acq_era }
configs.append(config)

return configs

0 comments on commit 08e4691

Please sign in to comment.